Vector Flow Tiles
Purpose
The Traffic Vector Flow Tiles API endpoint provides data on zoom levels ranging from 0
to 22
. For zoom level 0
, the world is displayed on a single tile. At zoom level 22
, the world is divided into 244 tiles. See the Zoom Levels and Tile Grid.
The service delivers traffic flow data packaged in a vector representation of squared sections called vector tiles. Each tile includes a pre-defined collection of road shapes with traffic flow data. The format of the tile is formally described using the protobuf schema. It shows either the current speed of traffic on different road segments, or the difference between current speed and the free-flow speed on the road segment.
Tiles resolution
Road geometry is stored as coordinates in the range of 0-4095
. Coordinates (0,0)
define the top-left corner of the tile.
Run this endpoint
You can easily run this and other endpoints. Go to the TomTom API Explorer page and follow the directions.
Vector format
The Vector format is a binary format created by using Google Protocol Buffers to serialize the data according to this defined vector schema.
The data is mapped to a protobuf layer called "Traffic flow". Besides the protobuf layers, the protobuf tags are also used to further describe the traffic. The protobuf tags are split into two categories: default and on-demand.
- The default tags are used unless they are filtered out by the
tags
request parameter. - The on-demand tags are used only if they were added by the
tags
request parameter.
Currently, the following Traffic flow tags are used.
Default tags
Tag | Description |
---|---|
| The tag value describes the road type.
|
| The tag value indicates the traffic speed.
See the
traffic flow types section
for details.
|
| The tag value describes if the traffic is assigned to the whole road
(one way road), or only to one side (two-way road).
|
| The tag presence indicates if the road has left-hand traffic. If the tag
is not present the road has right-hand traffic. |
| The tag presence indicates if the road is closed to traffic. If the tag
is not present the road is not closed and is passable. |
On-demand tags
Tag | Description |
---|---|
| The tag value describes the road category.
|
| The tag presence indicates if the road has a subcategory. Not all road
categories have subcategories.
|
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/map/{versionNumber}/tile/flow/{type}/{zoom}/{x}/{y}.{format}?key={Your_API_Key}&roadTypes={roadTypes[]}
Example
https://api.tomtom.com/traffic/map/4/tile/flow/relative/5/4/8.pbf?key={Your_API_Key}&roadTypes={[2,4,5]}
curl command format
curl 'https://api.tomtom.com/traffic/map/4/tile/flow/relative/5/4/8.pbf?key={Your_API_Key}&roadTypes={[2,4,5]&trafficLevelStep={trafficLevelStep}&margin={margin}&tags={[tags]}'
Request parameters
These elements are used in calls to generate all vector tile layers.
- 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.
|
| The version of the service to call. |
| Types of traffic flow. See the
Traffic flow types section for
details.
|
| The zoom level of a tile to be rendered. |
| The x coordinate of a tile on the zoom grid. |
| The y coordinate of a tile on the zoom grid. |
| The format of the response. |
| An API Key valid for the requested service. |
Optional parameters | Description |
---|---|
| The list of values representing the road types, which are going to be displayed on a particular zoom level according to the mapping:
The list of values must be enclosed in square brackets |
| The step value, describing the minimum difference between values of the
Values:
|
| The size of the tile margin, relative to the tile size. |
| The list of the values representing the available tags in the tile:
By default, only the default tags are attached to the tile geometry. See the Vector format for details.
Value: Square brackets enclosed list/array. |
Types of traffic flow
There are various types of traffic flow to use.
absolute
: this reflects the absolute speed.relative
: this is the speed relative to free-flow, highlighting areas of congestion.relative-delay
: this is the speed relative to free-flow (the same asrelative
), but it only shows areas of high congestion.
Host name cycling
Most web browsers have a default limitation on the number of active connections that can be allowed to each host. This means if map tiles are being loaded via the api.tomtom.com
host name, they will be loaded one at a time. A trick that can be used to get around this limitation is to cycle through the hosts we have created as aliases. These host names are:
- a.api.tomtom.com
- b.api.tomtom.com
- c.api.tomtom.com
- d.api.tomtom.com
By cycling through these four different host names, the web browser will be tricked into retrieving four map tiles at a time rather than just one. This will significantly speed up the performance of map rendering.
For instance, if four map tiles are being requested at zoom level one, you would request the first one as:
https://a.api.tomtom.com/traffic/map/4/tile/flow/relative/1/0/0.pbf?key={Your_API_Key}
The second would be:
https://b.api.tomtom.com/traffic/map/4/tile/flow/relative/1/0/0.pbf?key={Your_API_Key}
and so on up until d.api.tomtom.com. When more than four tiles are being requested, start back again at a.api.tomtom.com.
Request headers
Note: There are no required headers in this endpoint.
Optional headers | Description |
---|---|
Contains the content encoding (usually a compression algorithm), that
the client is able to understand. | |
Contains an identifier for a specific version of a resource. The server
will send back the requested resource with a 200 HTTP status code, only
if it doesn't have an ETag matching the given one. | |
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 Traffic Vector Flow Tiles API endpoint, for a single request, returns a binary response body which must be deserialized by client code generated by the Google Protocol Buffers compiler. The following examples use a simple textual representation of the serialized binary vector tile data to illustrate the response content.
Absolute Flow Type
https://api.tomtom.com/map/4/tile/flow/absolute/17/64989/42178.pbf?key={Your_API_Key}
1layer: 02 name: Traffic flow3 version: 24 extent: 40965 keys:6 0: road_type7 1: traffic_level8 2: traffic_road_coverage9 3: left_hand_traffic10 values:11 0: "Major local road" [string]12 1: 0 [double]13 2: "one_side" [string]14 3: 1 [bool]15 4: "Major road" [string]16 5: 45 [double]17 6: 1 [bool]18 7: 50 [double]19 8: 1 [bool]20 feature: 021 id: (none)22 geomtype: linestring23 geometry:24 LINESTRING[count=3](3002 -409,2964 1292,2842 2382)25 LINESTRING[count=3](2842 2382,2964 1292,3002 -409)26 properties:27 road_type="Major local road" [string]28 traffic_level=0 [double]29 traffic_road_coverage="one_side" [string]30 left_hand_traffic=1 [bool]31 feature: 132 id: (none)33 geomtype: linestring34 geometry:35 LINESTRING[count=7](4222 4505,4122 4366,3528 3882,3062 3494,2826 2932,2806 2752,2842 2382)36 LINESTRING[count=8](-409 656,-108 810,1260 1620,1832 1914,2842 2382,3792 2644,4400 2770,4505 2783)37 properties:38 road_type="Major road" [string]39 traffic_level=45 [double]40 traffic_road_coverage="one_side" [string]41 left_hand_traffic=1 [bool]42 feature: 243 id: (none)44 geomtype: linestring45 geometry:46 LINESTRING[count=7](2842 2382,2806 2752,2826 2932,3062 3494,3528 3882,4122 4366,4222 4505)47 LINESTRING[count=10](4505 2766,4418 2752,3882 2660,3406 2552,2920 2430,2700 2308,2276 2114,1952 1958,940 1430,-409 648)48 properties:49 road_type="Major road" [string]50 traffic_level=50 [double]51 traffic_road_coverage="one_side" [string]52 left_hand_traffic=1 [bool]
Relative Flow Type
https://api.tomtom.com/map/4/tile/flow/relative/17/64989/42178.pbf?key={Your_API_Key}
1layer: 02 name: Traffic flow3 version: 24 extent: 40965 keys:6 0: road_type7 1: traffic_level8 2: traffic_road_coverage9 3: left_hand_traffic10 values:11 0: "Major local road" [string]12 1: 0 [double]13 2: "one_side" [string]14 3: 1 [bool]15 4: "Major road" [string]16 5: 0.7 [double]17 6: 1 [bool]18 7: 0.767 [double]19 8: 1 [bool]20 9: 1 [double]21 10: 1 [bool]22 feature: 023 id: (none)24 geomtype: linestring25 geometry:26 LINESTRING[count=3](3002 -409,2964 1292,2842 2382)27 LINESTRING[count=3](2842 2382,2964 1292,3002 -409)28 properties:29 road_type="Major local road" [string]30 traffic_level=0 [double]31 traffic_road_coverage="one_side" [string]32 left_hand_traffic=1 [bool]33 feature: 134 id: (none)35 geomtype: linestring36 geometry:37 LINESTRING[count=8](-409 656,-108 810,1260 1620,1832 1914,2842 2382,3792 2644,4400 2770,4505 2783)38 properties:39 road_type="Major road" [string]40 traffic_level=0.7 [double]41 traffic_road_coverage="one_side" [string]42 left_hand_traffic=1 [bool]43 feature: 244 id: (none)45 geomtype: linestring46 geometry:47 LINESTRING[count=10](4505 2766,4418 2752,3882 2660,3406 2552,2920 2430,2700 2308,2276 2114,1952 1958,940 1430,-409 648)48 properties:49 road_type="Major road" [string]50 traffic_level=0.767 [double]51 traffic_road_coverage="one_side" [string]52 left_hand_traffic=1 [bool]53 feature: 354 id: (none)55 geomtype: linestring56 geometry:57 LINESTRING[count=7](2842 2382,2806 2752,2826 2932,3062 3494,3528 3882,4122 4366,4222 4505)58 LINESTRING[count=7](4222 4505,4122 4366,3528 3882,3062 3494,2826 2932,2806 2752,2842 2382)59 properties:60 road_type="Major local road" [string]61 traffic_level=1 [double]62 traffic_road_coverage="one_side" [string]63 left_hand_traffic=1 [bool]
Relative Delay Flow Type
https://api.tomtom.com/map/4/tile/flow/relative-delay/17/64989/42178.pbf?key={Your_API_Key}
1layer: 02 name: Traffic flow3 version: 24 extent: 40965 keys:6 0: road_type7 1: traffic_level8 2: traffic_road_coverage9 3: left_hand_traffic10 values:11 0: "Major local road" [string]12 1: 0 [double]13 2: "one_side" [string]14 3: 1 [bool]15 4: "Major road" [string]16 5: 0.694 [double]17 6: 1 [bool]18 7: 0.767 [double]19 8: 1 [bool]20 feature: 021 id: (none)22 geomtype: linestring23 geometry:24 LINESTRING[count=3](3002 -409,2964 1292,2842 2382)25 LINESTRING[count=3](2842 2382,2964 1292,3002 -409)26 properties:27 road_type="Major local road" [string]28 traffic_level=0 [double]29 traffic_road_coverage="one_side" [string]30 left_hand_traffic=1 [bool]31 feature: 132 id: (none)33 geomtype: linestring34 geometry:35 LINESTRING[count=8](-409 656,-108 810,1260 1620,1832 1914,2842 2382,3792 2644,4400 2770,4505 2783)36 properties:37 road_type="Major road" [string]38 traffic_level=0.694 [double]39 traffic_road_coverage="one_side" [string]40 left_hand_traffic=1 [bool]41 feature: 242 id: (none)43 geomtype: linestring44 geometry:45 LINESTRING[count=10](4505 2766,4418 2752,3882 2660,3406 2552,2920 2430,2700 2308,2276 2114,1952 1958,940 1430,-409 648)46 properties:47 road_type="Major road" [string]48 traffic_level=0.767 [double]49 traffic_road_coverage="one_side" [string]50 left_hand_traffic=1 [bool]
Error response
The Traffic Vector Flow Tiles API endpoint for an invalid single request returns a response body in JSON format.
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 "error": "Invalid zoom value. Allowed values are <0,22>.",3 "httpStatusCode": 400,4 "detailedError": {5 "code": "INVALID_REQUEST",6 "message": "Invalid zoom value. Allowed values are <0,22>."7 }8}
Response codes
Code | Meaning & possible causes |
---|---|
| OK |
| Bad request:
|
| Forbidden: The supplied API Key is not valid for this request. |
| 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: There is a problem with the TomTom Traffic Vector Flow Tiles API endpoint. |
| Service 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 Vector Flow Tiles 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
| |
Indicates which encodings were applied to the response body. | |
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. | |
Contains an identifier for a specific version of resource. | |
Contains the date after which the response is considered outdated. | |
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. |