The Mapbox web services? APIs allow for programmatic access to Mapbox tools and services. Use these APIs to retrieve information about your account, upload and change resources, and use core Mapbox tools, like geocoding? and directions.
This documentation provides examples of six different techniques for accessing Mapbox web services APIs:
Mapbox Swift/Objective-C libraries:
Each library’s documentation provides information on installing the library and how to use it.
This is REST API documentation: it’s the most technical level of documentation for Mapbox’s web services. If you're looking to use a map in an application, you probably want to use a library like Mapbox GL JS or Mapbox Mobile instead. The APIs described in this document are subject to Mapbox's Terms of Service.
This documentation is structured by API, which is a group of related functionality like Geocoding or Uploads, and then by endpoint, which is a specific method within that API that performs one action and is located at a specific URL.
Each endpoint in this documentation is described using several parts:
/geocoding/v5/{mode}/{query}.json{mode} in this example.All URLs referenced in the documentation have the base path https://api.mapbox.com.
This base path goes before the endpoint path. In this example, you'd
combine https://api.mapbox.com and /geocoding/v5/{mode}/{query}.json to get
the request URL https://api.mapbox.com/geocoding/v5/{mode}/{query}.json.
For this endpoint, {mode} and {query} are the URL parameters. In a request,
you replace their placeholders with real values: for instance, you'd choose
mapbox.places as your mode and Chester as your query, and get the URL
https://api.mapbox.com/geocoding/v5/mapbox.places/Chester.json
Query parameters are added to the end of the URL with query string encoding.
If you wanted to add the country query parameter to that Geocoding? request, you'd
the query string ?country=us to the end of the URL, producing
https://api.mapbox.com/geocoding/v5/mapbox.places/Chester.json?country=us.
All endpoints require an access token?, which is provided as a query parameter.
So the final geocoding request you would construct would look like
https://api.mapbox.com/geocoding/v5/mapbox.places/Chester.json?country=us&access_token=pk.my-token-value
The next section covers how you get and use access tokens.
https://api.mapbox.com
Access to Mapbox web services? requires an access token that connects API
requests to your account. The example requests in this documentation don't include
an access token?: you will need to supply one using the access_token query
option or by specifying the token in the SDK or library.
Your default access token is available on the right side of your Mapbox Studio home page. You can also manage and create additional tokens on your API access tokens page in Mapbox Studio? or with the Tokens API.
When creating a new access token, you have the option of adding one or more scopes. Each scope adds a different permission to the token, allowing it to be used to access restricted APIs. Throughout the documentation, we specify the scope required to access each endpoint.
https://api.mapbox.com/{endpoint}?access_token=
Each Mapbox API is versioned with a version string specified in the base URL that can be incremented independently from other APIs.
The Maps API is an exception: its endpoint is prefixed
with /v4/{map_id} instead of putting the version after the API name.
This mismatch will be fixed in the next API version.
Using the newest available API is always encouraged.
These changes are considered backwards compatible and will not require the version string to be incremented:
These changes are considered backwards incompatible and will require the version string to be incremented:
In the event that certain functionality is deprecated, we will give at least 90 days notice via email. You will only receive a deprecation email if we detect you are using part of the API that is being deprecated.
https://api.mapbox.com/{api}/{version}
Mapbox APIs have rate limits that cap the number of requests
that can be made against an endpoint. If you exceed a rate limit, your
request will be throttled and you will receive HTTP 429 Too Many Requests
responses from the API.
| Header | Description |
|---|---|
X-Rate-Limit-Interval |
Length of rate-limiting interval in seconds. |
X-Rate-Limit-Limit |
Maximum number of requests you may make in the current interval before reaching the limit. |
X-Rate-Limit-Reset |
Unix timestamp of when the current interval will end and the ratelimit counter is reset. |
Mapbox web services? support Cross-Origin Requests with no domain restrictions. To support Internet Explorer 8 and 9, use a library that falls back to XDomainRequest, like corslite.
Mapbox supports Retina image output on all APIs that serve images.
Add @2x before the file extension on a URL to request an image at
double scale. For instance, a map tile that is 256×256 pixels will be
512×512 pixels with @2x, but show the same content. When displayed
on a page, the image will be still sized to 256×256 pixels, but
4 pixels of the original will represent 1 pixel in screen units.
The @2x part of the URL goes before the entire format, so a URL
that ends in .png would end with @2x.png as a Retina image.
The only assets that are not available at Retina scale are tilesets uploaded from TileMill? or as MBTiles?.
# a 400x200 static map https://api.mapbox.com/v4/mapbox.dark/-76.9,38.9,5/400x200.png?access_token= # the same static map for Retina # displays: this image will be 800x400 # pixels, but show the same content # and look the same when scaled down https://api.mapbox.com/v4/mapbox.dark/-76.9,38.9,5/[email protected]?access_token=
We recommend all access to Mapbox is over HTTPS. Except for the Maps API, requests initiated over HTTP are automatically upgraded to HTTPS.
Pagination lets you list many objects from an API by using more than one
request. After receiving a page of objects, the next page can be requested using
the next link relation in Link header
of the response. This process can be repeated until the server sends a response
without a Link header or without a next link relation, which signals the end
of the collection.
Your application must use the Link header for pagination instead of
constructing your own URLs as the specific URLs used for pagination may change
at any time. The
Python requests library,
and the
link-header-parser module for JavaScript
can parse Link headers. Link headers follow the RFC 5988 specifications.
Pagination is supported on the Datasets, Uploads, Styles, Tilesets, and Tokens list endpoints.
| Query Parameter | Description |
|---|---|
limit |
The
maximum
number of objects to return. The API will attempt to return the requested number of objects, but receiving fewer objects does not necessarily signal the end of the collection. Receiving a response with no
Link
header or no
next
link relation is the only way to determine when you are at the end of a collection. |
Link: <https://api.mapbox.com/uploads/v1/1454024795582?start=cijywvxlm004rtikohhqf99jv&limit=100>; rel="next"
Most dates and times returned by the API are represented in RFC 3339 format, which can be parsed by the JavaScript Date constructor, the Python arrow library, and many other libraries and languages.
The only exception to this rule is the Retrieve TileJSON metadata
endpoint that returns created and modified properties as Unix time.
Where geographic coordinates are provided to a Mapbox API, they should be formatted
in the order longitude, latitude and specified as decimal degrees in the WGS84
coordinate system. This pattern matches existing standards, including GeoJSON? and KML?.
Mapbox APIs use GeoJSON formatting wherever possible to represent geospatial data. The Directions, Map Matching, Geocoding, and Datasets APIs all return GeoJSON-formatted responses, and the Upload and Map Matching APIs accept GeoJSON input.
The only exception to longitude, latitude ordering is the polyline format, supported
in Static (Classic) overlays and Directions responses. When polyline input
or output is specified, the polyline content should follow the Google Encoded Polyline format,
which specifies latitude, longitude ordering.
The Mapbox Swift libraries use the Core Location framework’s
CLLocationCoordinate2D
type to represent geographic coordinates. When initializing a
CLLocationCoordinate2D, always specify the latitude before the longitude.
The Mapbox Maps API supports reading raster tilesets, vector tilesets, and Mapbox Editor? project features. Tilesets can be retrieved as images, TileJSON, or HTML slippy maps for embedding. Mapbox Editor project features can be retrieved as GeoJSON? or KML?.
If you use Mapbox.js, Mapbox GL JS, or another library like Leaflet, you're already using this API. This documentation is geared toward software developers who want to programmatically read these resources: it isn't necessary to read or understand this reference to design or use maps.
Mapbox classic map IDs
The following map IDs are accessible to all accounts using a valid access token?:
Returns a image tile, vector tile, or UTFGrid in the specified format.
| URL Parameter | Description |
|---|---|
map_id |
unique identifier for the tileset in format
username.id |
format |
return format;
.grid.json
for UTFGrid,
.mvt
for vector tile, or an image extension listed below |
The {z}/{x}/{y} parameters are the tile coordinates as described
in the Slippy Map Tilenames
specification: they specify the tile's zoom level {z} and column {x} and row {y}.
The format of any image request can be replaced by any of the following formats
to adjust image quality for different bandwidth requirements. Higher-compression
formats like jpg70 or png32 can be useful to favor performance
over image quality.
| Image format | Description |
|---|---|
png |
true color PNG |
png32 |
32 color indexed PNG |
png64 |
64 color indexed PNG |
png128 |
128 color indexed PNG |
png256 |
256 color indexed PNG |
jpg70 |
70% quality JPG |
jpg80 |
80% quality JPG |
jpg90 |
90% quality JPG |
You can prefix the format with @2x to request a high DPI version. The @2x
is placed after the {z}/{x}/{y} and before the ., like
1/0/[email protected]
Tiles that include mapbox.satellite are always delivered as JPEG, even if the URL specifies PNG. The PNG
format can't efficiently encode photographic images like mapbox.satellite.
The response is an image tile in the specified format. For performance,
image tiles are delivered with a max-age header value set 12 hours in the future.
Style-optimized vector tiles
Vector tiles? can be further optimized by including a style ID with the tile request. If the style parameter is provided, we analyze the sources, filters, minzoom, and maxzoom properties of that style? and remove data from the vector tile that won't be visible on the map.
A style-optimized tile request requires a style parameter in the request. This style parameter is broken into two parts, the style ID and the style's recently edited timestamp. The timestamp parameter comes from the style JSON's modified property that is included with any style created with Mapbox Studio?.
Mapbox GL JS? can request style-optimized vector tiles that are hosted on Mapbox with a Mapbox Style JSON.
Optimized tiles remove unused layers and features. If you plan on dynamically modifying the style at runtime using Mapbox GL JS or Mapbox Mobile, broadening filters and zoom ranges won't work the same, since any data that isn't visible with the loaded style also won't be included in the data.
$ curl "https://api.mapbox.com/v4/mapbox.streets/1/0/0.png?access_token="
# a 2x tile: this is a 512x512 tile appropriate
# for high-density displays like Retina displays
$ curl "https://api.mapbox.com/v4/mapbox.streets/1/0/[email protected]?access_token="
# a tile with 70% quality jpg encoding
$ curl "https://api.mapbox.com/v4/mapbox.satellite/3/2/3.jpg70?access_token="
# a tile with 32 color indexed PNG
$ curl "https://api.mapbox.com/v4/mapbox.streets/3/2/3.png32?access_token="
# this requests a UTFGrid useful for interactivity
$ curl "https://api.mapbox.com/v4/my.tileset/1/0/0.grid.json?access_token="
# a style-optimized tile with "?style" in the query
$ curl "https://api.mapbox.com/v4/mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7/12/1171/1566.mvt?style=mapbox://styles/mapbox/streets-v10@00&access_token="
Returns an HTML slippy map for sharing or embedding.
| URL Parameter | Description |
|---|---|
options
(optional) |
a comma-separated list of controls and map behaviors to be included in the map |
hash
(optional) |
a zoom level and location for the map in format
#{zoom}/{lat}/{lon} |
| Query Parameter | Description |
|---|---|
zoomwheel |
enable zooming with the mouse wheel |
zoompan |
enable zoom and pan controls |
geocoder |
add a geocoder control |
share |
add a share control |
The response is HTML of a slippy map.
# a map with zoom controls, mouse controls, a geocoder, and share
$ curl "https://api.mapbox.com/v4/mapbox.light/zoomwheel,zoompan,geocoder,share.html?access_token="
# the same map without any options
$ curl "https://api.mapbox.com/v4/mapbox.light.html?access_token="
Retrieve vector features from Mapbox Editor? projects as GeoJSON? or KML?. GeoJSON
returns a FeatureCollection with features that conform to
the simplestyle-spec.
| URL Parameter | Description |
|---|---|
format |
json
for GeoJSON,
kml
for KML |
$ curl "https://api.mapbox.com/v4/mapbox.dc-markers/features.json?access_token="
# or the same dataset as KML
$ curl "https://api.mapbox.com/v4/mapbox.dc-markers/features.kml?access_token="
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"id": "{marker_id}",
"title": "{title}",
"description": "{description}",
"marker-size": "{simplestyle size}",
"marker-color": "{simplestyle color}",
"marker-symbol": "{maki symbol}"
},
"geometry": {
"coordinates": [ -77.031952, 38.913184 ],
"type": "Point"
},
"id": "{feature_id}"
}
]
}
Retrieve data about specific vector features at a specified location within a vector tileset?. The response body is a GeoJSON? FeatureCollection of features at or near the geographic point described by {lon},{lat} and within the distance described by the radius parameter. The geometry of the feature is not returned.
| Query Parameter | Description |
|---|---|
radius
(optional) |
Approximate distance in meters to query for features. Defaults to
0
. |
limit
(optional) |
Number of features between 1-50 to return. Defaults to
5
. |
The radius parameter has no upper bound and is required for queries against point and line data. Due to the nature of tile buffering, a query with a large radius made against equally large point or line data may not include all possible features in the results.
Restrictions and limits
Use of this endpoint is rate limited to 300 requests per minute. For a higher rate limit, contact us.
Exceeding the limits above will result in an HTTP 429 response. For information on rate limit headers, see Rate limits.
The original geometry of the result features will not be returned in the resultset. The geometry type in the response will be Point for all features returned in the FeatureCollection:
Polygon and MultiPolygon features the geometry is the point at the queried lon,latLineString and MultiLineString features the geometry is the nearest point on the feature within the radius threshold of lon,latPoint and MultiPoint features the geometry is the nearest point within the radius threshold of lon,latFeatures in the response body will include a tilequery object with the following additional properties:
| Property | Description |
|---|---|
distance |
Approximate distance in meters from the feature result to the queried point. |
layer |
The vector tile layer of the feature result. |
$ curl "https://api.mapbox.com/v4/mapbox.mapbox-terrain-v2/tilequery/-122.42901,37.80633.json?radius=10&access_token="
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-122.42901,
37.80633
]
},
"properties": {
"ele": -10,
"index": -1,
"tilequery": {
"distance": 0,
"layer": "contour"
}
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-122.42901,
37.80633
]
},
"properties": {
"ele": 0,
"index": -1,
"tilequery": {
"distance": 0,
"layer": "contour"
}
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-122.42901,
37.80633
]
},
"properties": {
"ele": 10,
"index": 1,
"tilequery": {
"distance": 0,
"layer": "contour"
}
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-122.42901,
37.80633
]
},
"properties": {
"ele": 20,
"index": 2,
"tilequery": {
"distance": 0,
"layer": "contour"
}
}
}
]
}
Returns TileJSON metadata for a tileset?. This is an object that describes a map's resources, like tiles, markers, and UTFGrid, as well as its name, description, and centerpoint.
| Query Parameter | Description |
|---|---|
?secure
(optional) |
request resources in the response as HTTPS endpoints |
$ curl "https://api.mapbox.com/v4/mapbox.emerald.json?access_token="
# the same request with HTTPS endpoints
$ curl "https://api.mapbox.com/v4/mapbox.emerald.json?secure&access_token="
{
"attribution": "<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">© Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">© OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://www.mapbox.com/map-feedback/\" target=\"_blank\">Improve this map</a> <a href=\"https://www.digitalglobe.com/\" target=\"_blank\">© DigitalGlobe</a>",
"autoscale": true,
"bounds": [-180, -85, 180, 85],
"cacheControl": "max-age=43200,s-maxage=604800",
"center": [0, 0, 3],
"created": 1358310600000,
"description": "",
"id": "mapbox.satellite",
"maxzoom": 19,
"minzoom": 0,
"modified": 1446150592060,
"name": "Mapbox Satellite",
"private": false,
"scheme": "xyz",
"tilejson": "2.0.0",
"tiles": [
"http://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png",
"http://b.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png"
],
"webpage": "http://a.tiles.mapbox.com/v4/mapbox.satellite/page.html"
}
Request a single marker? image without any background map.
| URL Parameter | Description |
|---|---|
name |
Marker shape and size. Options are
pin-s
,
pin-m
,
pin-l
. |
label
(optional) |
A
Maki v0.5.0
icon
value. |
color
(optional) |
A 3- or 6-digit hexadecimal color code. Default is gray. |
@2x
(optional) |
Include to request a high DPI version of the image. |
curl "https://api.mapbox.com/v4/marker/[email protected]?access_token="
# a default gray marker
curl "https://api.mapbox.com/v4/marker/pin-m.png?access_token="
# a medium blue marker labeled A
curl "https://api.mapbox.com/v4/marker/pin-m-1+00f.png?access_token="
The Mapbox Styles API lets you read and change map styles, fonts, and icons. This API is the basis for Mapbox Studio, our cartography software.
If you use Studio, Mapbox GL JS or the Mapbox Mobile SDKs, you're already using the Styles API. This documentation is geared toward software developers who want to programmatically read & write these resources: it isn't necessary to read or understand this reference to design or use maps.
You'll want to be familiar with the Mapbox Style Specification to use this API: it defines the structure of map styles and is the open standard that helps Studio communicate with APIs and produce maps compatible with our libraries (like GL JS and Mobile). When we refer to style objects, they are objects that fit the Mapbox Style Specification. You can see examples of these styles in our mapbox-gl-styles project, or you can create a new style? using Mapbox Studio.
Limits
Mapbox styles
The following styles are available to all accounts using a valid access token?:
mapbox://styles/mapbox/streets-v10mapbox://styles/mapbox/outdoors-v10mapbox://styles/mapbox/light-v9mapbox://styles/mapbox/dark-v9mapbox://styles/mapbox/satellite-v9mapbox://styles/mapbox/satellite-streets-v10mapbox://styles/mapbox/traffic-day-v2mapbox://styles/mapbox/traffic-night-v2Traffic styles feature coverage in geographies we support.
The style object conforms to the Mapbox Style Specification, with these additional account-related properties:
| Property | Description |
|---|---|
metadata |
information about the style that is used in Mapbox Studio |
created |
date and time the style was created |
id |
id of the style |
modified |
date and time the style was last modified |
owner |
the username of the style owner |
draft |
whether the style is draft or published |
{
"version": 8,
"name": "{name}",
"metadata": "{metadata}",
"sources": {},
"sprite": "mapbox://sprites/{username}/{style_id}",
"glyphs": "mapbox://fonts/{username}/{fontstack}/{range}.pbf",
"layers": ["{layers}"],
"created": "2015-10-30T22:18:31.111Z",
"id": "{style_id}",
"modified": "2015-10-30T22:22:06.077Z",
"owner": "{username}",
"draft": true
}
Retrieve a style? as a JSON document. The returned style object will be in the Mapbox Style format.
curl "https://api.mapbox.com/styles/v1/{username}/{style_id}?access_token="
{
"version": 8,
"name": "My Awesome Style",
"metadata": { },
"sources": {
"myvectorsource": {
"url": "mapbox://{map_id}",
"type": "vector"
},
"myrastersource": {
"url": "mapbox://{map_id}",
"type": "raster"
}
},
"sprite": "mapbox://sprites/{username}/{style_id}",
"glyphs": "mapbox://fonts/{username}/{fontstack}/{range}.pbf",
"layers": [ ],
"created": "2015-10-30T22:18:31.111Z",
"id": "{style_id}",
"modified": "2015-10-30T22:22:06.077Z",
"owner": "{username}",
"draft": true
}
Retrieve a list of styles for an account. This endpoint does not return full styles, but returns style? metadata.
curl "https://api.mapbox.com/styles/v1/{username}?access_token="
[
{
"version": 8,
"name": "My Awesome Style",
"created": "{timestamp}",
"id": "cige81msw000acnm7tvsnxcp5",
"modified": "{timestamp}",
"owner": "{username}"
},
{
"version": 8,
"name": "My Cool Style",
"created": "{timestamp}",
"id": "cig9rvfe300009lj9kekr0tm2",
"modified": "{timestamp}",
"owner": "{username}"
}
]
Creates a style? in your account. The posted style object must be both valid JSON and aligned to the Mapbox Style Specification: invalid styles will produce a descriptive validation error.
Only the most recent version of the Mapbox Style Specification is supported. If the optional "name" property is omitted, it will be automatically set to the style's ID.
The style you get back from the API will have new properties that the server
has added: created, id, modified, owner, and draft.
# assuming that you have a valid style named basic-v9.json
curl -X POST "https://api.mapbox.com/styles/v1/{username}?access_token=" \
--data @basic-v9.json \
--header "Content-Type:application/json"
{
"version": 8,
"name": "My Awesome Style",
"metadata": { },
"sources": {
"myvectorsource": {
"url": "mapbox://{map_id}",
"type": "vector"
},
"myrastersource": {
"url": "mapbox://{map_id}",
"type": "raster"
}
},
"glyphs": "mapbox://fonts/{username}/{fontstack}/{range}.pbf",
"layers": [ ]
}
{
"version": 8,
"name": "My Awesome Style",
"metadata": { },
"sources": {
"myvectorsource": {
"url": "mapbox://{map_id}",
"type": "vector"
},
"myrastersource": {
"url": "mapbox://{map_id}",
"type": "raster"
}
},
"sprite": "mapbox://sprites/{username}/{style_id}",
"glyphs": "mapbox://fonts/{username}/{fontstack}/{range}.pbf",
"layers": [ ],
"created": "2015-10-30T22:18:31.111Z",
"id": "{style_id}",
"modified": "2015-10-30T22:22:06.077Z",
"owner": "{username}",
"draft": true
}
Updates an existing style? in your account with new content.
Requesting a style and then using the same content to update the style will
fail: you'll need to remove the created and modified properties before
updating a style. The name property, which is optional for style creation,
is required when updating a style. Cross-version PATCH requests are rejected.
curl -X PATCH "https://api.mapbox.com/styles/v1/{username}/{style_id}" \
--data @basic-v9.json \
--header "Content-Type:application/json"
{
"version": 8,
"name": "New Style Name",
"metadata": { },
"sources": { },
"sprite": "mapbox://sprites/{username}/{style_id}",
"glyphs": "mapbox://fonts/{username}/{fontstack}/{range}.pbf",
"layers": [{
"id": "new-layer",
"type": "background",
"paint": {
"background-color": "#111"
},
"interactive": true
}],
"owner": "{username}",
"draft": true
}
{
"version": 8,
"name": "New Style Name",
"metadata": { },
"sources": { },
"sprite": "mapbox://sprites/{username}/{style_id}",
"glyphs": "mapbox://fonts/{username}/{fontstack}/{range}.pbf",
"layers": [{
"id": "new-layer",
"type": "background",
"paint": {
"background-color": "#111"
},
"interactive": true
}],
"created": "2015-10-30T22:18:31.111Z",
"id": "{style_id}",
"modified": "2015-10-30T22:22:06.077Z",
"owner": "{username}",
"draft": true
}
Deletes a style?. All sprites that belong to this style will also be deleted and the style will no longer be available.
curl -X DELETE "https://api.mapbox.com/styles/v1/{username}/{style_id}?access_token="
HTTP 204
Two types of fonts are supported: TrueType fonts, usually with
.ttf file extensions, and OpenType fonts, with .otf extensions. The API
accepts fonts as raw binary data, allows those fonts to be deleted,
and generates encoded letters for map renderers.
Fonts are managed on a per-account basis: styles can use any font from the same account.
Font limits
Glyph ranges are usually not of interest unless you're building a map renderer, but this is the endpoint where you can access them.
Font glyph ranges are protocol buffer-encoded signed distance fields. They can be used to show fonts at a variety of scales and rotations. One glyph is used at all scales.
| URL Parameter | Description |
|---|---|
font |
name of the font, can be multiple comma-separated font names |
start |
A multiple of 256 between 0 and 65280 |
end |
start
+ 255 |
curl "https://api.mapbox.com/fonts/v1/{username}/{font},{font}/{start}-{end}.pbf?access_token="
A successful request will return
HTTP 200 Success. The response body will be a buffer of the glyphs withContent-Type: application/x-protobuf.
Sprites are the way
that Mapbox GL JS? and Mapbox Mobile efficiently request and show icons. They are collections of icons that can be used in styles as markers or
patterns in symbol layers. Icons are SVG? images that can be added and removed
at will. The Styles API automatically collects these SVG images and renders
them into a single PNG image and a JSON document that describes where
each icon is positioned.
The sprite? JSON document is specified as part of the the Mapbox Style Specification.
Sprites are managed on a per-style basis: each sprite belongs to a style,
so the sprite limit of 500 icons is also a per-style limit. All sprite-related
API methods will require a {style_id} parameter referring to the style? that sprite belongs to.
Sprite limits
Retrieves a sprite? image or JSON document.
| URL Parameter | Description |
|---|---|
@2x
(optional) |
Render sprite at 2x resolution, appropriate for high-density displays |
format
(optional) |
.png
for the sprite image, or
.json
for the document. Without a format specified, JSON will be returned. |
# requesting retina json
curl "https://api.mapbox.com/styles/v1/{username}/{style_id}/sprite@2x?access_token="
# requesting normal-resolution png
curl "https://api.mapbox.com/styles/v1/{username}/{style_id}/sprite.png?access_token="
{
"default_marker": {
"width": 20,
"height": 50,
"x": 0,
"y": 0,
"pixelRatio": 2
},
"secondary_marker": {
"width": 20,
"height": 50,
"x": 20,
"y": 0,
"pixelRatio": 2
}
}
Adds a new icon to an existing sprite?.
The request body should be raw SVG? data.
curl -X PUT \
"https://api.mapbox.com/styles/v1/{username}/{style_id}/sprite/{icon_name}?access_token=" \
--data @aerialway-12.svg
{
"newsprite": {
"width": 1200,
"height": 600,
"x": 0,
"y": 0,
"pixelRatio": 1
},
"default_marker": {
"width": 20,
"height": 50,
"x": 0,
"y": 600,
"pixelRatio": 1
}
}
Deletes an icon from an existing sprite?.
curl -X DELETE "https://api.mapbox.com/styles/v1/{username}/{style_id}/sprite/{icon_name}?access_token="
{
"default_marker": {
"width": 20,
"height": 50,
"x": 0,
"y": 600,
"pixelRatio": 1
},
"secondary_marker": {
"width": 20,
"height": 50,
"x": 20,
"y": 600,
"pixelRatio": 1
}
}
Request embeddable HTML suitable for fullscreen map displays or for inserting into
blog posts and articles as <iframe> content.
| Query Parameter | Description |
|---|---|
zoomwheel
(optional) |
Disables zooming with mouse scroll wheel (default true) |
title
(optional) |
If
true
, shows a title box in upper right corner with map title and owner (default
false
) |
<iframe
src='https://api.mapbox.com/styles/v1/mapbox/streets-v10.html?title=true&zoomwheel=true' />
The Mapbox Static API returns static maps and raster tiles from styles in the Mapbox Style Specification. See the Static (Classic) API documentation.
Static maps are standalone images that can be displayed on web and mobile devices without the aid of a mapping library or API. They look like an embedded map without interactivity or controls.
Raster tiles can be used in traditional web mapping libraries like Mapbox.js, Leaflet, OpenLayers, and others.
Swift and Objective-C support for the Static API is provided by the MapboxStatic.swift library.
In contrast to the legacy Static API, this API supports pitch, bearing, and decimal zoom levels.
The position of the map is represented by 5 numbers: longitude, latitude,
zoom, bearing, and pitch. The last two numbers, bearing and pitch, are
optional: if you only specify bearing and not pitch, pitch will default to
0. If you specify neither, they will both default to 0.
| URL Parameter | Description |
|---|---|
overlay |
one or more comma-separated features to draw on top of the map. These can be in
marker
,
geojson
or
path
format. |
lon |
longitude for the center point of the static map; number between
-180
and
180 |
lat |
latitude for the center point of the static map; number between
-90
and
90 |
zoom |
zoom level; number between
0
and
22
. Fractional zoom levels will be rounded to two decimal places. |
bearing
(optional) |
bearing: rotates the map around its center. number between
0
and
360
, interpreted as decimal degrees. 90 rotates the map 90° to the left. 180 flips the map. Defaults to
0
. |
pitch
(optional) |
pitch: tilts the map, producing a perspective effect. number between
0
and
60
. Defaults to
0
. |
auto |
If
auto
is added, the viewport will fit the bounds of the overlay. If used,
auto
replaces
lon
and
lat
. |
width |
width of the image; number between
1
and
1280 |
height |
height of the image; number between
1
and
1280 |
@2x
(optional) |
If
@2x
is added to request a retina 2x image will be returned |
| Query Parameter | Description |
|---|---|
attribution
(optional) |
boolean
value controlling whether there is attribution on the image; defaults to
true |
logo
(optional) |
boolean
value controlling whether there is a Mapbox logo on the image; defaults to
true |
before_layer
(optional) |
string
value for controlling where the
overlay
is inserted in the style. All overlays will be inserted before the specified layer. |
The attribution option removes watermarked attribution? from the image,
but not the legal responsibility to attribute maps that use OpenStreetMap? data,
which includes most maps from Mapbox. If you specify attribution=false, you
are legally required to include proper attribution elsewhere on the webpage or document.
Tiles and static images returned from this API will be one zoom level offset from tiles and static images returned from the Static (Classic) API. This is due to the size of the individual tiles being created -- this API creates 512px by 512px tiles and the Static Classic API creates 256px by 256px tiles. The offset was introduced to keep zoom level 0 the lowest zoom (one tile for the whole world).
Example: the tile at zoom level 0 from this API covers 512px by 512px. This is the same pixel area as zoom level 1 in the Static (Classic) API, where there are 4 tiles to fill the same space. The features shown in zoom level 0 of the Static API are matched identically to the features shown in zoom level 1 of the Static (Classic) API.
Overlay
An overlay is data that can be applied on top of the map at request time. These are comma separated and can be a mix of valid GeoJSON, a marker?, a custom marker or path. Overlays cannot consist of more than 100 features. The maximum overlay length is 2083 characters. The order of the features dictates their Z-order on the page. The last item in the list will have the highest Z-order (will overlap the other features in the list), and the first item in the list will have the lowest (will underlap the other features).
Marker
{name}-{label}+{color}({lon},{lat})
| URL Parameter | Description |
|---|---|
name |
Marker shape and size. Options are
pin-s
,
pin-m
,
pin-l
. |
label
(optional) |
Marker symbol. Options are an alphanumeric label
a
through
z
,
0
through
99
, or a valid
Maki
icon. If a letter is requested, it will be rendered uppercase only. |
color
(optional) |
A 3- or 6-digit hexadecimal color code. |
Custom marker
url-{url}({lon},{lat})
| URL Parameter | Description |
|---|---|
url |
a percent-encoded URL for the image. Can be of type
PNG
or
JPG
. |
Custom markers are cached according to the
Expires and Cache-Control headers. Make sure that at least one of these
headers is set to a proper value to prevent repeated requests for the custom
marker image.
The marker image is always centered on the specified location. When creating an asymmetric marker like a pin, make sure that the tip of the pin is at the center of the image.
GeoJSON
geojson({geojson})
The {geojson} argument must be a valid GeoJSON object.
simplestyle-spec styles for
GeoJSON? features will be respected and rendered.
geojson({geojson})
| URL Parameter | Description |
|---|---|
geojson |
a valid GeoJSON object. simplestyle-spec styles for |
GeoJSON features will be respected and rendered.
Path
path-{strokeWidth}+{strokeColor}-{strokeOpacity}+{fillColor}-{fillOpacity}({polyline})
Encoded polylines with a precision of 5 decimal places can
be used with the Static API via the path parameter.
| URL Parameter | Description |
|---|---|
strokeWidth
(optional) |
Positive number for line stroke width |
strokeColor
(optional) |
A 3- or 6-digit hexadecimal color code for the line stroke |
strokeOpacity
(optional) |
A number between
0
(transparent) and
1
(opaque) for line stroke opacity |
fillColor
(optional) |
A 3- or 6-digit hexadecimal color code for the fill |
fillOpacity
(optional) |
A number between
0
(transparent) and
1
(opaque) for fill opacity |
polyline |
A valid encoded polyline encoded as a URI component |
# retrieve a map at -122.4241 longitude, 37.78 latitude,
# zoom 14.24, bearing 0, and pitch 60. The map
# will be 600 pixels wide and 600 pixels high
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/-122.4241,37.78,14.25,0,60/600x600?access_token="
# retrieve a map at 0 longitude, 10 latitude, zoom 3,
# and bearing 20. Pitch will default to 0.
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/0,10,3,20/600x600?access_token="
# retrieve a map at 0 longitude, 0 latitude, zoom 2.
# bearing & pitch default to 0.
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/0,0,2/600x600?access_token="
# retrieve a map with a custom marker overlay
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/url-https%3A%2F%2Fmapbox.com%2Fimg%2Frocket.png(-76.9,38.9)/-76.9,38.9,15/1000x1000?access_token="
# retrieve a map with a geojson overlay
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/geojson(%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B-73.99%2C40.7%5D%7D)/-73.99,40.70,12/500x300?access_token="
# retrieve a map with 2 points and a polyline overlay,
# with it's center point automatically determined with `auto`
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/pin-s-a+9ed4bd(-122.46589,37.77343),pin-s-b+000(-122.42816,37.75965),path-5+f44-0.5(%7DrpeFxbnjVsFwdAvr@cHgFor@jEmAlFmEMwM_FuItCkOi@wc@bg@wBSgM)/auto/500x300?access_token="
Request 256x256 or 512x512 image tiles from a style? that can be arranged and displayed with the help of a mapping library. Normally, you will not need to interact with this API directly, as our SDKs handle this for you.
Mapbox.js? has built-in support for raster tiles from a
style with L.mapbox.styleLayer.
256px vs 512px tiles
By default, the API will return 512x512 pixel image tiles. 512x512 image tiles will be offset by 1 zoom level when compared to traditional 256x256 tiles (for example, 512x512 tiles at zoom level 4 are equivalent to traditional tiles at zoom level 5). Tiles are 512x512 pixels unless the @2x parameter is included, in which case they're scaled to 1024x1024 pixels.
If you are using Leaflet? directly, the following options will need to included in the options
argument to the L.tileLayer constructor:
{ tileSize: 512, zoomOffset: -1 }
# default to 512x512 pixel tiles
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/tiles/1/1/0?access_token="
# specify 256x256 pixel tiles
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/tiles/256/1/1/0?access_token="
# specify 512x512 pixel tiles
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/tiles/512/1/1/0?access_token="
Mapbox supports access via the WMTS standard, which lets you use maps with desktop and online GIS software like ArcMap and QGIS.
curl "https://api.mapbox.com/styles/v1/mapbox/streets-v10/wmts?access_token="
The Mapbox Uploads API transforms geographic data into tilesets that can be used with maps and geographic applications. Given a wide variety of geospatial formats, it normalizes projections and generates tiles at multiple zoom levels to make data viewable on the web.
The upload workflow begins with a file and ends with a tileset?, or if you have invalid data, an error.
Limits
| Type | Size limit |
|---|---|
| TIFF and GeoTIFF | 10 GB |
| MBTiles | 25 GB |
| GeoJSON | 1 GB |
| CSV | 1 GB |
| KML | 260 MB |
| GPX | 260 MB |
| Shapefile (zipped) | 260 MB |
| Mapbox Dataset | 1 GB |
Uploading Mapbox Datasets is only available to users who are part of the Mapbox Dataset? beta.
Mapbox provides an Amazon S3 bucket to stage your file while your upload is processed. Uploads must be staged in this bucket before being uploaded to your Mapbox account. You can retrieve temporary credentials from this endpoint.
The response body is a JSON object containing the following properties.
| Property | Description |
|---|---|
accessKeyId |
AWS Access Key ID |
bucket |
S3 bucket name |
key |
unique key for data to be staged |
secretAccessKey |
AWS Secret Access Key |
sessionToken |
temporary security token |
url |
destination URL of the file |
Use these credentials to store your data in the provided bucket with the provided
key using the AWS CLI or AWS SDK of your choice. The bucket is located in AWS region us-east-1.
curl -X POST "https://api.mapbox.com/uploads/v1/{username}/credentials?access_token="
{
"accessKeyId": "{accessKeyId}",
"bucket": "somebucket",
"key": "hij456",
"secretAccessKey": "{secretAccessKey}",
"sessionToken": "{sessionToken}",
"url": "{url}"
}
Once you've used the temporary S3 credentials to transfer your file to Mapbox's staging bucket, you can trigger the generation of a tileset? given the file's URL and a destination tileset ID.
Uploads can only be use files in Mapbox's provided buckets, they cannot request resources from other S3 buckets or URLs.
The request body is a JSON object containing the following properties.
| Property | Description |
|---|---|
tileset |
the map ID to create or replace in the format
username.nameoftileset |
url |
HTTPS URL of the S3 object provided in the credential request or the Mapbox Dataset identifier. |
name
(optional) |
name for the tileset |
Reuse of a tileset value will replace existing data: use a random value
to make sure that a new tileset is created, or check existing tilesets first.
The response body is a JSON object containing the following properties.
| Property | Description |
|---|---|
complete |
whether the upload is complete (true) or not (false) |
tileset |
The id of the tileset (map) that will be created or replace if upload is successful |
error |
if null, the upload is in progress or successfully completed. Otherwise, a brief explanation of the error |
id |
the unique identifier for the upload |
name |
the name of the upload |
modified |
time when the upload resource was last modified |
created |
time when the upload resource was created |
owner |
the unique identifier for the owner's account |
progress |
the progress of the upload expressed as a float between 0 and 1 |
curl -X POST --header "Content-Type:application/json" "https://api.mapbox.com/uploads/v1/{username}?access_token="
{
"tileset": "{username}.mytileset",
"url": "http://somebucket.s3.amazonaws.com/markers.json",
"name": "example-markers"
}
{
"tileset": "{username}.mytileset",
"url": "mapbox://datasets/{username}/{dataset}",
"name": "example-dataset"
}
{
"complete": false,
"tileset": "example.markers",
"error": null,
"id": "hij456",
"name": "example-markers",
"modified": "{timestamp}",
"created": "{timestamp}",
"owner": "{username}",
"progress": 0
}
Upload processing is fast but not immediate. Once an upload is created, you can
track its status. Uploads have a progress property that will start at 0
and end at 1 when an upload is complete. If there's an error processing
an upload, the error property will include an error message.
curl "https://api.mapbox.com/uploads/v1/{username}/{upload_id}?access_token="
{
"complete": true,
"tileset": "example.markers",
"error": null,
"id": "hij456",
"name": "example-markers",
"modified": "{timestamp}",
"created": "{timestamp}",
"owner": "{username}",
"progress": 1
}
You can retrieve multiple upload statuses at the same time, sorted by the most recently created. This request returns the same information as individual upload status, but for all recent uploads. The list is limited to 1MB of JSON.
This endpoint supports pagination so that you can list
many uploads. Up to 100 items can be requested at a time using the limit
parameter. It also supports another parameter, reverse:
| Query Parameter | Description |
|---|---|
reverse |
List uploads in chronological order, rather than reverse chronological order. |
curl "https://api.mapbox.com/uploads/v1/{username}?access_token="
[{
"complete": true,
"tileset": "example.mbtiles",
"error": null,
"id": "abc123",
"name": null,
"modified": "2014-11-21T19:41:10.000Z",
"created": "2014-11-21T19:41:10.000Z",
"owner": "example",
"progress": 1
}, {
"complete": false,
"tileset": "example.foo",
"error": null,
"id": "xyz789",
"name": "foo",
"modified": "2014-11-21T19:41:10.000Z",
"created": "2014-11-21T19:41:10.000Z",
"owner": "example",
"progress": 0
}]
Remove a completed upload status from the upload listing.
Uploads are only statuses: removing an upload from the listing doesn't delete the associated tileset?. Tilesets can only be deleted from within Mapbox Studio?. An upload cannot be removed until it is completed.
$ curl -X DELETE "https://api.mapbox.com/uploads/v1/{username}/{upload_id}?access_token="
HTTP 204
A dataset is an editable collection of GeoJSON features. The Datasets API offers persistent storage for custom geographic data and supports reading, creating, updating, and removing features. The goal of this API is to let you manage your geodata using Mapbox. To serve this data at scale, convert your dataset? into a tileset? using the Uploads API.
Using the Datasets API involves interacting with two types of resources: datasets and features. Datasets contain a collection of features.
A dataset contains information about the dataset?. Each dataset contains the following properties:
| Property | Description |
|---|---|
owner |
the username of the dataset owner |
id |
id for an existing dataset |
created |
date and time the dataset was created |
modified |
date and time the dataset was last modified |
bounds |
the extent of features in the dataset as an array of west, south, east, north coordinates |
features |
the number of features in the dataset |
size |
the size of the dataset in bytes |
name
(optional) |
the name of the dataset |
description
(optional) |
the description of the dataset |
{
"owner": "{username}",
"id": "{dataset_id}",
"created": "{timestamp}",
"modified": "{timestamp}",
"bounds": [-10, -10, 10, 10],
"features": 100,
"size": 409600,
"name": "{name}",
"description": "{description}"
}
A feature is a GeoJSON? Feature object representing a feature in the dataset?. GeometryCollections and null geometries are not supported.
For a full list of GeoJSON Feature properties, see the GeoJSON specification.
Limits
{
"id": "{feature_id}",
"type": "Feature",
"properties": {
"prop0": "value0"
},
"geometry": {
"coordinates": [ 102,0.5 ],
"type": "Point"
}
}
Lists all datasets for a particular account.
$ curl "https://api.mapbox.com/datasets/v1/{username}?access_token="
[
{
"owner": "{username}",
"id": "{dataset_id}",
"created": "{timestamp}",
"modified": "{timestamp}",
"bounds": [-10, -10, 10, 10],
"features": 100,
"size": 409600,
"name": "{name}",
"description": "{description}"
},
{
"owner": "{username}",
"id": "{dataset_id}",
"created": "{timestamp}",
"modified": "{timestamp}",
"bounds": [-10, -10, 10, 10],
"features": 100,
"size": 409600,
"name": "{name}",
"description": "{description}"
}
]
Creates a new, empty dataset?.
curl -X POST "https://api.mapbox.com/datasets/v1/{username}?access_token="
{
"name": "foo",
"description": "bar"
}
{
"owner": "{username}",
"id": "{dataset_id}",
"created": "{timestamp}",
"modified": "{timestamp}",
"bounds": [-10, -10, 10, 10],
"features": 100,
"size": 409600,
"name": "foo",
"description": "bar"
}
curl "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}?access_token="
{
"owner": "{username}",
"id": "{dataset_id}",
"created": "{timestamp}",
"modified": "{timestamp}",
"bounds": [-10, -10, 10, 10],
"features": 100,
"size": 409600,
"name": "{name}",
"description": "{description}"
}
Updates the properties of a particular dataset?.
curl --request PATCH "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}?access_token=" \
-d @data.json
{
"name": "foo",
"description": "bar"
}
{
"owner": "{username}",
"id": "{dataset_id}",
"created": "{timestamp}",
"modified": "{timestamp}",
"bounds": [-10, -10, 10, 10],
"features": 100,
"size": 409600,
"name": "foo",
"description": "bar"
}
Deletes a dataset?, including all features it contains.
curl -X DELETE "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}?access_token="
HTTP 204
List features in a dataset?. The response body will be a GeoJSON? FeatureCollection.
This endpoint supports pagination so that you can list many features.
curl "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}/features?access_token="
# using pagination to only list 10 features
curl "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}/features?limit=10&access_token="
# using pagination to start the listing after feature with the id f6d9
curl "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}/features?start=f6d9&access_token="
{
"type": "FeatureCollection",
"features": [
{
"id": "{feature_id}",
"type": "Feature",
"properties": {
"prop0": "value0"
},
"geometry": {
"coordinates": [ 102,0.5 ],
"type": "Point"
}
},
{
"id": "{feature_id}",
"type": "Feature",
"properties": {
"prop0": "value0"
},
"geometry": {
"coordinates": [
[ 102, 0 ],
[ 103, 1 ],
[ 104, 0 ],
[ 105, 1 ]
],
"type": "LineString"
}
}
]
}
Inserts or updates a feature in a dataset?. If there's already a feature with the given ID in the dataset, it will be replaced. If there isn't a feature with that ID, a new feature is created.
If you are inserting a feature, you must add the feature as the body of the PUT request. This should be one individual GeoJSON? feature and not a GeoJSON FeatureCollection. If the GeoJSON feature has a top-level id property, it must match the feature_id you use in the URL endpoint.
| Property | Description |
|---|---|
id |
the id of an existing feature in the dataset |
curl "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}/features/{feature_id}?access_token=" \
-X PUT \
-H "Content-Type: application/json" \
-d @file.geojson
{
"id": "{feature_id}",
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ 100, 0 ],
[ 101, 0 ],
[ 101, 1 ],
[ 100, 1 ],
[ 100, 0 ]
]
]
},
"properties": {
"prop0": "value0"
}
}
{
"id": "{feature_id}",
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ 100, 0 ],
[ 101, 0 ],
[ 101, 1 ],
[ 100, 1 ],
[ 100, 0 ]
]
]
},
"properties": {
"prop0": "value0"
}
}
Retrieves a feature in a dataset?.
curl "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}/features/{feature_id}?access_token="
{
"id": "{feature_id}",
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ 100, 0 ],
[ 101, 0 ],
[ 101, 1 ],
[ 100, 1 ],
[ 100, 0 ]
]
]
},
"properties": {
"prop0": "value0"
}
}
Removes a feature from a dataset?.
curl -X DELETE "https://api.mapbox.com/datasets/v1/{username}/{dataset_id}/features/{feature_id}?access_token="
HTTP 204
Each tileset? object contains the following properties:
| Property | Description |
|---|---|
type |
kind of data contained, either
raster
or
vector |
center |
longitude, latitude and zoom level for the center of contained data |
created |
date and time the tileset was created |
description |
human friendly description of the tileset |
filesize |
storage in bytes consumed by the tileset |
id |
machine identifier for the tileset |
modified |
date and time the tileset was last modified |
visibility |
access control for the tileset, either
public
or
private |
status |
processing status of the tileset, one of:
available
,
pending
or
invalid |
{
"type": "vector",
"center": [-0.2680000000000007, 11.7014165, 2],
"created": "2015-09-09T23:30:17.936Z",
"description": "",
"filesize": 17879790,
"id": "mapbox.05bv6e12",
"modified": "2015-09-09T23:30:17.906Z",
"name": "routes.geojson",
"visibility": "public",
"status": "available"
}
Lists all tilesets for an account.
This endpoint supports pagination.
The response may be altered with optional query parameters:
| Query Parameter | Description |
|---|---|
type |
Filter results by tileset type, either
raster
or
vector
. |
visibility |
Filter results visibility, either
public
or
private
. Private tilesets require an access token belonging to the owner, while public tilesets may be requested with an access token belonging to any user. |
sortby |
Sort the listing by
created
or
modified
timestamps. |
limit |
The maximum number of objects to return. An integer between 1 and 500 is expected, defaults to 100. See pagination for details |
$ curl "https://api.mapbox.com/tilesets/v1/{username}?access_token="
[
{
"type": "vector",
"center": [-0.2680000000000007, 11.7014165, 2],
"created": "2015-09-09T23:30:17.936Z",
"description": "",
"filesize": 17879790,
"id": "mapbox.05bv6e12",
"modified": "2015-09-09T23:30:17.906Z",
"name": "routes.geojson",
"visibility": "public",
"status": "available"
},
{
"type": "vector",
"center": [-122.43612326651723, 37.75953636431886, 12],
"created": "2016-01-07T19:12:56.530Z",
"description": "",
"filesize": 3271136,
"id": "mapbox.0z6e1qup",
"modified": "2016-01-30T02:13:00.093Z",
"name": "Zoning_Districts",
"visibility": "private",
"status": "available"
},
{
"type": "raster",
"center": [-110.32479628173822, 44.56501277250615, 8],
"created": "2016-12-10T01:29:37.682Z",
"description": "",
"filesize": 794079,
"id": "mapbox.4umcnx2j",
"modified": "2016-12-10T01:29:37.289Z",
"name": "sample-4czm7e",
"visibility": "private",
"status": "available"
}
]
The Mapbox Geocoding? API does two things: forward geocoding and reverse geocoding.
Forward geocoding lets you convert location text into geographic
coordinates, turning 2 Lincoln Memorial Circle NW into -77.050,38.889.
Reverse geocoding turns geographic coordinates into place names,
turning -77.050, 38.889 into 2 Lincoln Memorial Circle NW. These place names
can vary from specific addresses to states and countries that contain
the given coordinates.
Swift and Objective-C support for Geocoding is provided by the MapboxGeocoder.swift library.
Restrictions and limits
Use of the geocoding API is rate-limited by access token?. These limits vary by plan.
| Account level | Rate limit |
|---|---|
| Starter | 600 requests per minute |
| Premium | 600 requests per minute |
| Enterprise | 2,400 requests per minute |
Exceeding the limits above will result in an HTTP 429 response. For information on rate limit headers, see Rate limits.
Batch geocoding is only available with an Enterprise plan. On all other plan levels, one geocode is permitted per request.
The results from geocoding with the mapbox.places mode must
be displayed on a Mapbox map and cannot be stored permanently. The mapbox.places-permanent mode, available with an Enterprise plan,
does not have these licensing restrictions.
The Mapbox Geocoding API coverage map lists the types of geocoding results supported in each area of the world.
Queries are limited to either a total of 20 words and numbers separated by spacing and punctuation or 256 characters.
If you use the optional bounding box? parameter to filter? results, note that the bounding box cannot cross the 180th meridian.
Both geocoding? and reverse geocoding requests have the same basic format. Since
the {query} parameter can contain any value, it should be URL-encoded UTF-8.
| URL Parameter | Description |
|---|---|
query |
a location; a place name for forward geocoding or a coordinate pair (longitude, latitude) for reverse geocoding |
mode |
mapbox.places
for ephemeral geocoding or
mapbox.places-permanent
for storing results and batch geocoding |
| Query Parameter | Description |
|---|---|
country
(optional) |
Limit results to one or more countries. Options are ISO 3166 alpha 2 country codes separated by commas. |
proximity
(optional) |
Bias local results based on a provided location. Options are
longitude,latitude
coordinates. |
types
(optional) |
Filter results by one or more feature types. Options are
country
,
region
,
postcode
,
district
,
place
,
locality
,
neighborhood
,
address
,
poi
, and
poi.landmark
. Note that
poi.landmark
returns a subset of the results returned by
poi
. Multiple options can be comma-separated. |
autocomplete
(optional) |
Return autocomplete results or not. Options are
true
or
false
and the default is
true
. |
bbox
(optional) |
Limit results to a bounding box. Options are in the format
minX,minY,maxX,maxY
. |
limit
(optional) |
Limit the number of results returned. The default is
5
for forward geocoding and
1
for reverse geocoding. |
language
(optional) |
Specify the language to use for response text and, for forward geocoding, query result weighting. Options are IETF language tags comprised of a mandatory ISO 639-1 language code and optionally one or more IETF subtags for country or script. More than one value can also be specified, separated by commas. |
The {proximity} parameter biases search results within 5 miles of a specific
location given in {longitude},{latitude} coordinates. Results will not be
filtered by location or ordered by distance, but location will be considered
along with textual relevance and other criteria when scoring and sorting
results.
The {autocomplete} parameter controls whether autocomplete results
are included. Autocomplete results can partially match the query: for example,
searching for washingto could include washington even though only
the prefix matches. Autocomplete is useful for offering fast, type-ahead
results in user interfaces. If your queries represent complete addresses or
place names, you can disable this behavior and exclude partial matches by
setting the {autocomplete} parameter to false.
The {limit} parameter specifies the maximum number of results to
return. For forward geocoding, the default is 5 and the maximum is
10. For reverse geocoding, the default is 1 and the maximum is 5.
If a limit other than 1 is used for reverse geocoding, a single types
option must also be specified.
The {language} parameter specifies the desired response language for user
queries. For forward geocodes, results that match the requested language are
favored over results in other languages. If more than one language tag is
supplied, text in all requested languages will be returned. For forward
geocodes with more than one language tag, only the first language will be used
to weight results.
Any valid IETF language tag can be submitted, and a best effort will be made to
return results in the requested language or languages, falling back first to
similar and then to common languages in the event that text is not available in
the requested language. In the event a fallback language is used, the language
field will have a different value than the one requested.
Translation availability varies by language and region:
Global coverage: these languages are almost always present for country, region, and prominent place features
| Language | ||
|---|---|---|
de
German |
en
English |
fr
French |
it
Italian |
nl
Dutch |
Local coverage: these languages may lack global coverage but are almost always present for country, region, and prominent place features where they are widely used
| Language | ||
|---|---|---|
bs
Bosnian |
bg
Bulgarian |
ca
Catalan |
cs
Czech |
da
Danish |
el
Greek |
et
Estonian |
fi
Finnish |
ka
Georgian |
he
Hebrew |
hu
Hungarian |
is
Icelandic |
ja
Japanese |
ko
Korean |
lt
Lithuanian |
lv
Latvian |
mn
Mongolian |
nb
Norwegian Bokmål |
pl
Polish |
pt
Portuguese |
ro
Moldovan |
ru
Russian |
sk
Slovak |
sl
Slovenian |
sr
Serbian |
sv
Swedish |
tl
Tagalog |
th
Thai |
uk
Ukrainian |
zh_Hans
Simplified Chinese |
zh_Hant
Traditional Chinese |
Limited coverage: these languages are sometimes present but coverage tends to be inconsistent or geographically constrained
| Language | ||
|---|---|---|
ar
Arabic |
es
Spanish |
fa
Persian, |
kk
Kazakh |
ms
Malay |
sq
Albanian, |
tr
Turkish |
uz
Uzbek |
vi
Vietnamese |
Because Mapbox's geocoding? data is constantly updated and improved, the values of properties in the response object are not guaranteed and may change within the same version of the API. Properties may be added to but will not be removed from the response within the same version. Geocoding results are returned in Carmen GeoJSON format.
| Property | Description |
|---|---|
type |
"Feature Collection"
, a GeoJSON type from the
GeoJSON specification
. |
query |
An array of space and punctuation-separated strings from the original query. |
features |
An array of feature objects. |
attribution |
A string attributing the results of the Mapbox Geocoding API to Mapbox and links to Mapbox's terms of service and data sources. |
Feature object
Each feature object in the "features" array may have the properties described below. Forward geocodes return features ordered by relevance. Reverse geocodes return features in order of index hierarchy from most specific features to least specific features that overlap the queried coordinates.
| Property | Description |
|---|---|
id |
A string feature id in the form
{type}.{id}
where
{type}
is the lowest hierarchy feature in the
place_type
field. The
{id}
suffix of the feature id is unstable and may change within versions. |
type |
"Feature"
, a GeoJSON type from the
GeoJSON specification
. |
place_type |
An array of feature types describing the feature. Options are
country
,
region
,
postcode
,
district
,
place
,
locality
,
neighborhood
,
address
,
poi
, and
poi.landmark
. Most features have only one type, but if the feature has multiple types, (for example, Vatican City is a
country
,
region
, and
place
), all applicable types will be listed in the array. |
relevance |
A numerical score from 0 (least relevant) to 0.99 (most relevant) measuring how well each returned feature matches the query. You can use the
relevance
property to remove results which don't fully match the query. |
address
(optional) |
A string of the house number for the returned
address
feature. Note that unlike the
address
property for
poi
features, this property is outside the
properties
object. |
properties |
An object describing the feature. The property object is unstable and only Carmen GeoJSON properties are guaranteed. Your implementation should check for the presence of these values in a response before it attempts to use them. |
properties.address
(optional) |
A string of the full street address for the returned
poi
feature. Note that unlike the
address
property for
address
features, this property is inside the
properties
object. |
properties.category
(optional) |
A string of comma-separated categories for the returned
poi
feature. |
properties.tel
(optional) |
A formatted string of the telephone number for the returned
poi
feature. |
properties.maki
(optional) |
The name of a suggested
Maki
icon to visualize a
poi
feature based on its
category
. |
properties.landmark
(optional) |
A boolean value indicating whether a
poi
feature is a landmark. Landmarks are particularly notable or long-lived features like schools, parks, museums and places of worship. |
properties.wikidata
(optional) |
The Wikidata identifier for the returned feature. |
properties.short_code
(optional) |
The ISO 3166-1 country and ISO 3166-2 region code for the returned feature. |
text |
A string representing the feature in the requested language, if specified. |
place_name |
A string representing the feature in the requested language, if specified, and its full result hierarchy. |
matching_text
(optional) |
A string analogous to the
text
field that more closely matches the query than results in the specified language. For example, querying "Köln, Germany" with language set to English might return a feature with the
text
"Cologne" and the
matching_text
"Köln". |
matching_place_name
(optional) |
A string analogous to the
place_name
field that more closely matches the query than results in the specified language. For example, querying "Köln, Germany" with language set to English might return a feature with the
place_name
"Cologne, Germany" and a
matching_place_name
of "Köln, North Rhine-Westphalia, Germany". |
text_{language}
(optional) |
A string analogous to the
text
field that matches the query in the requested language. This field is only returned when requesting multiple languages and will be present for each requested language. |
place_name_{language}
(optional) |
A string analogous to the
place_name
field that matches the query in the requested language. This field is only returned when requesting multiple languages and will be present for each requested language. |
language
(optional) |
A string of the IETF language tag of the query's primary language. |
language_{language}
(optional) |
A string of the IETF language tag of the query's fallback language. This field is only returned when requesting multiple languages and will be present for each requested language. |
bbox |
An array bounding box in the form [ minX,minY,maxX,maxY ] . |
center |
An array in the form
[
longitude,latitude
]
at the center of the specified
bbox
. |
geometry |
An object describing the spatial geometry of the returned feature. |
geometry.type |
"Point"
, a GeoJSON type from the
GeoJSON specification
. |
geometry.coordinates |
An array in the format
[
longitude,latitude
]
at the center of the specified
bbox
. |
geometry.interpolated
(optional) |
A boolean value indicating if an
address
is interpolated along a road network. This field is only present when the feature is interpolated. |
context |
An array representing the hierarchy of encompassing parent features. Each parent feature may include any of the above properties. |
{
"type": "FeatureCollection",
"query": [
"los",
"angeles"
],
"features": [
{
"id": "place.9962989141465270",
"type": "Feature",
"place_type": [
"place"
],
"relevance": 0.99,
"properties": {
"wikidata": "Q65"
},
"text": "Los Angeles",
"place_name": "Los Angeles, California, United States",
"bbox": [
-118.529221009603,
33.901599990108,
-118.121099990025,
34.1612200099034
],
"center": [
-118.2439,
34.0544
],
"geometry": {
"type": "Point",
"coordinates": [
-118.2439,
34.0544
]
},
"context": [
{
"id": "region.3591",
"short_code": "US-CA",
"wikidata": "Q99",
"text": "California"
},
{
"id": "country.3145",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
{
"id": "place.10952642230180310",
"type": "Feature",
"place_type": [
"place"
],
"relevance": 0.99,
"properties": {
"wikidata": "Q16910"
},
"text": "Los Ángeles",
"place_name": "Los Ángeles, Bío Bío, Chile",
"bbox": [
-72.68248,
-37.663862,
-72.041277,
-37.178368
],
"center": [
-72.35,
-37.46667
],
"geometry": {
"type": "Point",
"coordinates": [
-72.35,
-37.46667
]
},
"context": [
{
"id": "region.3552",
"short_code": "CL-BI",
"wikidata": "Q2170",
"text": "Bío Bío"
},
{
"id": "country.344",
"short_code": "cl",
"wikidata": "Q298",
"text": "Chile"
}
]
},
{
"id": "poi.1611278850983920",
"type": "Feature",
"place_type": [
"poi"
],
"relevance": 0.99,
"properties": {
"address": "1 World Way",
"category": "international airport, airport",
"tel": "(310) 646-5252",
"wikidata": "Q8731",
"landmark": true,
"maki": "airport"
},
"text": "Los Angeles International Airport",
"place_name": "Los Angeles International Airport, 1 World Way, Los Angeles, California 90045, United States",
"center": [
-118.408056,
33.9425
],
"geometry": {
"coordinates": [
-118.408056,
33.9425
],
"type": "Point"
},
"context": [
{
"id": "neighborhood.33720",
"text": "Westchester"
},
{
"id": "postcode.8081932850252730",
"text": "90045"
},
{
"id": "place.9962989141465270",
"wikidata": "Q65",
"text": "Los Angeles"
},
{
"id": "region.3591",
"short_code": "US-CA",
"wikidata": "Q99",
"text": "California"
},
{
"id": "country.3145",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
{
"id": "neighborhood.2104633",
"type": "Feature",
"place_type": [
"neighborhood"
],
"relevance": 0.99,
"properties": {},
"text": "Los Angeles Heights - Keystone",
"place_name": "Los Angeles Heights - Keystone, San Antonio, Texas 78201, United States",
"bbox": [
-98.534942,
29.453364,
-98.514652,
29.485214
],
"center": [
-98.52,
29.47
],
"geometry": {
"type": "Point",
"coordinates": [
-98.52,
29.47
]
},
"context": [
{
"id": "postcode.7069290925572850",
"text": "78201"
},
{
"id": "place.7705127234253710",
"wikidata": "Q975",
"text": "San Antonio"
},
{
"id": "region.3818",
"short_code": "US-TX",
"wikidata": "Q1439",
"text": "Texas"
},
{
"id": "country.3145",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
},
{
"id": "poi.17555628334440500",
"type": "Feature",
"place_type": [
"poi"
],
"relevance": 0.99,
"properties": {
"address": "3939 S Figueroa St",
"category": "stadium, arena",
"tel": "(213) 747-7111",
"wikidata": "Q849784",
"landmark": true,
"maki": "baseball"
},
"text": "Los Angeles Memorial Coliseum",
"place_name": "Los Angeles Memorial Coliseum, 3939 S Figueroa St, Los Angeles, California 90037, United States",
"center": [
-118.287778,
34.014167
],
"geometry": {
"coordinates": [
-118.287778,
34.014167
],
"type": "Point"
},
"context": [
{
"id": "neighborhood.293901",
"text": "South Los Angeles"
},
{
"id": "postcode.15612390715732530",
"text": "90037"
},
{
"id": "place.9962989141465270",
"wikidata": "Q65",
"text": "Los Angeles"
},
{
"id": "region.3591",
"short_code": "US-CA",
"wikidata": "Q99",
"text": "California"
},
{
"id": "country.3145",
"short_code": "us",
"wikidata": "Q30",
"text": "United States"
}
]
}
],
"attribution": "NOTICE: © 2017 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www.mapbox.com/about/maps/). This response and the information it contains may not be retained."
}
This is often called forward geocoding. Request feature data that best matches the input {query} text. The response includes one or more results ordered by relevance.
This API is used by the Mapbox.js L.mapbox.geocoderControl and the mapbox-gl-geocoder user interfaces.
$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/Los%20Angeles.json?access_token="
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/2+lincoln+memorial+circle+nw.json?access_token="
# use the country option to limit
# results to Canada and exclude the
# Lincoln Memorial in America
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/2+lincoln+memorial+circle+nw.json?country=ca&access_token="
# there are many towns named 'Chester', but adding the
# proximity parameter with local coordinates ensures that the town
# of Chester, New Jersey is in the search results
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/chester.json?proximity=-74.70850,40.78375&access_token="
# search only for countries named Georgia,
# so that we don't find the state in America
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/georgia.json?types=country&access_token="
# use the bounding box option to limit results for a
# search for "Starbucks" to those within Washington, D.C.
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/starbucks.json?bbox=-77.083056,38.908611,-76.997778,38.959167&access_token="
# use the limit option to limit the number of
# results to `2`. Even though there are many possible matches
# for `Washington`, this query will only return 2 results.
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/Washington.json?limit=2&access_token="
This is often called reverse geocoding. Request feature data located at the input {longitude},{latitude} coordinates. The response includes at most one result from each type, unless using the limit option.
Try this in the API Playground.
| URL Parameter | Description |
|---|---|
mode |
mapbox.places
or
mapbox.places-permanent
for enterprise/batch geocoding (see Response format below). |
| Query Parameter | Description |
|---|---|
types
(optional) |
Filter results by one or more type. Options are
country
,
region
,
postcode
,
district
,
place
,
locality
,
neighborhood
,
address
,
poi
, and
poi.landmark
. Multiple options can be comma-separated. Note that
poi.landmark
returns a subset of the results returned by
poi
. |
limit
(optional) |
Limit the maximum number of results. The default is
1
, and the maximum is
5
. If using this option a single
types
is required. |
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/-73.989,40.733.json?access_token="
# filter results to only include points of interest
curl "https://api.mapbox.com/geocoding/v5/mapbox.places/-73.989,40.733.json?types=poi&access_token="
This feature is only available with the mapbox.places-permanent mode.
Batch requests have the same parameters as normal requests, but can include
more than one query by separating queries with the ; character. Each
query should be URL encoded, but the ; character should not be encoded: it
should be included verbatim.
With the mapbox.places-permanent mode, you can make up to 50 forward
or reverse geocoding? queries in a single request. The response is
an array of individual geocoder responses.
Each query in a batch request counts individually against
your account's rate limits.
curl "https://api.mapbox.com/geocoding/v5/mapbox.places-permanent/20001;20009;22209.json?access_token="
The Mapbox Directions API will show you how to get where you're going. With the Directions API, you can:
This API supports four different routing profiles:
mapbox/driving-traffic for automotive routing. This profile factors in current and historic
traffic conditions to avoid slowdowns. Traffic is available in these supported geographiesmapbox/driving for automotive routing. This profile shows the fastest
routes by preferring high-speed roads, like highways.mapbox/walking for pedestrian and hiking routing. This profile shows the shortest
path by using sidewalks and trails.mapbox/cycling for bicycle routing. This profile shows routes that are short
and safer for cyclists by avoiding highways and preferring streets with bike lanes.Swift and Objective-C support for Directions is provided by the MapboxDirections.swift library.
Restrictions and limits
driving, walking, and cycling profiles can specify
up to 25 total waypoints along the route. Requests using the driving-traffic
profile can specify up to 3 waypoints.driving-traffic profile is available in supported geographies. Requests to this profile revert to driving profile results for areas without traffic coverage.driving-traffic profile.| URL Parameter | Description |
|---|---|
profile |
Routing profile; either
mapbox/driving-traffic
,
mapbox/driving
,
mapbox/walking
, or
mapbox/cycling |
coordinates |
Semicolon-separated list of
{longitude},{latitude}
coordinate pairs to visit in order; there can be between 2 and 25 coordinates. |
The response may be altered with optional query parameters:
| Query Parameter | Description |
|---|---|
alternatives
(optional) |
Whether to try to return alternative routes. An alternative is classified as a route that is significantly different then the fastest route, but also still reasonably fast. Not in all circumtances such a route exists. At the moment at most one alternative can be returned. Can be
true
or
false
(default). |
geometries
(optional) |
Format of the returned geometry. Allowed values are:
geojson
(as
LineString
),
polyline
(
documentation
) with precision 5,
polyline6
(
documentation
polyline with precision 6). The default value is
polyline
. |
overview
(optional) |
Type of returned overview geometry. Can be
full
(the most detailed geometry available),
simplified
(a simplified version of the full geometry), or
false
(no overview geometry). The default is
simplified
. |
radiuses
(optional) |
Maximum distance in meters that each coordinate is allowed to move when snapped to a nearby road segment. There must be as many radiuses as there are coordinates in the request, each separated by
;
. Values can be any number greater than 0 or they can be the string
unlimited
. If no routable road is found within the radius, a
NoSegment
error is returned. |
steps
(optional) |
Whether to return steps and turn-by-turn instructions. Can be
true
or
false
. The default is
false
. |
continue_straight
(optional) |
Sets allowed direction of travel when departing intermediate waypoints. If
true
the route will continue in the same direction of travel. If
false
the route may continue in the opposite direction of travel. Defaults to
true
for
mapbox/driving
and
false
for
mapbox/walking
and
mapbox/cycling
. |
bearings
(optional) |
Used to filter the road segment the waypoint will be placed on by direction and dictates the angle of approach. This option should always be used in conjunction with the
radiuses
parameter. The parameter takes two values per waypoint: the first is an angle clockwise from true north between 0 and 360. The second is the range of degrees the angle can deviate by. We recommend a value of 45° or 90° for the range, as bearing measurements tend to be inaccurate. This is useful for making sure we reroute vehicles on new routes that continue traveling in their current direction. A request that does this would provide bearing and radius values for the first waypoint and leave the remaining values empty. If provided, the list of bearings must be the same length as the list of waypoints, but you can skip a coordinate and show its position with the
;
separator. |
annotations
(optional) |
Whether or not to return additional metadata along the route. Possible values are:
duration
,
distance
,
speed
and
congestion
. Several annotations can be used by separating them with
,
. See the
RouteLeg object
for more details on what is included with annotations. |
language
(optional) |
Language of returned turn-by-turn text instructions. See
supported languages
. The default is
en
for English. |
Unrecognized options in the query string result in an InvalidInput error.
# request directions with no additional options
curl "https://api.mapbox.com/directions/v5/mapbox/cycling/-122.42,37.78;-77.03,38.91?access_token="
# request directions with steps and alternatives
curl "https://api.mapbox.com/directions/v5/mapbox/cycling/-122.42,37.78;-77.03,38.91?steps=true&alternatives=true&access_token="
# request directions with radiuses and polyline response
curl "https://api.mapbox.com/directions/v5/mapbox/driving/13.4301,52.5109;13.4265,52.5080;13.4194,52.5072?radiuses=40;;100&geometries=polyline&access_token="
# specify bearings
curl "https://api.mapbox.com/directions/v5/mapbox/driving/13.4301,52.5109;13.4265,52.5080;13.4316,52.5021?bearings=60,45;;45,45&radiuses=100;100;100&access_token="
The table below shows supported language codes used with the language parameter for turn-by-turn instructions.
| Code | Language |
|---|---|
de |
German |
en |
English |
es |
Spanish |
fr |
French |
id |
Indonesian |
nl |
Dutch |
ru |
Russian |
sv |
Swedish |
vi |
Vietnamese |
zh-Hans |
Chinese Simplified |
If an unsupported language code is used, the language parameter will automatically be set to English.
code: String indicating the state of the response. This is a separate code than the HTTP status code. On normal valid responses, the value will be Ok.waypoints: Array of Waypoint objects. Each waypoints is an input coordinate snapped to the road and path network. The waypoints appear in the array in the order of the input coordinates.routes: Array of Route objects ordered by descending recommendation rank. May contain at most two routes.$ curl "https://api.mapbox.com/directions/v5/mapbox/driving/13.4265,52.5080;13.4273,52.5069?steps=true&geometries=polyline&access_token="
{
"routes": [
{
"geometry": "mnn_Ick}pAfBiF`CzA",
"legs": [
{
"steps": [
{
"intersections": [
{
"out": 0,
"entry": [
true
],
"bearings": [
125
],
"location": [
13.426579,
52.508068
]
},
{
"out": 1,
"location": [
13.426688,
52.508022
],
"bearings": [
30,
120,
300
],
"entry": [
true,
true,
false
],
"in": 2
}
],
"geometry": "mnn_Ick}pAHUlAqDNa@",
"mode": "driving",
"duration": 18.6,
"maneuver": {
"bearing_after": 125,
"type": "depart",
"modifier": "right",
"bearing_before": 0,
"location": [
13.426579,
52.508068
],
"instruction": "Head southeast on Köpenicker Straße (L 1066)"
},
"ref": "L 1066",
"weight": 18.6,
"distance": 98.1,
"name": "Köpenicker Straße (L 1066)"
},
{
"intersections": [
{
"out": 2,
"location": [
13.427752,
52.50755
],
"bearings": [
30,
120,
210,
300
],
"entry": [
false,
true,
true,
false
],
"in": 3
}
],
"geometry": "ekn_Imr}pARL\\T^RHDd@\\",
"mode": "driving",
"duration": 8.5,
"maneuver": {
"bearing_after": 202,
"type": "turn",
"modifier": "right",
"bearing_before": 125,
"location": [
13.427752,
52.50755
],
"instruction": "Turn right onto Engeldamm"
},
"weight": 8.5,
"distance": 78.6,
"name": "Engeldamm"
},
{
"intersections": [
{
"in": 0,
"entry": [
true
],
"bearings": [
25
],
"location": [
13.427292,
52.506902
]
}
],
"geometry": "cgn_Iqo}pA",
"mode": "driving",
"duration": 0,
"maneuver": {
"bearing_after": 0,
"location": [
13.427292,
52.506902
],
"bearing_before": 205,
"type": "arrive",
"instruction": "You have arrived at your destination"
},
"weight": 0,
"distance": 0,
"name": "Engeldamm"
}
],
"distance": 176.7,
"duration": 27.1,
"summary": "Köpenicker Straße, Engeldamm",
"weight": 27.1
}
],
"distance": 176.7,
"duration": 27.1,
"weight_name": "routability",
"weight": 27.1
}
],
"waypoints": [
{
"name": "Köpenicker Straße",
"location": [
13.426579,
52.508068
]
},
{
"name": "Engeldamm",
"location": [
13.427292,
52.506902
]
}
],
"code": "Ok"
}
An input coordinate snapped to the roads network.
name: String with the name of the way the coordinate snapped tolocation: Array of [ longitude, latitude ] for the snapped coordinate{
"name": "Kirkjubøarvegur",
"location": [
-6.80897,
62.000075
]
}
A route through (potentially multiple) waypoints.
distance: Float indicating the distance traveled in metersduration: Float indicating the estimated travel time in secondsweight: Float indicating the weight in units described by weight_nameweight_name: String indicating which weight was used. The default is routability which is duration based, with additional penalties for less desirable maneuvers.geometry: Depending on the geometries parameter this is a GeoJSON LineString or a Polyline string. Depending on the overview parameter this is the complete route geometry (full), a simplified geometry to the zoom level at which the route can be displayed in full (simplified), or is not included (false).legs: Array of RouteLeg objects{
"duration": 88.4,
"distance": 830.4,
"weight": 88.4,
"weight_name": "routability",
"geometry": "oklyJ`{ph@yBuY_F{^_FxJoBrBs@d@mAT",
"legs": [ ]
}
A route between only two waypoints.
distance: Number indicating the distance traveled in metersduration: Number indicating the estimated travel time in secondssteps: Depending on the steps parameter, either an Array of RouteStep objects (true, default) or an empty array (false)summary: Depending on the summary parameter, either a String summarizing the route (true, default) or an empty String (false)annotation: An annotations object that contains additional details about each line segment along the route geometry. Each entry in an annotations field corresponds to a coordinate along the route geometry.annotation |
Description |
|---|---|
distance |
The distance, in meters, between each pair of coordinates |
duration |
The duration, in seconds, between each pair of coordinates |
speed |
The speed, in meters per second, between each pair of coordinates |
congestion |
The congestion level between each pair of coordinates, described as one of
severe
,
heavy
,
moderate
,
low
or
unknown |
congestion is the speed with traffic compared with speed with no traffic. A break down is below:
| Congestion | Description |
|---|---|
low |
between 0% and 20% greater than non-traffic speeds |
moderate |
between 20% and 60% greater than non-traffic speeds |
heavy |
between 60% and 80% greater than non-traffic speeds |
severe |
between 80% and 100% greater than non-traffic speeds |
unknown |
this information is unavailable |
{
"annotation": {
"distance": [
4.294596842089401,
5.051172053200946,
5.533254065167979,
6.576513793849532,
7.4449640160938015,
8.468757534990829,
15.202780313562714,
7.056346577326572
],
"duration": [
1,
1.2,
2,
1.6,
1.8,
2,
3.6,
1.7
],
"speed": [
4.3,
4.2,
2.8,
4.1,
4.1,
4.2,
4.2,
4.2
],
"congestion": [
"low",
"moderate",
"moderate",
"moderate",
"heavy",
"heavy",
"heavy",
"heavy"
]
},
"duration": 14.3,
"weight": 14.3,
"distance": 53.4,
"steps": [],
"summary": ""
}
Includes one StepManeuver object and travel to the following RouteStep.
distance: Number indicating the distance traveled in meters from the maneuver to the next RouteStep.
duration: Number indicating the estimated time traveled time in seconds from the maneuver to the next RouteStep.
geometry: Depending on the geometries parameter this is a GeoJSON LineString or a Polyline string representing the full route geometry from this RouteStep to the next RouteStep
name: String with the name of the way along which the travel proceeds
ref: Any road designations associated with the road or path leading from this step’s maneuver to the next step’s maneuver. Optionally included, if data is available. If multiple road designations are associated with the road, they are separated by semicolons. A road designation typically consists of an alphabetic network code (identifying the road type or numbering system), a space or hyphen, and a route number. You should not assume that the network code is globally unique: for example, a network code of “NH” may appear on a “National Highway” or “New Hampshire”. Moreover, a route number may not even uniquely identify a road within a given network.
destinations: String with the destinations of the way along which the travel proceeds. Optionally included, if data is available.
exits: String with the exit numbers or names of the way. Optionally included, if data is available.
mode: String indicating the mode of transportation. Possible values:
mapbox/driving: driving, ferry, unaccessiblemapbox/walking: walking, ferry, unaccessiblemapbox/cycling: cycling, walking, ferry, train, unaccessiblemaneuver: One StepManeuver object
intersections: Array of objects representing all intersections along the step.
location: A [longitude, latitude] pair describing the location of the turn.bearings: A list of bearing values (for example [0,90,180,270]) that are available at the intersection. The bearings describe all available roads at the intersection.classes: An array of strings signifying the classes of the road exiting the intersection. Possible values:
toll: the road continues on a toll roadferry: the road continues on a ferryrestricted: the road continues on with access restrictionsmotorway: the road continues on a motorwayentry: A list of entry flags, corresponding in a 1:1 relationship to the bearings. A value of true indicates that the respective road could be entered on a valid route. false indicates that the turn onto the respective road would violate a restriction.in: Index into bearings/entry array. Used to calculate the bearing before the turn. Namely, the clockwise angle from true north to the direction of travel before the maneuver/passing the intersection. To get the bearing in the direction of driving, the bearing has to be rotated by a value of 180. The value is not supplied for departure maneuvers.out: Index into the bearings/entry array. Used to extract the bearing after the turn. Namely, The clockwise angle from true north to the direction of travel after the maneuver/passing the intersection. The value is not supplied for arrive maneuvers.lanes: Array of Lane objects that represent the available turn lanes at the intersection. If no lane information is available for an intersection, the lanes property will not be present.{
"intersections": [
{
"out": 1,
"location": [
13.424671,
52.508812
],
"bearings": [
120,
210,
300
],
"entry": [
false,
true,
true
],
"in": 0
}
],
"geometry": "asn_Ie_}pAdKxG",
"maneuver": {
"bearing_after": 202,
"type": "turn",
"modifier": "left",
"bearing_before": 299,
"location": [
13.424671,
52.508812
],
"instruction": "Turn left onto Adalbertstraße"
},
"duration": 59.1,
"distance": 236.9,
"weight": 59.1,
"name": "Adalbertstraße",
"mode": "driving"
}
location: Array of [ longitude, latitude ] coordinates for the point of the maneuverbearing_before: Number between 0 and 360 indicating the clockwise angle from true north to the direction of travel right before the maneuverbearing_after: Number between 0 and 360 indicating the clockwise angle from true north to the direction of travel right after the maneuverinstruction: A human-readable instruction of how to execute the returned maneuvertype: String indicating the type of maneuvermodifier Optional String indicating the direction change of the maneuvermodifier |
Description |
|---|---|
uturn |
indicates reversal of direction,
type
can be
turn
or
continue
when staying on the same road |
sharp right |
a sharp right turn |
right |
a normal turn to the right |
slight right |
a slight turn to the right |
straight |
no relevant change in direction |
slight left |
a slight turn to the left |
left |
a normal turn to the left |
sharp left |
a sharp turn to the left |
The list of turns without a modifier is limited to: depart / arrive.
If the source? / target location is close enough to the depart / arrive location, no modifier will be given.
The meaning depends on the type property.
type |
Description |
|---|---|
depart
/
arrive |
modifier
indicates the position of departure point and arrival point in relation to the current direction of travel |
New properties (potentially depending on type) may be introduced in the future without an API version change.
{
"bearing_before": 299,
"bearing_after": 202,
"type": "turn",
"modifier": "left",
"location": [
13.424671,
52.508812
],
"instruction": "Turn left onto Adalbertstraße"
}
type |
Description |
|---|---|
turn |
a basic turn into direction of the modifier |
new name |
the road name changes (after a mandatory turn) |
depart |
indicates departure from a leg |
arrive |
indicates arrival to a destination of a leg |
merge |
merge onto a street |
on ramp |
take a ramp to enter a highway |
off ramp |
take a ramp to exit a highway |
fork |
take the left/right side of a fork |
end of road |
road ends in a T intersection |
continue |
continue on a street after a turn |
roundabout |
traverse roundabout, has additional property
exit
in
RouteStep
containing the exit number. The modifier specifies the direction of entering the roundabout. |
rotary |
a traffic circle. While very similar to a larger version of a roundabout, it does not necessarily follow roundabout rules for right of way. It can offer
rotary_name
and / or
rotary_pronunciation
parameters located in the
RouteStep
object in addition to the
exit
property. |
roundabout turn |
small roundabout that is treated as an intersection |
notification |
change of driving conditions, e.g. change of
mode
from
driving
to
ferry |
Available turn lanes at the intersection. Lanes are provided in their order on the street, from left to right.
valid: Boolean value for whether this lane can be taken to complete the maneuver. For instance, if the lane array has four objects and the first two are marked as valid, then the driver can take either of the left lanes and stay on the route.indications: Array of signs for each turn lane. There can be multiple signs. For example, a turning lane can have a sign with an arrow pointing left and another sign with an arrow pointing straight.{
"valid": true,
"indications": [
"left"
]
}
On error, the server responds with different HTTP status codes. For responses with HTTP status codes lower than 500, the JSON response body includes the code property, which may be used by client programs to manage control flow. The response body may also include a message property, with a human-readable explanation of the error.
If a server error occurs, the HTTP status code will be 500 or higher and the response will not include a code property.
Response body
code |
HTTP status code | comment |
|---|---|---|
Ok |
200 |
Normal success case |
NoRoute |
200 |
There was no route found for the given coordinates. Check for impossible routes (e.g. routes over oceans without ferry connections). |
NoSegment |
200 |
No road segment could be matched for coordinates. Check for coordinates too far away from a road. |
ProfileNotFound |
404 |
Use a valid profile as described above |
InvalidInput |
422 |
The given request was not valid. The
message
key of the response will hold an explanation of the invalid input. |
This documentation is for the v5 API. See the documentation for the legacy v4 API.
The Mapbox Map Matching API snaps fuzzy, inaccurate traces from a GPS unit or a phone to the OpenStreetMap? road and path network using the Directions API. This produces clean paths that can be displayed on a map or used for other analysis.
Limits
For high volume or other use cases, contact us.
Returns a path on the road and path network closest to the input traces.
| URL Parameter | Description |
|---|---|
profile |
A directions profile ID; either
mapbox/driving
,
mapbox/driving-traffic
,
mapbox/walking
, or
mapbox/cycling |
coordinates |
Semicolon-separated list of
{longitude},{latitude}
coordinate pairs to visit in order; there can be between 2 and 100 coordinates. |
| Query Parameter | Description |
|---|---|
geometries
(optional) |
Format of the returned geometry. Allowed values are:
geojson
(as
LineString
),
polyline
(
documentation
) with precision 5,
polyline6
(
documentation
polyline with precision 6). The default value is
polyline
. |
radiuses
(optional) |
A list of integers in meters indicating the assumed precision of the used tracking device. There must be as many radiuses as there are coordinates in the request, each separated by
;
. Values can be a number between 0 and 30. Use higher numbers (20-30) for noisy traces and lower numbers (1-10) for clean traces. The default value is 5. |
steps
(optional) |
Whether to return steps and turn-by-turn instructions. Can be
true
or
false
. The default is
false
. |
overview
(optional) |
Type of returned overview geometry. Can be
full
(the most detailed geometry available),
simplified
(a simplified version of the full geometry), or
false
(no overview geometry). The default is
simplified
. |
timestamps
(optional) |
Timestamps corresponding to each coordinate provided in the request; must be numbers in
Unix time
(seconds since the Unix epoch). There must be as many timestamps as there are coordinates in the request, each separated by
;
. |
annotations
(optional) |
Whether or not to return additional metadata along the route. Possible values are:
duration
,
distance
and
speed
. Several annotations can be used by separating them with
,
. See the
RouteLeg object
for more details on what is included with annotations. |
tidy
(optional) |
Whether or not to transparently remove clusters and re-sample traces for improved map matching results. Can be
true
or
false
. The default is
false
. |
language
(optional) |
Language of returned turn-by-turn text instructions. See
supported languages
. The default is
en
for English. |
It is recommended to include timestamps, since they help improve the quality of the matching. The timestamps must be ascending. For best results, your timestamps should have a sample rate of about 5 seconds.
Some pre-processing tips to achieve the best results:
tidy=true query parameter or pre-process your traces with
external tools like geojson-tidy.$ curl "https://api.mapbox.com/matching/v5/mapbox/driving/-117.1728265285492,32.71204416018209;-117.17288821935652,32.712258556224;-117.17293113470076,32.712443613445814;-117.17292040586472,32.71256999376694;-117.17298477888109,32.712603845608285;-117.17314302921294,32.71259933203019;-117.17334151268004,32.71254065549407?access_token="
With clean matches, only one match object is returned. When the the algorithm cannot decide the correct match between two points, it will omit that line and return several sub-matches as match objects. The higher the number of sub-match match objects, the more likely that the input traces are poorly aligned to the road network.
code: a string depicting the state of the response; see below for optionsmatchings: an array of Match objectstracepoints: an array of Tracepoint objects representing the location an input point was matched with. Array of Waypoint objects representing all input points of the trace in the order they were matched. If a trace point is omitted by map matching because it is an outlier, the entry will be null.$ curl "https://api.mapbox.com/matching/v5/mapbox/driving/-117.1728265285492,32.71204416018209;-117.17288821935652,32.712258556224;-117.17293113470076,32.712443613445814;-117.17292040586472,32.71256999376694;-117.17298477888109,32.712603845608285;-117.17314302921294,32.71259933203019;-117.17334151268004,32.71254065549407?access_token="
{
"matchings": [
{
"confidence": 0.9559977809133028,
"geometry": "gatfEfidjUk@Lc@@Y?E??L?\\Hh@",
"legs": [
{
"steps": [],
"distance": 25,
"duration": 2.8,
"summary": "",
"weight": 2.8
},
{
"steps": [],
"distance": 21,
"duration": 2.4,
"summary": "",
"weight": 2.4
},
{
"steps": [],
"distance": 14,
"duration": 1.6,
"summary": "",
"weight": 1.6
},
{
"steps": [],
"distance": 9.1,
"duration": 6.5,
"summary": "",
"weight": 7.6
},
{
"steps": [],
"distance": 14.8,
"duration": 6,
"summary": "",
"weight": 6.4
},
{
"steps": [],
"distance": 20,
"duration": 9,
"summary": "",
"weight": 9
}
],
"distance": 103.89999999999999,
"duration": 28.299999999999997,
"weight_name": "routability",
"weight": 29.799999999999997
}
],
"tracepoints": [
{
"alternatives_count": 0,
"waypoint_index": 0,
"location": [
-117.172836,
32.712041
],
"name": "North Harbor Drive",
"matchings_index": 0
},
{
"alternatives_count": 0,
"waypoint_index": 1,
"location": [
-117.17291,
32.712256
],
"name": "North Harbor Drive",
"matchings_index": 0
},
{
"alternatives_count": 0,
"waypoint_index": 2,
"location": [
-117.17292,
32.712444
],
"name": "North Harbor Drive",
"matchings_index": 0
},
{
"alternatives_count": 0,
"waypoint_index": 3,
"location": [
-117.172922,
32.71257
],
"name": "North Harbor Drive",
"matchings_index": 0
},
{
"alternatives_count": 0,
"waypoint_index": 4,
"location": [
-117.172985,
32.7126
],
"name": "West G Street",
"matchings_index": 0
},
{
"alternatives_count": 0,
"waypoint_index": 5,
"location": [
-117.173143,
32.712597
],
"name": "West G Street",
"matchings_index": 0
},
{
"alternatives_count": 1,
"waypoint_index": 6,
"location": [
-117.173345,
32.712546
],
"name": "West G Street",
"matchings_index": 0
}
],
"code": "Ok"
}
A match object is a Route object with an additional confidence field.
confidence: a number between 0 (low) and 1 (high) indicating level of confidence in the returned matchRefer to the Route object documentation for how the rest of a Match object is structured.
{
"confidence": 0.9548844020537051,
"distance": 103.7,
"duration": 16.4,
"geometry": "gatfEfidjUi@Le@@Y?E??J?^Hf@",
"legs": []
}
A tracepoint object is Waypoint object with two additional fields:
matchings_index: Index to the match object in matchings the sub-trace was matched to.waypoint_index: Index of the waypoint inside the matched route.alternatives_count: Number of probable alternative matchings for this trace point. A value of zero indicates that this point was matched unambiguously. Split the trace at these points for incremental map matching.{
"waypoint_index": 0,
"location": [-117.172836, 32.71204],
"name": "North Harbor Drive",
"matchings_index": 0,
"alternatives_count": 0
}
On error, the server responds with different HTTP status codes. For responses with HTTP status codes lower than 500, the JSON response body includes the code property, which may be used by client programs to manage control flow. The response body may also include a message property, with a human-readable explaination of the error.
If a server error occurs, the HTTP status code will be 500 or higher and the response will not include a code property.
| Code option | Description |
|---|---|
Ok |
Normal case |
NoMatch |
The input did not produce any matches.
features
will be an empty array. |
TooManyCoordinates |
There are more than 100 points in the request. |
InvalidInput |
message
will hold an explanation of the invalid input. |
ProfileNotFound |
Needs to be a valid profile. See valid profiles above . |
This documentation is for the v5 API. See the documentation for the v4 API.
The Matrix API returns travel times between many points.
For example, given 3 locations A, B, C, the Matrix API will return a matrix of all travel times in seconds between the locations:
| A | B | C | |
|---|---|---|---|
| A | A → A | A → B | A → C |
| B | B → A | B → B | B → C |
| C | C → A | C → B | C → C |
The Matrix API will always return the duration on the fastest route. Durations between points may not be symmetric (for example A to B may have a different duration than B to A), as the routes may differ by direction due to one-way streets or turn restrictions. The Matrix API returns durations in seconds. It does not return route geometries or distances.
This API allows you to build tools that efficiently check the reachability of coordinates from each other, filter? points by travel time, or run your own algorithms for solving optimization problems.
Limits
For example you can request a symmetric 25x25 matrix, an asymmetric 1x24 matrix with distinct coordinates or a 12x24 where sources and destinations share some coordinates.
For higher volumes, contact us.
Returns a duration matrix showing travel times between coordinates.
The {profile} parameter of your request should be a Mapbox Directions routing profile? ID. The following IDs are supported:
mapbox/driving for car travel timesmapbox/walking for pedestrian and hiking travel timesmapbox/cycling for bicycle travel timesThe mapbox/driving-traffic profile is not supported.
The {coordinates} parameter is a semicolon-separated list of {longitude},{latitude} coordinates. There must be between 2 and 25 coordinates.
In the default case, the matrix returns a symmetric matrix, using all input coordinates as sources and destinations. You may also generate an asymmetric matrix, with only some coordinates as sources or destinations:
| Query Parameter | Values |
|---|---|
sources
(optional) |
{index};{index}[;{index} ...]
or
all
(default) |
destinations
(optional) |
{index};{index}[;{index} ...]
or
all
(default) |
Unrecognized options in the query string result in an InvalidInput error.
# request a symmetric 3x3 matrix for cars
curl "https://api.mapbox.com/directions-matrix/v1/mapbox/driving/-122.42,37.78;-122.45,37.91;-122.48,37.73?access_token="
# request an asymmetric 2x3 matrix for bicycles
curl "https://api.mapbox.com/directions-matrix/v1/mapbox/cycling/-122.42,37.78;-122.45,37.91;-122.48,37.73?sources=0;2&destinations=all&access_token="
code: String indicating the state of the response. This is a separate code than the HTTP status code. On normal valid responses, the value will be Ok. See the errors section below for more information.durations: Durations as array of arrays representing the matrix in row-major order. durations[i][j] gives the travel time from the i-th source to the j-th destination. All values are in seconds. The duration between the same coordinate is always 0. If a duration can not be found, the result is null.destinations:: Array of waypoint objects. Each waypoints is an input coordinate snapped to the road and path network. The waypoints appear in the array in the order of the input coordinates, or in the order as specified in the destinations query parameter.sources: Array of waypoint objects. Each waypoints is an input coordinate snapped to the road and path network. The waypoints appear in the array in the order of the input coordinates, or in the order as specified in the sources query parameter.{
"code": "Ok",
"durations": [
[ 0, 77.3, null ],
[ 75.7, 0, null ],
[ null, null, 0 ]
],
"destinations": [
{
"location": [
-6.80897,
62.000075
],
"name": "Kirkjubøarvegur"
},
{
"location": [
-6.802374,
62.004142
],
"name": "Marknagilsvegur"
},
{
"location": [
7.419449,
43.731931
],
"name": "Avenue du Port"
}
],
"sources": [
{
"location": [
-6.80897,
62.000075
],
"name": "Kirkjubøarvegur"
},
{
"location": [
-6.802374,
62.004142
],
"name": "Marknagilsvegur"
},
{
"location": [
7.419449,
43.731931
],
"name": "Avenue du Port"
}
]
}
On error, the server responds with different HTTP status codes. For responses with HTTP status codes lower than 500, the JSON response body includes the code property, which may be used by client programs to manage control flow. The response body may also include a message property, with a human-readable explanation of the error.
If a server error occurs, the HTTP status code will be 500 or higher and the response will not include a code property.
Note that in cases where no route is found between a source? and destination, no error will be returned, but instead the respective value in the durations matrix will be null.
Response body
code |
HTTP status code | comment |
|---|---|---|
Ok |
200 |
Normal success case |
ProfileNotFound |
404 |
Use a valid profile as described above |
InvalidInput |
422 |
The given request was not valid. The
message
key of the response will hold an explanation of the invalid input. |
The earlier Mapbox Distance API is deprecated. See the documentation.
The Optimization API returns a duration-optimized route between the input coordinates. This is also known as solving the Traveling Salesperson Problem. A typical use case for this API is planning the route for deliveries in a city. Route can be retrieved for car driving, bicycling and walking or hiking.
Limits
For higher volumes, contact us.
The {profile} parameter of your request should be a Mapbox Directions routing profile?
ID. The following IDs are supported:
mapbox/driving for car tripsmapbox/walking for pedestrian and hiking tripsmapbox/cycling for bicycle tripsThe mapbox/driving-traffic profile is not supported.
The {coordinates} parameter is a semicolon-separated list of {longitude},{latitude} coordinates. There must be between 2 and 12 coordinates. The first coordinate is the start and end point of the trip.
The response may be altered with optional query parameters:
| Query Parameter | Description |
|---|---|
roundtrip
(optional) |
Returned route is a roundtrip (route returns to first location). Allowed values are:
true
(default),
false
. If the roundtrip is set to
false
, then
source
and
destination
parameters are required but not all combinations are possible. See Fixing Start and End Points for additional notes. |
source
(optional) |
Returned route starts at
any
or
first
coordinate. Allowed values are:
any
(default),
first
. |
destination
(optional) |
Returned route ends at
any
or
last
coordinate. Allowed values are:
any
(default),
last
. |
geometries
(optional) |
Format of the returned geometries. Allowed values are:
polyline
(default,
documentation
, polyline with precision 5),
polyline6
(
documentation
, polyline with precision 6),
geojson
(as
LineString
). |
overview
(optional) |
Type of returned overview geometry. Allowed values are:
simplified
(default, a simplified version of the geometry),
full
(the most detailed geometry available),
false
(no overview geometry). |
radiuses
(optional) |
Maximum distance in meters that each coordinate is allowed to move when snapped to a nearby road segment. There must be as many radiuses as there are coordinates in the request, each separated by
;
. Values can be any number greater than 0 or they can be the string
unlimited
. If no routable road is found within the radius, a
NoSegment
error is returned. |
steps
(optional) |
Whether to return steps and turn-by-turn instructions. Allowed values are:
false
(default),
true |
bearings
(optional) |
Used to filter the road segment the waypoint will be placed on by direction and dictates the angle of approach. This option should always be used in conjunction with the
radiuses
parameter. The parameter takes two values per waypoint: the first is an angle clockwise from true north between 0 and 360. The second is the range of degrees the angle can deviate by. We recommend a value of 45° or 90° for the range, as bearing measurements tend to be inaccurate. This is useful for making sure we reroute vehicles on new routes that continue traveling in their current direction. A request that does this would provide bearing and radius values for the first waypoint and leave the remaining values empty. If provided, the list of bearings must be the same length as the list of waypoints, but you can skip a coordinate and show its position with the
;
separator. |
annotations
(optional) |
Whether or not to return additional metadata along the route. Possible values are:
duration
,
distance
and
speed
. Several annotations can be used by separating them with
,
. See the
RouteLeg object
for more details on what is included with annotations. |
language
(optional) |
Language of returned turn-by-turn text instructions. See
supported languages
. The default is
en
for English. |
distributions
(optional) |
Specify pick-up and drop-off locations for a trip by providing a
;
delimited list of number pairs that correspond with the
coordinates
list. The first number indicates the index to the coordinate of the pick-up location in the coordinates list, and the second number indicates the index to the coordinate of the drop-off location in the coordinates list. Each pair must contain exactly two numbers. Pick-up and drop-off locations in one pair cannot be the same. The returned solution will visit pick-up locations before visiting drop-off locations. The depot (first location) can only be a pick-up location but not a drop-off location. |
Unrecognized options in the query string result in an InvalidInput error.
Note that routes returned by the Optimization API will behave as if continue_straight=false was set at each waypoint. See the continue\straight parameter for more details on what this means for the route.
Fixing Start and End Points
It is possible to explicitly set the start or end coordinate of the trip.
When source? is set to first, the first coordinate is used as the start coordinate of the trip in the output. When destination is set to last, the last coordinate will be used as destination of the trip in the returned output. If you specify any, any of the coordinates can be used as the first or last coordinate in the output.
If source=any&destination=any the returned roundtrip will still start at the first input coordinate by default.
Not all combinations of roundtrip, source and destination are supported. Right now, the following combinations are possible:
| roundtrip | source | destination | supported |
|---|---|---|---|
| true | first | last | yes |
| true | first | any | yes |
| true | any | last | yes |
| true | any | any | yes |
| false | first | last | yes |
| false | first | any | no |
| false | any | last | no |
| false | any | any | no |
# request an optimized car trip with no additional options
curl "https://api.mapbox.com/optimized-trips/v1/mapbox/driving/-122.42,37.78;-122.45,37.91;-122.48,37.73?access_token="
# request an optimized bicycle trip with steps and geojson response
curl "https://api.mapbox.com/optimized-trips/v1/mapbox/cycling/-122.42,37.78;-122.45,37.91;-122.48,37.73?steps=true&geometries=geojson&access_token="
# request an optimized car roundtrip in Berlin with four coordinates, starting at the first coordinate pair, ending at the coordinate pair
curl "https://api.mapbox.com/optimized-trips/v1/mapbox/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219;13.418555,52.523215?source=first&destination=last&roundtrip=true&access_token="
# request an optimized car trip with four coordinates and one distributions constraint where the last given coordinate must be visited before the second
curl "https://api.mapbox.com/optimized-trips/v1/mapbox/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219;13.418555,52.523215?roundtrip=true&distributions=3,1&access_token="
code: String indicating the state of the response. This is a separate code than the HTTP status code. On normal valid responses, the value will be Ok. See the errors section below for more information.waypoints: Array of waypoint objects. Each waypoint is an input coordinate snapped to the road and path network. The waypoints appear in the array in the order of the input coordinates.trips: Array of trip objects. Will have zero or one trip.Waypoint object
An input coordinate snapped to the roads network.
name: String with the name of the way the coordinate snapped tolocation: Array of [ longitude, latitude ] for the snapped coordinatetrips_index: Index to the trip object in the trips array that contains this waypointwaypoint_index: Index of position of the waypoint within the tripTrip object
A trip object is a route through (potentially multiple) waypoints. It follows the exact same format as the Route object in the Directions API. Please refer to the Directions API documentation.
{
"code": "Ok",
"waypoints": [
{
"location": [
-6.80897,
62.000075
],
"waypoint_index": 0,
"name": "Kirkjubøarvegur",
"trips_index": 0
},
{
"location": [
-6.802374,
62.004142
],
"waypoint_index": 1,
"name": "Marknagilsvegur",
"trips_index": 0
}
],
"trips": [
{
"distance": 1660.8,
"duration": 153,
"legs": [
{
"summary": "",
"duration": 77.3,
"steps": [],
"distance": 830.4
},
{
"distance": 830.4,
"steps": [],
"duration": 75.7,
"summary": ""
}
],
"geometry": "oklyJ`{ph@yBuY_F{^_FxJoBrBs@d@mATlAUr@e@nBsB~EyJ~Ez^xBtY"
}
]
}
On error, the server responds with different HTTP status codes. For responses with HTTP status codes lower than 500, the JSON response body includes the code property, which may be used by client programs to manage control flow. The response body may also include a message property, with a human-readable explanation of the error.
If a server error occurs, the HTTP status code will be 500 or higher and the response will not include a code property.
Response body
code |
HTTP status code | comment |
|---|---|---|
Ok |
200 |
Normal success case |
NoTrips |
200 |
For one coordinate no route to other coordinates could be found. Check for impossible routes (e.g. routes over oceans without ferry connections). |
NotImplemented |
200 |
For the given combination of
source
,
destination
and
roundtrip
, this request is not supported. |
ProfileNotFound |
404 |
Use a valid profile as described above |
InvalidInput |
422 |
The given request was not valid. The
message
key of the response will hold an explanation of the invalid input. |
All other properties might be undefined.
An access token, referred to hereafter as 'token', grants access to Mapbox resources on behalf of a user. All accounts have a public token by default. Additional tokens can be created to grant additional, or more limited, privileges.
To create additional tokens using this API you will first need to create an initial token. This initial token must contain the tokens:write scope and all scopes you want to add to the created token. To create the initial token visit your Mapbox Studio API access tokens page, and click Create a new token.
Mapbox uses JSON Web Tokens (JWT) as the token format. Each token is a string delimited by dots into three parts: header, payload, and signature.
The header is a literal value of either pk (public token), sk (secret token), or tk (temporary token).
The payload is a base64-encoded JSON object containing the identity and authorities of the token. pk and sk tokens contain a reference to an authorization which holds the rights granted for the token. tk tokens contain the content of the authorization directly in the payload.
The signature is signed by Mapbox and used to verify the token has not been tampered with.
The actions allowed by a token are based on scopes. A scope is a string that often is a resource type and action separated by a colon. For example, the styles:read scope allows read access to styles. Tokens will have access to different scopes depending on their account level and other features of their account.
An authorization contains information about the capabilities of a token. Each authorization contains the following properties:
| Property | Description |
|---|---|
id |
the identifier for the authorization |
usage |
the type of authorization |
client |
the client for the authorization, always 'api' |
default |
if the token is a default token |
scopes |
array of scopes the authorization grants |
note |
human friendly description of the authorization |
created |
date and time the authorization was created |
modified |
date and time the authorization was last modified |
token |
the token representing the authorization |
Limits
{
"id": "cijucimbe000brbkt48d0dhcx",
"usage": "pk",
"client": "api",
"default": false,
"note": "My website",
"scopes": ["styles:read", "fonts:read"],
"created": "2016-01-25T19:07:07.621Z",
"modified": "2016-01-26T00:39:57.941Z",
"token": "pk.eyJ1Ijoic2NvdGhpcyIsImEiOiJjaWp1Y2ltYmUwMDBicmJrdDQ4ZDBkaGN4In0.sbihZCZJ56-fsFNKHXF8YQ"
}
Lists all tokens for an account.
This endpoint supports pagination.
Note: The token property will not be included for sk tokens.
curl "https://api.mapbox.com/tokens/v2/{username}?access_token="
[
{
"client": "api",
"note": "a public token",
"usage": "pk",
"id": "cijucimbe000brbkt48d0dhcx",
"default": false, "scopes": ["styles:read", "fonts:read"],
"created": "2016-01-25T19:07:07.621Z",
"modified":"2016-01-26T00:39:57.941Z",
"token": "pk.eyJ1Ijoic2NvdGhpcyIsImEiOiJjaWp1Y2ltYmUwMDBicmJrdDQ4ZDBkaGN4In0.sbihZCZJ56-fsFNKHXF8YQ"
},
{
"client": "api",
"note": "a secret token",
"usage": "sk",
"id": "cijuorumy001cutm5r4fl2y1b",
"default": false,
"scopes": ["styles:list"],
"created": "2016-01-26T00:50:13.701Z",
"modified": "2016-01-26T00:50:13.701Z"
}
]
Creates a new token.
Every requested scope must be present in the access token? used to allow the request. It is not possible to create a token with access to more scopes than the token that created it.
The scopes included in the token decide whether the token is public or secret. A public token may only contains public scopes.
curl -X POST "https://api.mapbox.com/tokens/v2/{username}?access_token="
{
"scopes": ["styles:read", "fonts:read"],
"note": "My top secret project"
}
{
"client": "api",
"note": "My top secret project",
"usage": "pk",
"id": "cijucimbe000brbkt48d0dhcx",
"default": false,
"scopes": ["styles:read", "fonts:read"],
"created": "2016-01-25T19:07:07.621Z",
"modified":"2016-01-25T19:07:07.621Z",
"token": "pk.eyJ1Ijoic2NvdGhpcyIsImEiOiJjaWp1Y2ltYmUwMDBicmJrdDQ4ZDBkaGN4In0.sbihZCZJ56-fsFNKHXF8YQ"
}
Creates a new temporary token that automatically expires at a fixed time.
The expires property for a temporary token cannot be in the past or more than 1 hour in the future. If the authorizing token is temporary, the expires cannot be later than that of the authorizing token.
Every requested scope must be present in the authorizing token used to allow the request. It is not possible to create a token with access to more scopes than the token that created it.
Unlike public and secret tokens, a temporary token contains the authorization inside the payload of the token instead of referencing an authorization persisted on the server. Temporary tokens cannot be updated or revoked after they are created.
curl -X POST "https://api.mapbox.com/tokens/v2/{username}?access_token="
{
"expires": "2016-09-15T19:27:53.000Z",
"scopes": ["styles:read", "fonts:read"]
}
{
"token": "tk.eyJ1IjoibWFwYm94IiwiZXhwIjoxNDczOTY3NjczLCJpYXQiOjE0NzM5Njc2NDMsInNjb3BlcyI6WyJzdHlsZXM6cmVhZCIsImZvbnRzOnJlYWQiXSwiY2xpZW50IjoiYXBpIn0.ZepsWvpjTMlpePE4IQBs0g"
}
Update the authorization's note or scopes.
A public, pk, token may only be updated to include other public scopes. A secret, sk, token may be updated to contain public and secret scopes.
When updating scopes for an existing token, the token sent along with the request must also have the scopes you're requesting. It is not possible to create a token with access to more scopes than the token that updated it.
curl -X PATCH "https://api.mapbox.com/tokens/v2/{username}/{authorization_id}?access_token="
{
"scopes": ["styles:tiles", "styles:read", "fonts:read"]
}
{
"client": "api",
"note": "My top secret project",
"usage": "pk",
"id": "cijucimbe000brbkt48d0dhcx",
"default": false,
"scopes": ["styles:tiles", "styles:read", "fonts:read"],
"created": "2016-01-25T19:07:07.621Z",
"modified":"2016-01-25T19:07:07.621Z",
"token": "pk.eyJ1Ijoic2NvdGhpcyIsImEiOiJjaWp1Y2ltYmUwMDBicmJrdDQ4ZDBkaGN4In0.sbihZCZJ56-fsFNKHXF8YQ"
}
Revoke an authorization, removing access to Mapbox APIs. This is the same as deleting a token. Applications using the revoked token will need to get a new access token? before they can access Mapbox APIs.
Note: Cached resources may continue to be accessible for a short period after a token is revoked. No new or updated resources will be accessible with the revoked token.
curl -X DELETE "https://api.mapbox.com/tokens/v2/{username}/{authorization_id}?access_token="
HTTP 204
Check if a token is valid. If the token is invalid an explanation of why is returned as the code property.
The body of the token is parsed and included as the token property in object form.
| Code | Description |
|---|---|
TokenValid |
the token is valid and active |
TokenMalformed |
the token can not be parsed |
TokenInvalid |
the signature for the token does not validate |
TokenExpired |
the token was temporary and expired |
TokenRevoked |
the authorization associated with the token has been deleted |
$ curl "https://api.mapbox.com/tokens/v2?access_token="
{
"code": "TokenValid",
"token": {
"usage": "pk",
"user": "mapbox",
"authorization": "cijucimbe000brbkt48d0dhcx"
}
}
{
"code": "TokenExpired",
"token": {
"usage": "tk",
"user": "mapbox",
"expires": "2016-09-15T19:27:53.000Z",
"created": "2016-09-15T19:27:23.000Z",
"scopes": ["styles:read", "fonts:read"],
"client": "api"
}
}
List scopes for a user. All potential scopes a user has access to are listed.
Public tokens may only contain scopes with the public property set to true. Secret tokens may contain any scope.
| Property | Description |
|---|---|
id |
identifier of the scope |
description |
human friendly description of the scope |
public |
true
if the scope is available for public tokens |
$ curl "https://api.mapbox.com/scopes/v1/{username}?access_token="
[
{
"id": "scopes:list",
"description": "List all available scopes."
},
{
"id": "styles:read",
"public": true,
"description": "Read styles."
}
]
Returns the request counts per day for given resource and period.
{resourceType} is tokens, the {id} is the complete token.{resourceType} is styles, the {id} is the Style ID. Not to be confused with the Style URL, the id is the alphanumeric segment at the end of the style: the Style URL mapbox://styles/user/cimdoca6f00 contains the Style ID cimdoca6f00, so the analytics request would have the path /analytics/v1/styles/user/cimdoca6f00.{resourceType} is tilesets, the {id} is a Map ID.| URL Parameter | Description |
|---|---|
resourceType |
The resource being requested. Valid resource types are
accounts
,
tokens
,
tilesets
or
styles
. |
username |
The username for the account that owns the resource. |
id
(optional) |
The id for the resource. In the case of
accounts
this isn't required. |
period
(optional) |
2 comma separated dates as ISO formatted strings . The first date must be earlier than the second. The period is inclusive of dates provided. Defaults to last 90 days if not provided. The maximum period is 1 year. If the provided dates are more than 1 year apart, an error will be returned. |
Responses include arrays of request counts per service.
| Property | Description |
|---|---|
timestamps |
an array of dates as ISO formatted strings for each day included in the response. |
period |
a 2 element array with start and end dates as ISO formatted strings for the response period. |
services |
an object with a key per service the value of which is an array of request counts per day in the same sequence as
timestamps
. |
Only services applicable to the given resource are returned in the response.
| Resource type | Services returned in response |
|---|---|
accounts |
mapview
static
tile
directions
geocode |
tokens |
mapview
static
tile
directions
geocode |
tilesets |
mapview
static
tile |
styles |
mapview
static
tile |
For the styles resource type, Static & Tile services refer to the Static API. For tilesets, Static & Tile services refer to the Static (Classic) and Maps → Tiles APIs.
curl "https://api.mapbox.com/analytics/v1/tilesets/mapbox/mapbox.streets?period=2016-03-22T00:00:00.000Z,2016-03-24T00:00:00.000Z&access_token="
{
"period": ["2016-03-22T00:00:00.000Z", "2016-03-24T00:00:00.000Z"],
"timestamps": ["2016-03-22T00:00:00.000Z", "2016-03-23T00:00:00.000Z", "2016-03-24T00:00:00.000Z"],
"services": {
"mapview": [ 25, 22, 37 ],
"static": [ 23, 20, 34 ],
"tiles": [ 30, 39, 53 ]
}
}