メインコンテンツまでスキップ
For the complete documentation index, see llms.txt.

Interlaken API

Public Beta for the Interlaken API

The Interlaken API is in public beta. The API may change before general availability.

The Interlaken API stores your geospatial data in Mapbox Interlaken Database as datasources and lets you query that data. A datasource holds a collection of geospatial features. Every upload to a datasource creates a new, immutable version.

Use the datasource endpoints to create datasources, upload data, and manage branches. Use the query endpoint to find the features in a datasource that meet a spatial condition, such as inside a bounding box or within a distance of a point, and optionally a filter on their properties.

Datasources are also the inputs for the Mapbox Tiling Service v2.

Create a datasource​

post
https://api.mapbox.com/db/v1/datasources/{owner}/{id}
datasources:write

Creates an empty datasource. You can upload data to it once it exists. Creating a datasource that already exists returns an HTTP 409 Conflict error.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that will own the datasource.
idstringThe ID of the datasource to create. Up to 64 characters. The only allowed characters are letters, numbers, -, and _.
access_tokenstringA valid Mapbox access token with the datasources:write scope.

The request body is optional. When you send one, it must be a JSON object with any of the following properties:

Optional body propertiesTypeDescription
display_namestringA human-readable name for the datasource, from 1 to 255 characters. You can change it later with the Update datasource properties endpoint.
fieldsarray of objectsProperty columns to define up front, each with a name and a type. See Fields.
detail_strategyobjectRules that set the zoom levels at which features appear. Can't be changed after the datasource is created. See Detail strategy.

Fields​

Use fields to declare typed property columns before you upload data. Each entry has the following properties:

PropertyTypeDescription
namestringThe name of the feature property.
typestringThe property's data type. One of boolean, double, long, string, list<boolean>, list<double>, list<long>, or list<string>. A list<...> type is a single-level list of that type.

Example request: Create a datasource​

# Create an empty datasource with no optional properties
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN"

# Create a datasource with a display name, fields, and a detail strategy
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"display_name": "Street trees",
"fields": [
{ "name": "species", "type": "string" },
{ "name": "height", "type": "double" },
{ "name": "heritage", "type": "boolean" },
{ "name": "min_zoom", "type": "long" }
],
"detail_strategy": {
"rules": [
{ "when": "min_zoom IS NOT NULL", "minzoom": { "field": "min_zoom" } },
{ "when": "heritage = true", "minzoom": 10 },
{ "when": "height >= 20", "minzoom": 13 }
],
"default": { "minzoom": 15 }
}
}'

Response: Create a datasource​

If the request is successful, the response has an HTTP 201 Created status and contains the following properties:

PropertyTypeDescription
idstringThe ID of the datasource.
ownerstringThe account that owns the datasource.
display_namestringThe datasource's display name, if you set one.

Example response: Create a datasource​

{
"id": "trees",
"owner": "username",
"display_name": "Street trees"
}

Upload files to a datasource​

Each upload adds data to a datasource branch and, once processed, creates a new version that the branch points at. There are two ways to upload a file:

  • In a single request (type=singlepart, the default), for files up to 300 MB.
  • In parts (type=multipart), for files larger than 300 MB or when you want to attach metadata to the new version.

The following table compares them:

SinglepartMultipart
File sizeUp to 300 MBUp to 1 GB in total
RequestsOne request that sends the whole fileStart the upload, send the file in parts, then commit it
Version metadataNot supportedOptional, sent with the commit

Both kinds of upload accept GeoJSON, line-delimited GeoJSON, and other common geospatial formats. See Supported file formats.

All uploads are processed asynchronously. The request that queues a file for processing (the singlepart upload request, or the multipart commit request) returns an HTTP 202 Accepted status as soon as the file is queued, with an upload_id. To find out when processing finishes, poll the upload status endpoint with that upload_id until status is completed, failed, or retry.

When you start an upload, you can use the following optional query parameters:

Optional parametersTypeDefaultDescription
typestringsinglepartThe kind of upload: singlepart or multipart.
operationstringappendWhat to do with the data. append adds the uploaded features to the branch. overwrite replaces everything on the branch with the uploaded features.
branchstringmainThe branch to write to. Branch names are 1 to 64 lowercase letters, numbers, -, and _, with at least one character that isn't a number. Create the branch with the Create or update a branch endpoint before you upload to it.
basestringThe version the branch points atThe version to build on. Can't be combined with operation=overwrite.

Upload a file in a single request​

post
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/uploads
datasources:write

This is the default kind of upload (type=singlepart). Send the whole file as the body of the request. The file must be 300 MB or smaller. There is no separate commit step: the request queues the file for processing. Because of this, you can't attach metadata to the version a singlepart upload creates. To attach metadata, use a multipart upload and send it when you commit the upload.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource to upload to.
access_tokenstringA valid Mapbox access token with the datasources:write scope.

Example request: Upload a file in a single request​

$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @trees.geojson

Response: Upload a file in a single request​

If the file is queued for processing, the response has an HTTP 202 Accepted status and contains the following properties. Poll the upload status endpoint with the upload_id to find out when processing finishes.

PropertyTypeDescription
upload_idstringThe ID of the upload. Use it to check the upload status.
ownerstringThe account that owns the datasource.
idstringThe ID of the datasource.
upload_typestringsinglepart.
operationstringThe operation you requested: append or overwrite.
branchstringThe branch the upload writes to.
statusstringcommitted: the file is queued for processing. See upload statuses.
Example response: Upload a file in a single request​
{
"owner": "username",
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"id": "trees",
"upload_type": "singlepart",
"operation": "append",
"branch": "main",
"status": "committed"
}

Upload a file in parts​

For files larger than 300 MB, or to attach metadata to the new version, set type=multipart. A multipart upload sends a file in parts across several requests, then commits them. The total size of all parts can be up to 1 GB.

Step 1: Start a multipart upload​

post
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/uploads?type=multipart
datasources:write

Starts a multipart upload and returns its upload_id. Send this request without a body.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource to upload to.
typestringmultipart.
access_tokenstringA valid Mapbox access token with the datasources:write scope.
Example request: Start a multipart upload​
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads?type=multipart&access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN"
Response: Start a multipart upload​

If the request is successful, the response has an HTTP 200 OK status and contains the following properties:

PropertyTypeDescription
upload_idstringThe ID of the upload. Use it in the next two steps.
ownerstringThe account that owns the datasource.
idstringThe ID of the datasource.
upload_typestringmultipart.
branchstringThe branch the upload writes to.
Example response: Start a multipart upload​
{
"owner": "username",
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"id": "trees",
"upload_type": "multipart",
"branch": "main"
}

Step 2: Upload each part​

post
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/uploads/{upload_id}
datasources:write

Sends one part of the file as the request body. Each part must have a Content-Length header, and every part except the last must be at least 5 MiB (5,242,880 bytes).

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource.
upload_idstringThe upload_id from Step 1.
access_tokenstringA valid Mapbox access token with the datasources:write scope.

The first part is checked to make sure it is a supported file format. If it isn't, the request fails with an HTTP 422 Unprocessable Entity error.

Example request: Upload each part​
# Split the file into 100 MB parts, then send them in order
$split -b 100m trees.geojson trees-part-
$for part in trees-part-*; do
curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads/3fa85f64-5717-4562-b3fc-2c963f66afa6?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$part"
done
Response: Upload each part​

If the part is accepted, the response has an HTTP 200 OK status and contains the upload_id, owner, and id of the upload.

Example response: Upload each part​
{
"owner": "username",
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"id": "trees"
}

Step 3: Commit the upload​

post
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/uploads/{upload_id}/commit
datasources:write

Joins the uploaded parts and queues the file for processing. After you commit an upload, you can't add more parts to it.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource.
upload_idstringThe upload_id from Step 1.
access_tokenstringA valid Mapbox access token with the datasources:write scope.

The request body is optional. When you send one, it must be a JSON object with a Content-Type: application/json header, and can contain the following property:

Optional body propertiesTypeDescription
metadataobjectYour own JSON metadata for the version this upload creates, up to 16 KB and 32 levels deep. If you leave it out, the previous version's metadata is carried forward. If you send it, it replaces the previous metadata.
Example request: Commit the upload​
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads/3fa85f64-5717-4562-b3fc-2c963f66afa6/commit?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "metadata": { "source": "city-open-data", "exported": "2026-11-01" } }'
Response: Commit the upload​

If the commit is accepted, the file is queued for processing and the response has an HTTP 202 Accepted status and a status of committed. Poll the upload status endpoint with the upload_id to find out when processing finishes.

Example response: Commit the upload​
{
"owner": "username",
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"id": "trees",
"status": "committed",
"total_chunks": 1,
"ingested_chunks": 0
}

Retrieve upload status​

get
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/uploads/{upload_id}
datasources:read

Returns the current state of an upload. Because uploads are processed asynchronously, poll this endpoint after you upload a file, waiting a few seconds between requests, until status is completed, failed, or retry. When status is completed, version is the new version and the branch points at it.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource.
upload_idstringThe ID of the upload, returned when you started it.
access_tokenstringA valid Mapbox access token with the datasources:read scope.

Example request: Retrieve upload status​

$curl "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads/3fa85f64-5717-4562-b3fc-2c963f66afa6?access_token=YOUR_MAPBOX_ACCESS_TOKEN"

Response: Retrieve upload status​

If the request is successful, the response contains the following properties:

PropertyTypeDescription
upload_idstringThe ID of the upload.
ownerstringThe account that owns the datasource.
idstringThe ID of the datasource.
upload_typestringsinglepart or multipart.
operationstringThe operation you requested when you started the upload.
branchstringThe branch the upload writes to.
statusstringThe upload's status. See upload statuses.
versionstringThe version the upload created. Only present when status is completed.
total_chunksintegerThe number of chunks to process.
ingested_chunksintegerThe number of chunks processed so far.
created_atstringWhen the upload started, as an ISO 8601 timestamp.
updated_atstringWhen the upload's status last changed, as an ISO 8601 timestamp.
errorstringA description of what went wrong. Only present when status is failed or retry.

Upload statuses​

StatusDescription
processingA multipart upload has started and is receiving parts.
committedThe file is queued or being processed.
completedProcessing finished. version is the new version, and the branch now points at it.
failedProcessing failed and won't succeed if you try again with the same file. Check error for the reason.
retryProcessing failed because of a temporary problem. The upload isn't retried automatically; upload the file again.

Example response: Retrieve upload status​

{
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"owner": "username",
"id": "trees",
"upload_type": "multipart",
"operation": "append",
"branch": "main",
"status": "completed",
"version": "799472732836488995",
"total_chunks": 1,
"ingested_chunks": 1,
"created_at": "2026-11-04T18:40:11.362Z",
"updated_at": "2026-11-04T18:42:30.118Z"
}

List datasources​

get
https://api.mapbox.com/db/v1/datasources/{owner}
datasources:list

Lists the datasources that belong to an account. An account with no datasources returns an empty list. Results are returned in pages; see Pagination.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account whose datasources to list.
access_tokenstringA valid Mapbox access token with the datasources:list scope.
Optional parametersTypeDefaultDescription
limitinteger100The maximum number of datasources to return, from 1 to 500.
startstringNone (first page)The cursor for the next page of results, taken from the Link header of the previous response. See Pagination.

Example request: List datasources​

$curl "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME?limit=25&access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN"

Response: List datasources​

If the request is successful, the response contains a datasources array. Results are in a consistent but unspecified order. Each datasource in the array has the following properties:

PropertyTypeDescription
ownerstringThe account that owns the datasource.
idstringThe ID of the datasource.

To get a datasource's display name and branches, retrieve the datasource.

Example response: List datasources​

{
"datasources": [
{ "owner": "username", "id": "parcels" },
{ "owner": "username", "id": "trees" }
]
}

Pagination​

Results are returned in pages. When more results are available, the response includes a Link header with a URL for the next page:

Link: <https://api.mapbox.com/db/v1/datasources/username?limit=25&start=eyJrIjoidHJlZXMifQ&access_token=YOUR_MAPBOX_ACCESS_TOKEN>; rel="next"

To get every datasource, request the rel="next" URL from each response until a response has no Link header.

  • Treat the start value as opaque. Don't build, change, or store it.
  • start values expire after a short time. If you send one that has expired or is malformed, the response is an HTTP 400 Bad Request error with the message Invalid start. Start again from the first page.
  • Datasources created or deleted while you page through the results aren't guaranteed to appear in the results.

Retrieve a datasource​

get
https://api.mapbox.com/db/v1/datasources/{owner}/{id}
datasources:read

Returns a datasource's display name, first version, and branches. Use it to find the version each branch points at.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource.
access_tokenstringA valid Mapbox access token with the datasources:read scope.

Example request: Retrieve a datasource​

$curl "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees?access_token=YOUR_MAPBOX_ACCESS_TOKEN"

Response: Retrieve a datasource​

If the request is successful, the response contains the following properties:

PropertyTypeDescription
ownerstringThe account that owns the datasource.
idstringThe ID of the datasource.
display_namestringThe datasource's display name, or null if it doesn't have one.
initial_versionstringThe first version created in the datasource. null until the datasource ingest completes
branchesarray of objectsThe datasource's branches. Each has a name and the version it points at.

Example response: Retrieve a datasource​

{
"owner": "username",
"id": "trees",
"display_name": "Street trees",
"initial_version": "799472732836488995",
"branches": [
{ "name": "main", "version": "812094471182364207" },
{ "name": "staging", "version": "825317690124553810" }
]
}

Update datasource properties​

put
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/properties
datasources:write

Updates properties that apply to the whole datasource rather than to one version. The only property you can update is display_name. Updating it doesn't create a new version.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource.
access_tokenstringA valid Mapbox access token with the datasources:write scope.

The request body must be a JSON object with the following property:

Body propertiesTypeDescription
display_namestring or nullRequired. The new display name, from 1 to 255 characters. Set it to null to remove the display name.

Example request: Update datasource properties​

$curl -X PUT "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/properties?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "display_name": "Street trees 2026" }'

Response: Update datasource properties​

If the request is successful, the response contains the following properties:

PropertyTypeDescription
idstringThe ID of the datasource.
ownerstringThe account that owns the datasource.
display_namestringThe datasource's display name after the update, or null if removed.

Example response: Update datasource properties​

{
"id": "trees",
"owner": "username",
"display_name": "Street trees 2026"
}

Retrieve a datasource version​

get
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/versions/{version}
datasources:read

Returns details about one version of a datasource: how many features it has, their geometry types and bounding box, statistics for each property, and the metadata you attached when you uploaded it.

version must be a numeric version ID. Branch names aren't accepted and return HTTP 404 Not Found. To find the version a branch points at, retrieve the datasource and read branches.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource.
versionstringThe numeric ID of the version, such as 799472732836488995.
access_tokenstringA valid Mapbox access token with the datasources:read scope.

Example request: Retrieve a datasource version​

$curl "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/versions/812094471182364207?access_token=YOUR_MAPBOX_ACCESS_TOKEN"

Response: Retrieve a datasource version​

If the request is successful, the response contains the following properties. Statistics that aren't available are null.

PropertyTypeDescription
idstringThe ID of the datasource.
ownerstringThe account that owns the datasource.
display_namestringThe datasource's display name, or null.
versionstringThe ID of the version.
parent_versionstringThe previous version that this version builds on, or null if there is none.
created_atstringWhen the version was created, as an ISO 8601 timestamp in UTC.
feature_countintegerThe number of features in the version.
total_sizeintegerThe total size of the version, in bytes.
bboxarray of numbersThe bounding box of the version's features, as [west, south, east, north].
geometry_typesobjectThe number of features of each geometry type, keyed by GeoJSON type such as Point or MultiPolygon.
fieldsarray of objectsThe feature properties in the version. Each has a name and a type, and may include statistics: null_count, min, max, the most common values, and typical_length for text.
user_metadataobjectThe metadata you sent when you committed the upload that created this version, or carried forward from an earlier version.
memostringA memo recorded with the version, or null.
detail_strategyobjectThe datasource's detail strategy, or null if it doesn't have one. Every zoom level is filled in, and a maxzoom of 255 means no limit.

Example response: Retrieve a datasource version​

{
"id": "trees",
"owner": "username",
"display_name": "Street trees",
"version": "812094471182364207",
"parent_version": "799472732836488995",
"created_at": "2026-11-04T18:42:30Z",
"feature_count": 52418,
"total_size": 9842113,
"bbox": [-122.5149, 37.7081, -122.357, 37.8324],
"geometry_types": { "Point": 52418 },
"fields": [
{
"name": "species",
"type": "string",
"null_count": 0,
"values": ["oak", "maple", "sycamore"],
"values_truncated": true,
"typical_length": 6
},
{ "name": "height", "type": "double", "null_count": 112, "min": 1.5, "max": 38.2 }
],
"user_metadata": { "source": "city-open-data", "exported": "2026-11-01" },
"memo": null,
"detail_strategy": {
"rules": [
{ "when": "min_zoom IS NOT NULL", "minzoom": { "field": "min_zoom" }, "maxzoom": 255 },
{ "when": "heritage = true", "minzoom": 10, "maxzoom": 255 },
{ "when": "height >= 20", "minzoom": 13, "maxzoom": 255 }
],
"default": { "minzoom": 15, "maxzoom": 255 }
}
}

Create or update a branch​

put
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/branches/{branch}
datasources:write
Advanced feature

Most workflows don't need to manage branches directly: uploads write to main, and main moves to each new version automatically. Use this endpoint when you need more control, such as staging changes before they reach main or rolling back to an earlier version. Moving a branch changes the data that every tileset referencing it uses the next time that tileset is published.

Points a branch at a version. If the branch doesn't exist, it is created. If it exists, it moves to the version you choose. Sending the same request again has no further effect.

Use this endpoint to:

  • Promote changes: create a staging branch with this endpoint, upload to it, check the result in a tileset that uses the staging branch, then point main at the same version.
  • Roll back: point main at an earlier version, such as the version main pointed at before a bad upload.
  • Keep a stable reference: create a branch such as release-2026-11 that stays on a version while main moves on.
Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource.
branchstringThe branch name. 1 to 64 lowercase letters, numbers, -, and _, with at least one character that isn't a number.
access_tokenstringA valid Mapbox access token with the datasources:write scope.

The request body must be a JSON object with the following property:

Body propertiesTypeDescription
versionstringRequired. The numeric ID of the version to point the branch at. To use the version another branch points at, retrieve the datasource first.

Example request: Create or update a branch​

# Promote the version on the staging branch to main
$curl -X PUT "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/branches/main?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "version": "825317690124553810" }'

Response: Create or update a branch​

If the request is successful, the response contains the following properties:

PropertyTypeDescription
ownerstringThe account that owns the datasource.
idstringThe ID of the datasource.
branchstringThe name of the branch.
versionstringThe version the branch now points at.

If the datasource or the version doesn't exist, the response has an HTTP 404 Not Found status.

Example response: Create or update a branch​

{
"owner": "username",
"id": "trees",
"branch": "main",
"version": "825317690124553810"
}

Delete a branch​

delete
https://api.mapbox.com/db/v1/datasources/{owner}/{id}/branches/{branch}
datasources:write

Deletes a branch. The main branch can't be deleted, and trying returns an HTTP 409 Conflict error.

Required parametersTypeDescription
ownerstringThe Mapbox username of the account that owns the datasource.
idstringThe ID of the datasource.
branchstringThe name of the branch to delete.
access_tokenstringA valid Mapbox access token with the datasources:write scope.

Example request: Delete a branch​

$curl -X DELETE "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/branches/staging?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN"

Response: Delete a branch​

If the branch is deleted, the response has an HTTP 204 No Content status and no body.

Supported file formats​

Each upload is one file. You don't need to tell the API the file's format: it's detected from the file's contents. Coordinates must be longitude and latitude in WGS84 (EPSG:4326).

FormatNotes
GeoJSONA FeatureCollection or a single Feature. Property values and feature IDs keep their JSON types. A crs member, if present, must name WGS84.
Line-delimited GeoJSONOne GeoJSON feature per line.
GeoJSON text sequencesGeoJSON features separated by record separator characters (RFC 8142).
TopoJSON
FlatGeobuf
KMLAn uncompressed .kml file.
GPX

If your data is in another format, such as a Shapefile, GeoPackage, CSV, or GeoParquet, convert it to GeoJSON before you upload it. You can use the GDAL command-line tool ogr2ogr, which can also convert the coordinates to WGS84:

$ogr2ogr -f GeoJSON -t_srs EPSG:4326 output.geojson input.shp

Query a datasource​

post
https://api.mapbox.com/db/v1/spatialquery
datasources:read

Returns the features that match the query document in the request body.

Required parametersTypeDescription
access_tokenstringA valid Mapbox access token with the datasources:read scope, from the account that owns the datasource.
Optional parametersTypeDescription
continuestringThe _mbx.continue token from the previous response. Send it with the same query document to get the next page. See Paging.

You can query a datasource created with the datasource endpoints on this page or uploaded with the Data Workbench. To get the ID of data uploaded with the Data Workbench, open it and click Copy ID next to its name.

Query document​

The request body is a JSON query document.

PropertyTypeDescription
datasourceobjectRequired. The datasource to query, as {"id": "..."}. Add version to query a specific version. Without it, the API queries the current version.
spatialobjectRequired. Where to look, as exactly one spatial operator.
filterarrayWhich features to keep, as a filter expression.
resultobjectWhat to return. See Results. Defaults to matching features.

Coordinates are [longitude, latitude] in WGS84 degrees, as in GeoJSON.

Spatial operators​

OperatorTypeDescription
bboxarrayFeatures touching the box [west, south, east, north]. To search a whole datasource, use [-180, -90, 180, 90]. A box whose west is greater than its east crosses the antimeridian.
intersectsobjectFeatures touching geometry, boundaries included.
coversobjectFeatures that completely contain geometry.
covered_byobjectFeatures completely inside geometry.
within_distanceobjectFeatures within distance of geometry, closest first. unit is m, km, ft, or mi. The distance can be at most 50 km. Each feature returns its distance in _mbx.distance.

Every operator but bbox takes an object with a geometry:

"spatial": { "intersects": { "geometry": { "type": "Point", "coordinates": [-122.4194, 37.7749] } } }

geometry is a GeoJSON Point, LineString, Polygon, or Multi* geometry, or a Feature that holds one, with at most 10,000 positions. Split a geometry that crosses the antimeridian at ±180°.

Filters​

A filter is a Mapbox expression over the datasource's string, number, and boolean properties.

ExpressionExampleMatches features where
== != < <= > >=["==", ["get", "category"], "park"]The comparison is true.
in, with a list["in", ["get", "category"], ["literal", ["park", "cafe"]]]The property is one of the values.
in, with text["in", "coffee", ["get", "name"]]The property contains the text, ignoring case.
has["has", "name"]The property has a value other than null.
geometry-type["==", ["geometry-type"], "Polygon"]The geometry is that type. Polygon also matches MultiPolygon.
all any !["all", <filter>, <filter>]all: every filter matches. any: at least one does. !: the filter doesn't.

!=, and a == or in inside !, also match features that don't have the property. <, <=, >, and >= never match them, even inside !. A filter can nest 32 levels deep and hold at most 1,000 conditions and 1,000 in values.

Results​

PropertyTypeDescription
selectarrayThe properties to return. Defaults to all properties. The feature id is always returned.
geometrystringfull (default) returns the stored geometry, bbox_center the center point of its bounding box, and none no geometry.
limitintegerThe most features one response returns, from 1 to 1000. Defaults to 100.

Paging​

While a response includes _mbx.continue, more features may match. To get the next page, send the same query document with that token as the continue parameter. A page can hold fewer than limit features, or none, before the last one. The results end at the first response without _mbx.continue. Paging returns each match exactly once, in no particular order. The token can expire.

A query without a version pins the version that answered its first page, so later pages read the same data even if the datasource changes.

within_distance doesn't page and doesn't accept continue. It returns the limit closest features, and sets _mbx.complete to false if more were in range.

Find property names​

A filter or select that names a property the datasource doesn't have returns a 400 error. Its errors[].valid lists the properties the datasource has, and errors[].suggestion the closest match.

Example requests: Query a datasource​

# Find the parks in a bounding box, with only their names and categories
$curl -X POST "https://api.mapbox.com/db/v1/spatialquery?access_token=YOUR_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"datasource": { "id": "my-datasource" },
"spatial": { "bbox": [-122.45, 37.75, -122.4, 37.8] },
"filter": ["==", ["get", "category"], "park"],
"result": { "select": ["name", "category"] }
}'

# Find the 2 cafes closest to a point, within 1 km
$curl -X POST "https://api.mapbox.com/db/v1/spatialquery?access_token=YOUR_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"datasource": { "id": "my-datasource" },
"spatial": { "within_distance": { "geometry": { "type": "Point", "coordinates": [-122.4194, 37.7749] }, "distance": 1, "unit": "km" } },
"filter": ["==", ["get", "category"], "cafe"],
"result": { "limit": 2 }
}'

Response: Query a datasource​

Results are a GeoJSON FeatureCollection (application/geo+json):

PropertyTypeDescription
featuresarrayThe matching features. Each has an id, a geometry, and properties.
features[]._mbx.distancenumberFor within_distance. The feature's distance from the query geometry, in the request's unit.
_mbx.completebooleanfalse when more features may match.
_mbx.continuestringPresent while more features may match. See Paging.
_mbx.versionstringThe datasource version the API queried.
_mbx.distance_cutoffnumberFor an incomplete within_distance result. The distance of the furthest feature returned. Features tied at exactly this distance may be missing.

Example response: Query a datasource​

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "4f9c2a51-7d3e-5b8a-9c1f-2e6d8a0b4c37",
"geometry": { "type": "Point", "coordinates": [-122.4346, 37.7764] },
"properties": { "name": "Alamo Square", "category": "park" }
},
{
"type": "Feature",
"id": "b2e81c94-3a6f-5d07-8e2b-91c4f7a3d560",
"geometry": { "type": "Point", "coordinates": [-122.4335, 37.7692] },
"properties": { "name": "Duboce Park", "category": "park" }
}
],
"_mbx": {
"complete": false,
"version": "8094315265395412347",
"continue": "AhQQrcfad1rRr3WAb_s7IHjdI7Li3sbJMOukY06PEQxRho1h"
}
}

Interlaken API errors​

The datasource endpoints and the query endpoint return errors in different formats.

Datasource endpoint errors​

Error responses contain a message property describing the problem. Errors with a status of 500 or higher always have the message Internal Server Error.

HTTP status codeResponse body messageDescription
400VariesA parameter or the request body is invalid, such as an ID that is too long, a branch name with uppercase letters, or base combined with operation=overwrite. The message describes the problem.
400Request body is empty; singlepart uploads send the file with this requestThe singlepart upload request didn't include a file.
400Content-Length header is required for multipart uploadsThe request for a multipart part didn't include a Content-Length header.
400Invalid startThe start cursor has expired or is malformed. See Pagination.
401Not Authorized - No TokenNo access token was used in the request.
401Not Authorized - Invalid TokenCheck the access token you used in the request.
403This API requires a token with {scope} scope.The access token needs the specified scope.
403ForbiddenThe access token belongs to a different account than owner. You can only access datasources that your account owns.
404VariesThe datasource, version, or branch doesn't exist.
404Upload not found: {upload_id}The upload doesn't exist, or belongs to a different datasource.
409VariesA datasource with this ID already exists.
409The 'main' branch cannot be deletedYou tried to delete the main branch.
409Upload {upload_id} has already been committedThe multipart upload was already committed. You can't add parts to it or commit it again.
409Singlepart uploads are committed when they are createdYou tried to commit a singlepart upload. Singlepart uploads don't need a commit.
409No parts uploaded for upload {upload_id}. Upload parts before committing.You tried to commit a multipart upload before sending any parts.
409Upload {upload_id} has permanently failed: {error}The upload failed and can't be continued. Start a new upload.
415Commit request body must be sent with Content-Type: application/json.A commit request had a body without a Content-Type: application/json header.
422Varies, such as Unsupported file format: a bare shapefile componentThe file isn't in a supported format.
429Too Many RequestsYou have exceeded the rate limit.
500Internal Server ErrorSomething went wrong on the server. Try again later.
504Internal Server ErrorThe request took too long. Retry a read request later. A write request that times out can still take effect, so check the result before you retry it, for example with the upload status endpoint or by retrieving the datasource.

Query endpoint errors​

Errors are RFC 9457 Problem Details with a detail message, retryable, and an errors list. One response reports every problem in the query document, up to 100, and detail gives the total when there are several. Each problem has a stable code and a detail. Where they apply, it also has:

  • at: the invalid field.
  • received: the value sent. The API shortens a long value and sets received_truncated to true.
  • suggestion: the closest valid value.
  • valid or expected: the values accepted.
  • limit and actual: the limit exceeded and the measured value.
  • example: a corrected part of the query document.
{
"title": "Bad Request",
"status": 400,
"detail": "Unknown field 'categroy' in filter.",
"retryable": false,
"errors": [
{
"code": "unknown_filter_field",
"detail": "Unknown field 'categroy' in filter.",
"at": "filter[1][1]",
"received": "categroy",
"suggestion": "category",
"valid": ["category", "name", "rating"],
"example": { "filter": ["==", ["get", "category"], "value"] }
}
]
}
codeHTTP status codeDescription
invalid_request400The query document is invalid, or the API didn't issue the continue token.
invalid_filter, unknown_filter_operator400The filter isn't a valid expression.
unknown_filter_field, unknown_select_field400The datasource doesn't have the property. valid lists the properties it has.
unfilterable_field400The property isn't a string, number, or boolean.
filter_type_mismatch400The filter compares a property with a value of another type.
continuation_query_mismatch400The continue token belongs to a different query document.
missing_token, invalid_token401Check the access token.
token_restricted, insufficient_scope403The token is restricted, or it doesn't have the datasources:read scope.
datasource_not_found, version_not_found404The token's account has no such datasource or version.
request_too_large413The request body is over 1 MiB.
query_too_broad413The query is over a limit, such as the 50 km within_distance radius. Narrow it.
query_budget_exhausted413A within_distance search has too many features in range to rank, or too many features share one location to page past. Narrow the area or add a filter.
rate_limited429You exceeded the rate limit. Retry after the X-Rate-Limit-Reset time.
internal_error500An unexpected error occurred.
auth_unavailable503The API couldn't verify the access token. Retry the request.

Interlaken API restrictions and limits​

Requests are rate limited per access token. If you exceed a limit, you receive an HTTP 429 Too Many Requests error. For information on rate limit headers, see Rate limit headers.

もし、レート制限をの数を高くしたい場合は、 お問い合わせください。.

Datasource endpoint limits​

LimitValue
Datasource IDUp to 64 characters: letters, numbers, -, and _.
Branch name1 to 64 characters: lowercase letters, numbers, -, and _, with at least one that isn't a number.
Display name1 to 255 characters.
Singlepart upload300 MB per file.
Multipart upload1 GB in total. Every part except the last must be at least 5 MiB (5,242,880 bytes).
Upload metadata16 KB when encoded as JSON, and up to 32 levels of nesting.
Detail strategyUp to 20 rules. Each when expression is up to 256 characters. Zoom levels are 0 to 30.
List datasources page sizeUp to 500 datasources per page.

Query endpoint limits​

LimitValue
Request body1 MiB.
Query geometryUp to 10,000 positions.
within_distance radiusUp to 50 km. The geometry can reach at most 500 km from its center.
ResultsUp to 1,000 features per response. Use paging for more.
CachingResponses set Cache-Control: no-store.
Edge precisionMatching first compares stored bounding boxes at single precision, so a query can miss a feature whose edge is within about 1 m of the query's edge.

Interlaken API pricing​

The datasource endpoints and the query endpoint are free during the public beta.

Detail strategy​

Advanced feature

Detail strategy is an advanced feature, worth considering if you're working with large datasources. You can only set it when you create a datasource.

A detail strategy gives every feature in a datasource a minimum and maximum zoom level, based on its properties. For example, you can show landmark trees from zoom 10 and other trees only from zoom 15. Tilesets built from the datasource include each feature only at the zoom levels its detail strategy allows.

Use a detail strategy when a datasource has more features than a map can usefully show when zoomed out. Leaving minor features out of low zoom levels keeps the map readable, and makes tiles smaller so they load and render faster. Because the zoom levels are stored with the data, every tileset built from the datasource uses them, without repeating the same filters in each recipe or style.

You can only set a detail strategy when you create a datasource, and you can't change it afterward. If you don't set one, every feature appears at every zoom level.

PropertyTypeDescription
rulesarray of objectsUp to 20 rules, tried in order. See Rules.
defaultobjectThe minzoom and maxzoom for features that no rule matches. Both are optional.

Rules​

Each rule sets the zoom levels for the features that match it:

PropertyTypeDescription
whenstringRequired. A filter expression of up to 256 characters that selects features, such as species = 'oak'.
minzoominteger or objectOptional. The lowest zoom level at which matching features appear. See Zoom levels.
maxzoominteger or objectOptional. The highest zoom level at which matching features appear. See Zoom levels.

For each feature, rules are tried in the order you list them, and the first rule whose when matches sets the feature's zoom levels. Later rules are ignored for that feature. If no rule matches, default applies. Put your most specific rules first.

If a when expression compares a property that is missing or null on a feature, the rule doesn't match that feature, and the next rule is tried.

Zoom levels​

Each minzoom and maxzoom, in a rule or in default, is one of the following:

  • A zoom level from 0 to 30, such as 12. If a rule sets both, maxzoom can't be lower than minzoom.
  • A property reference, such as { "field": "min_zoom" }, that reads the zoom level from each feature's own property. The property must be declared in fields as a long or double. Decimal values are rounded down, so 3.7 becomes 3.

A zoom level that you leave out, or a property reference that is null or outside 0 to 30 for a feature, uses the built-in default: minzoom 0, or no maxzoom limit. This applies even inside a rule, so a rule's missing maxzoom doesn't fall back to the maxzoom in default.

If a property reference gives a feature a maxzoom lower than its minzoom, the feature keeps its minzoom and has no maxzoom limit.

Write a when expression​

A when expression compares feature properties with values. Every property it uses must be declared in fields in the same request, and each value must match the property's type. The request is rejected if an expression refers to an undeclared property, compares a property with a value of the wrong type, or can't be parsed.

OperatorExampleMatches features where
= (or ==)species = 'oak'species is oak.
!= (or <>)species != 'oak'species is something other than oak.
<, <=, >, >=height >= 20height is 20 or more.
BETWEEN ... AND ...height BETWEEN 10 AND 20height is from 10 to 20, inclusive.
IN (...), NOT IN (...)species IN ('oak', 'maple')species is oak or maple.
LIKE, NOT LIKEspecies LIKE 'pine%'species starts with pine.
IS NULL, IS NOT NULLmin_zoom IS NOT NULLmin_zoom has a value.
AND, OR, NOT, and parenthesesheritage = true OR (height > 25 AND species = 'oak')Both conditions, either condition, or the opposite of a condition.

When writing expressions:

  • Put text values in single quotes: species = 'oak'. Double quotes are for property names, not values, so species = "oak" is rejected.
  • Write numbers without quotes (height > 20) and boolean values as true or false (heritage = true).
  • LIKE only supports % at the end of the value, to match text that starts with a prefix. '%oak' and 'o%k' aren't supported.
  • Operator keywords such as AND, IN, and LIKE aren't case-sensitive. Property names and text values are.

Example: Detail strategy​

This detail strategy for a datasource of street trees uses a min_zoom property when a tree has one, shows heritage and tall trees earlier than others, and shows every other tree from zoom 15:

{
"rules": [
{ "when": "min_zoom IS NOT NULL", "minzoom": { "field": "min_zoom" } },
{ "when": "heritage = true", "minzoom": 10 },
{ "when": "height >= 20", "minzoom": 13 }
],
"default": { "minzoom": 15 }
}
Feature propertiesRule that matchesZoom levels
{ "min_zoom": 8, "heritage": true }First8 and higher
{ "heritage": true, "height": 30 }Second10 and higher
{ "heritage": false, "height": 22 }Third13 and higher
{ "heritage": false, "height": 6 }None (default)15 and higher
このpageは役に立ちましたか?