Keep track of your requests
Include X-Request-ID and billingTag in your API requests to enable system administrators and developers to analyze, improve, and enhance the efficiency of request handling.
X-Request-ID
This unique identifier allows you to link the requests you make with the server's log entries. You can create this ID and send it along with your request to the server. Once received, the server embeds this ID in every log entry.
While troubleshooting a request issue, including this ID in your bug report facilitates tracing the exact log statements related to your request. This eliminates the need to rely on timestamps, IPs, or other factors, streamlining the debugging process.
As a best practice, embed the X-Request-ID in the request header to ensure better security, integrity, and adherence to common practices. The following sample shows how to automatically generate an X-Request-ID and add it to a request header in Python:
import requests
import uuid
# Generate a unique X-Request-ID using uuid
x_request_id = str(uuid.uuid4())
# Define the headers
headers = {
'X-Request-ID': x_request_id,
# Add other headers as needed
}
# Make the request
response = requests.get('http://example.com', headers=headers)Note
- The
X-Request-IDheader is recorded and returned correctly only for requests that lead to cache misses (scenarios when the content delivery network, or CDN, needs to fetch content from the origin server to serve a request).- For requests that result in cache hits (scenarios when you request content that is already cached and does not need to be fetched from the origin server), the user-provided
X-Request-IDis replaced by anotherX-Request-IDthat was automatically generated on the server side.
billingTag
This is a user-defined key-value pair that you can add to a request to group and categorize costs in the billing reports. billingTag allows you to track request usage and manage costs across different teams, projects, or environments. Unlike X-Request-ID, which is often generated automatically and used for tracing requests, a billing tag is typically set manually.
For information on how to create a valid billing tag, see Add and use billing tags in the Cost Management Developer Guide.
For example, when the client application initiates a task involving both routing and rendering requests, it can use the same billingTag value for all operations. Later, this shared identifier can help categorize and consolidate these interconnected requests for such billing purposes like calculating the overall price for the task, regardless of the number of requests sent to a service.
Next steps
- To explore all supported endpoints and parameters, see the API Reference.
- To gain more hands-on experience with the HERE Map Image API see the
Tutorialssection of this guide.
Updated last month