Incident Viewport
Purpose
This service returns legal and technical information for the viewport described in the request. It should be called by client applications whenever the viewport changes (for instance, through zooming, panning, going to a location, or displaying a route).
- The request should contain the bounding box and zoom level of the viewport whose information is needed.
- The response will contain map version information, as well as the most recent Traffic Model ID and copyright IDs.
The Traffic Model ID returned by the Viewport Description is used by other services to retrieve last traffic information for further processing.
Run this endpoint
You can easily run this and other endpoints. Go to the TomTom API Explorer page and follow the directions.
Request data
HTTPS method: GET
- Constants and parameters enclosed in curly brackets { } must be replaced with their values.
- Please see the following Request parameters section with the required and optional parameters tables for their values. The generic request format is as follows.
URL format
https://{baseURL}/traffic/services/{versionNumber}/incidentViewport/{boundingBox}/{boundingZoom}/{overviewBox}/{overviewZoom}/{copyright}/{contentType}?key={Your_API_Key}&jsonp={jsonp}
Example
https://api.tomtom.com/traffic/services/4/incidentViewport/-939584.4813015489,-23954526.723651607,14675583.153020501,25043442.895825107/2/-939584.4813015489,-23954526.723651607,14675583.153020501,25043442.895825107/2/true/xml?key={Your_API_Key}
curl command format
curl 'https://api.tomtom.com/traffic/services/4/incidentViewport/-939584.4813015489,-23954526.723651607,14675583.153020501,25043442.895825107/2/-939584.4813015489,-23954526.723651607,14675583.153020501,25043442.895825107/2/true/xml?key={Your_API_Key}'
Request parameters
The following table describes the parameters that can be used in a request.
- Required parameters must be used or the call will fail.
- Parameters and values are case-sensitive.
- Optional parameters may be used.
Required parameters | Description |
---|---|
| The base URL for calling TomTom services.
|
| Version of the service to call. |
| Bounding box of the map viewport in an
EPSG:900913
projection. The maximum size of the bounding box that can be passed is
dependent on the requested zoom level. The width and height cannot
exceed the square of a side of 16 tiles for a given zoom level. See the
Maximum bounding box section for
details. |
| The zoom level of the map viewport. Used to determine whether the view
can be zoomed in. |
| Bounding box of the overview map in EPSG:900913 projection. Used in case
the overview box/mini map has different copyright data than the main
map. If there is no mini map, use the same coordinates as in the
preceding |
| Zoom level of the overview map. If there is no mini map, use the same
zoom level as in the preceding |
| Determines what copyright information to return. When |
| The content type of the response structure. If the content type is
jsonp, a callback method must be specified at the end of the service
call.
|
| The Authorization key for access to the API. |
Optional parameters | Description |
---|---|
| Specifies the callback method. It is only used where the
|
Maximum bounding box
In EPSG:900913 projection we use an extent of the world from -20037508.34 to 20037508.34 in each direction.
- On each zoom level the world is divided into 2zoom x 2zoom tiles.
- The maximum allowed size of the requested bounding box is a square of size 16 x 16 tiles.
For zoom level 5
and greater, the width and height cannot exceed 40075016.68 / 2zoom - 4.
Note that bounding boxes that cross the 180° meridian require special treatment.
- For such boxes, the eastern
maxX
value will be negative, and thus less than theminX
value west of the 180° meridian. - To address that, the value
40075016.6855874
should be added to the truemaxX
value before it is passed in the request.
Request headers
The following table lists HTTP request headers of particular interest to clients of the Traffic Incident Viewport endpoint. Note: There are no required headers in this endpoint.
Optional headers | Description |
---|---|
Tracking-ID | Specifies an identifier for the request. It can be used to trace a call.
The value must match the regular expression
|
Response data
Successful response
The Incident Viewport API endpoint for a valid single request returns a response in XML, JSON, or JSONP format.
XML response body example
The following XML code block demonstrates a successful response from the API server. Note: An XSD response schema is available for download.
The XML response of the preceding sample request would look like this:
1<viewpResp xmlns="http://lbs.tomtom.com/services" maps="world" version="traffic-service 2.0.004">2 <trafficState trafficModelId="1400143970784" trafficAge="28320"/>3 <copyrightIds>4 https://www.tomtom.com/en_gb/thirdpartyproductterms/5 </copyrightIds>6</viewpResp>
A typical response in JSON would be:
1{2 "viewpResp": {3 "trafficState": {4 "@trafficAge": 28320,5 "@trafficModelId": "1400143970784"6 },7 "copyrightIds": "https://www.tomtom.com/en_gb/thirdpartyproductterms/",8 "@version": "traffic-service 2.0.004",9 "@maps": "world"10 }11}
Response field structure
The following table describes all of the XML/JSON element fields that can appear in a response. The types of the fields refer to a JSON response.
Field | Description |
---|---|
| The main response element. The key attributes are:
|
| Traffic information.
|
| Copyright information for the map viewport. When the
|
Error response
If there is an error in the supplied parameters or any other internal problem:
- An error response is generated in the requested format.
- If the
contentType
parameter could not be parsed, XML is returned.
Error response field structure | |
---|---|
Field | Description |
| Main object of the error response. |
| One of a server-defined set of error codes. |
| A human-readable description of the error code. |
1{2 "errorResponse": {3 "@errorCode": 400,4 "@description": "Error validating overviewBbox: ",5 "@version": "traffic-service 4.0.010"6 },7 "detailedError": {8 "code": "INVALID_REQUEST",9 "message": "Error validating overviewBbox: "10 }11}
1<errorResponse description="Error validating overviewBbox: "errorCode"="400" version="traffic-service 4.0.010">2 <detailedError>3 <code>INVALID_REQUEST</code>4 <message>Error validating overviewBbox: </message>5 </detailedError>6</errorResponse>
Response codes
Code | Meaning & possible causes |
---|---|
| OK |
| Bad request |
| Forbidden: The supplied API Key is not valid for this request. |
| Not Found: The requested resource cannot be found. |
| Method Not Allowed: The provided HTTP request method is known by the server, but is not supported by the target resource. |
| Too Many Requests: Too many requests were sent in a given amount of time for the supplied API Key. |
| Internal Server Error |
| Service currently unavailable: The service is currently unavailable. |
| Service Not Found: Unknown version of the service. |
Response headers
The following table lists HTTP response headers of particular interest to clients of the Traffic Incident Viewport API endpoint.
Header | Description |
---|---|
Indicates that cross-origin resource sharing (CORS) is allowed. | |
Lists the set of supported HTTP methods. The header is sent in case a
| |
Contains directives for a caching mechanism. | |
Contains information about the size of the response body. | |
Indicates the media type of the resource returned.
| |
Contains the date and time when the message was originated. | |
Tracking-ID | An identifier for the request. If the
Tracking-ID header was specified in
the request, it is replicated in the response. Otherwise, it is
generated automatically by the service. For details check
RFC 4122. It is only meant to be used for support and does not involve tracking
of you or your users in any form. |