Skip to content

Trace Attributes





The trace attributes API gives you detailed information along a route or at a single point. Attribute tracing lets you level up your navigation application with just-in-time details about the upcoming section of the route, conserving data in case the user misses a turn, or get detailed road network information from a GPS trace.

Hera are just a few of the attributes you'll get back from the API:

  • Road name, class, and estimated speed (for routing / ETA calculations)
  • Whether a section contains a tunnel or bridge
  • Elevation and grade information
  • Posted speed limits (subject to availability)


Example Code


Get started quickly with code samples using our official SDKs or cURL. Official SDKs include documentation of all request and response models, either as separate pages, or through docstrings and autocomplete in most IDEs. If you are building for another language or want to try out requests in a browser, refer to our interactive API reference.

import { RoutingApi, Configuration, TraceAttributesRequest } from '@stadiamaps/api';

// If you are writing for a backend application or can't use domain-based auth,
// then you'll need to add your API key like so:
// const config = new Configuration({ apiKey: "YOUR-API-KEY" });
// You can also use our EU endpoint to keep traffic within the EU using the basePath option:
// const config = new Configuration({ basePath: "" });
// const api = new RoutingApi(config);
const api = new RoutingApi();

// A trace attributes request using an encoded polyline. You can also use a list of coordinates to specify the shape.
const req: TraceAttributesRequest = {
    id: "trace",
    encodedPolyline: "kydw~@zm|g`DE`i@`JhDrAjEzM|FzWfL^sYH_EToCl@gAnE?rOBxKHE~B",
    shapeMatch: "map_snap",
    costing: "pedestrian",
    units: DistanceUnit.Mi
const res = await api.traceAttributes({ traceAttributesRequest: req });
import os
import stadiamaps
from import ApiException

# You can also use our EU endpoint to keep traffic within the EU like so:
# configuration = stadiamaps.Configuration(host="")
configuration = stadiamaps.Configuration()

# Configure API key authentication (ex: via environment variable).
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

with stadiamaps.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = stadiamaps.RoutingApi(api_client)

        req = stadiamaps.TraceAttributesRequest(

        res = api_instance.trace_attributes(req)
    except ApiException as e:
        # Add your error handling here
        print("Exception when calling the Stadia Maps API: %s\n" % e)
// Imports (at the top of your source file; we've used some wildcard imports for simplicity)
import com.stadiamaps.api.apis.*
import com.stadiamaps.api.auth.ApiKeyAuth
import com.stadiamaps.api.infrastructure.*
import com.stadiamaps.api.models.*

// Set your API key (from an environment variable in this case)
val apiKey = System.getenv("STADIA_API_KEY") ?: throw RuntimeException("API Key not set")

// Defining the host is optional and defaults to
// You can also use our EU endpoint to keep traffic within the EU like so:
// val client = ApiClient(baseUrl = "")
val client = ApiClient()
client.addAuthorization("ApiKeyAuth", ApiKeyAuth("query", "api_key", apiKey))

// Configure a service for the group of APIs we want to talk to
val service = client.createService(

// Set up the request. Note: if you're using Kotlin with coroutines, you can also await
// rather than executing synchronously when using suspend functions.
val req = TraceAttributesRequest(
    id = "map_match",
    encodedPolyline = "kydw~@zm|g`DE`i@`JhDrAjEzM|FzWfL^sYH_EToCl@gAnE?rOBxKHE~B",
    costing = MapMatchCostingModel.pedestrian,
val res = service.traceAttributes(req).execute()

if (res.isSuccessful) {
    println("Found result: ${res.body()}")
} else {
    println("Request failed with error code ${res.code()}")
import StadiaMaps

// This setup code can go anywhere before you actually make an API call (typically in your app init)
func setupStadiaMapsAPI() {
    // Set your API key
    StadiaMapsAPI.customHeaders = ["Authorization": "Stadia-Auth YOUR-API-KEY"]
    // Optionally use our EU endpoint to keep traffic within the EU
    // StadiaMapsAPI.basePath = ""

// This function demonstrates how to call the Stadia Maps API.
// If you have not yet adopted async/await in your Swift codebase, you can use the Task API
// to call async functions in a non-async context:
func myFunction() async throws {
     let req = TraceAttributesRequest(
        id: "trace",
        encodedPolyline: "kydw~@zm|g`DE`i@`JhDrAjEzM|FzWfL^sYH_EToCl@gAnE?rOBxKHE~B",
        costing: .pedestrian, shapeMatch: .mapSnap
    let res = try await RoutingAPI.traceAttributes(traceAttributesRequest: req)

    // Do something with the response...
curl -X POST -H "Content-Type: application/json" --data-raw '{
    "id": "trace",
    "encoded_polyline": "kydw~@zm|g`DE`i@`JhDrAjEzM|FzWfL^sYH_EToCl@gAnE?rOBxKHE~B",
    "shape_match": "map_snap",
    "costing": "pedestrian",
    "units": "miles"
}' ""

Complementary APIs

Attribute tracing pairs well with several other APIs. Most commonly, it complements either map matching or standard routing, providing detailed information along edges of the routing graph (road segments).

Next Steps