### Table of Contents * [Styles][1] * [getStyle][2] * [Parameters][3] * [Examples][4] * [createStyle][5] * [Parameters][6] * [Examples][7] * [updateStyle][8] * [Parameters][9] * [Examples][10] * [deleteStyle][11] * [Parameters][12] * [Examples][13] * [listStyles][14] * [Parameters][15] * [Examples][16] * [putStyleIcon][17] * [Parameters][18] * [Examples][19] * [deleteStyleIcon][20] * [Parameters][21] * [Examples][22] * [getStyleSprite][23] * [Parameters][24] * [Examples][25] * [getFontGlyphRange][26] * [Parameters][27] * [Examples][28] * [getEmbeddableHtml][29] * [Parameters][30] * [Static][31] * [getStaticImage][32] * [Parameters][33] * [Examples][34] * [Uploads][35] * [listUploads][36] * [Parameters][37] * [Examples][38] * [createUploadCredentials][39] * [Examples][40] * [createUpload][41] * [Parameters][42] * [Examples][43] * [getUpload][44] * [Parameters][45] * [Examples][46] * [deleteUpload][47] * [Parameters][48] * [Examples][49] * [Datasets][50] * [listDatasets][51] * [Parameters][52] * [Examples][53] * [createDataset][54] * [Parameters][55] * [Examples][56] * [getMetadata][57] * [Parameters][58] * [Examples][59] * [updateMetadata][60] * [Parameters][61] * [Examples][62] * [deleteDataset][63] * [Parameters][64] * [Examples][65] * [listFeatures][66] * [Parameters][67] * [Examples][68] * [putFeature][69] * [Parameters][70] * [Examples][71] * [getFeature][72] * [Parameters][73] * [Examples][74] * [deleteFeature][75] * [Parameters][76] * [Examples][77] * [Tilequery][78] * [listFeatures][79] * [Parameters][80] * [Examples][81] * [Tilesets][82] * [listTilesets][83] * [Parameters][84] * [Examples][85] * [deleteTileset][86] * [Parameters][87] * [Examples][88] * [tileJSONMetadata][89] * [Parameters][90] * [createTilesetSource][91] * [Parameters][92] * [Examples][93] * [getTilesetSource][94] * [Parameters][95] * [Examples][96] * [listTilesetSources][97] * [Parameters][98] * [Examples][99] * [deleteTilesetSource][100] * [Parameters][101] * [Examples][102] * [createTileset][103] * [Parameters][104] * [Examples][105] * [publishTileset][106] * [Parameters][107] * [Examples][108] * [updateTileset][109] * [Parameters][110] * [Examples][111] * [tilesetStatus][112] * [Parameters][113] * [Examples][114] * [tilesetJob][115] * [Parameters][116] * [Examples][117] * [listTilesetJobs][118] * [Parameters][119] * [Examples][120] * [getTilesetsQueue][121] * [Examples][122] * [validateRecipe][123] * [Parameters][124] * [Examples][125] * [getRecipe][126] * [Parameters][127] * [Examples][128] * [updateRecipe][129] * [Parameters][130] * [Examples][131] * [Geocoding][132] * [forwardGeocode][133] * [Parameters][134] * [Examples][135] * [reverseGeocode][136] * [Parameters][137] * [Examples][138] * [Directions][139] * [getDirections][140] * [Parameters][141] * [Examples][142] * [MapMatching][143] * [getMatch][144] * [Parameters][145] * [Examples][146] * [Matrix][147] * [getMatrix][148] * [Parameters][149] * [Examples][150] * [Optimization][151] * [getOptimization][152] * [Parameters][153] * [Tokens][154] * [listTokens][155] * [Examples][156] * [createToken][157] * [Parameters][158] * [Examples][159] * [createTemporaryToken][160] * [Parameters][161] * [Examples][162] * [updateToken][163] * [Parameters][164] * [Examples][165] * [getToken][166] * [Examples][167] * [deleteToken][168] * [Parameters][169] * [Examples][170] * [listScopes][171] * [Examples][172] * [Data structures][173] * [DirectionsWaypoint][174] * [Properties][175] * [MapMatchingPoint][176] * [Properties][177] * [MatrixPoint][178] * [Properties][179] * [OptimizationWaypoint][180] * [Properties][181] * [SimpleMarkerOverlay][182] * [Properties][183] * [CustomMarkerOverlay][184] * [Properties][185] * [PathOverlay][186] * [Properties][187] * [GeoJsonOverlay][188] * [Properties][189] * [UploadableFile][190] * [Coordinates][191] * [BoundingBox][192] * [Isochrone][193] * [getContours][194] * [Parameters][195] * [GeocodingV6][196] * [forwardGeocode][197] * [Parameters][198] * [Examples][199] * [reverseGeocode][200] * [Parameters][201] * [Examples][202] * [Distribution][203] * [Properties][204] ## Styles Styles API service. Learn more about this service and its responses in [the HTTP service documentation][205]. ### getStyle Get a style. See the [corresponding HTTP service documentation][206]. #### Parameters * `config` **[Object][207]** * `config.styleId` **[string][208]** * `config.ownerId` **[string][208]?** * `config.metadata` **[boolean][209]** If true, `mapbox:` specific metadata will be preserved (optional, default `false`) * `config.draft` **[boolean][209]** If `true` will retrieve the draft style, otherwise will retrieve the published style. (optional, default `false`) * `config.fresh` **[boolean][209]** If `true`, will bypass the cached version of the style. Fresh style requests have a lower rate limit than cached requests and may have a higher latency. `fresh=true` should never be used in production or high concurrency environments. (optional, default `false`) #### Examples ```javascript stylesClient.getStyle({ styleId: 'style-id' }) .send() .then(response => { const style = response.body; }); ``` Returns **MapiRequest** ### createStyle Create a style. See the [corresponding HTTP service documentation][210]. #### Parameters * `config` **[Object][207]** * `config.style` **[Object][207]** Stylesheet JSON object. * `config.ownerId` **[string][208]?** #### Examples ```javascript stylesClient.createStyle({ style: { version: 8, name: "My Awesome Style", metadata: {}, sources: {}, layers: [], glyphs: "mapbox://fonts/{owner}/{fontstack}/{range}.pbf" } }) .send() .then(response => { const style = response.body; }); ``` Returns **MapiRequest** ### updateStyle Update a style. See the [corresponding HTTP service documentation][211]. #### Parameters * `config` **[Object][207]** * `config.styleId` **[string][208]** * `config.style` **[Object][207]** Stylesheet JSON object. * `config.lastKnownModification` **([string][208] | [number][212] | [Date][213])?** Datetime of last known update. Passed as 'If-Unmodified-Since' HTTP header. * `config.ownerId` **[string][208]?** #### Examples ```javascript stylesClient.updateStyle({ styleId: 'style-id', style: { version: 8, name: 'My Awesome Style', metadata: {}, sources: {}, layers: [], glyphs: 'mapbox://fonts/{owner}/{fontstack}/{range}.pbf' } }) .send() .then(response => { const style = response.body; }); ``` Returns **MapiRequest** ### deleteStyle Delete a style. #### Parameters * `config` **[Object][207]** * `config.styleId` **[string][208]** * `config.ownerId` **[string][208]?** #### Examples ```javascript stylesClient.deleteStyle({ styleId: 'style-id' }) .send() .then(response => { // delete successful }); ``` Returns **MapiRequest** ### listStyles List styles in your account. #### Parameters * `config` **[Object][207]?** * `config.start` **[string][208]?** The style ID to start at, for paginated results. * `config.ownerId` **[string][208]?** * `config.fresh` **[boolean][209]** If `true`, will bypass the cached resource. Fresh requests have a lower rate limit than cached requests and may have a higher latency. `fresh=true` should never be used in high concurrency environments. (optional, default `false`) #### Examples ```javascript stylesClient.listStyles() .send() .then(response => { const styles = response.body; }); ``` Returns **MapiRequest** ### putStyleIcon Add an icon to a style, or update an existing one. #### Parameters * `config` **[Object][207]** * `config.styleId` **[string][208]** * `config.iconId` **[string][208]** * `config.file` **[UploadableFile][190]** An SVG file. * `config.ownerId` **[string][208]?** #### Examples ```javascript stylesClient.putStyleIcon({ styleId: 'foo', iconId: 'bar', // The string filename value works in Node. // In the browser, provide a Blob. file: 'path/to/file.svg' }) .send() .then(response => { const newSprite = response.body; }); ``` Returns **MapiRequest** ### deleteStyleIcon Remove an icon from a style. #### Parameters * `config` **[Object][207]** * `config.styleId` **[string][208]** * `config.iconId` **[string][208]** * `config.ownerId` **[string][208]?** * `config.draft` **[boolean][209]** If `true` will remove the icon from the draft style, otherwise will remove the icon from the published style. (optional, default `false`) #### Examples ```javascript stylesClient.deleteStyleIcon({ styleId: 'foo', iconId: 'bar' }) .send() .then(response => { // delete successful }); ``` Returns **MapiRequest** ### getStyleSprite Get a style sprite's image or JSON document. See [the corresponding HTTP service documentation][214]. #### Parameters * `config` **[Object][207]** * `config.styleId` **[string][208]** * `config.format` **(`"json"` | `"png"`)** (optional, default `"json"`) * `config.highRes` **[boolean][209]?** If true, returns spritesheet with 2x resolution. * `config.ownerId` **[string][208]?** * `config.draft` **[boolean][209]** If `true` will retrieve the draft style sprite, otherwise will retrieve the published style sprite. (optional, default `false`) * `config.fresh` **[boolean][209]** If `true`, will bypass the cached resource. Fresh requests have a lower rate limit than cached requests and may have a higher latency. `fresh=true` should never be used in high concurrency environments. (optional, default `false`) #### Examples ```javascript stylesClient.getStyleSprite({ format: 'json', styleId: 'foo', highRes: true }) .send() .then(response => { const sprite = response.body; }); ``` ```javascript stylesClient.getStyleSprite({ format: 'png', styleId: 'foo', highRes: true }) .send() .then(response => { const sprite = response.body; fs.writeFileSync('sprite.png', sprite, 'binary'); }); ``` Returns **MapiRequest** ### getFontGlyphRange Get a font glyph range. See [the corresponding HTTP service documentation][215]. #### Parameters * `config` **[Object][207]** * `config.fonts` **([string][208] | [Array][216]<[string][208]>)** An array of font names. * `config.start` **[number][212]** Character code of the starting glyph. * `config.end` **[number][212]** Character code of the last glyph, typically equivalent to`config.start + 255`. * `config.ownerId` **[string][208]?** #### Examples ```javascript stylesClient.getFontGlyphRange({ fonts: 'Arial Unicode', start: 0, end: 255 }) .send() .then(response => { const glyph = response.body; }); ``` Returns **MapiRequest** ### getEmbeddableHtml Get embeddable HTML displaying a map. See [the corresponding HTTP service documentation][217]. #### Parameters * `config` **[Object][207]** * `config.styleId` **[string][208]** * `config.scrollZoom` **[boolean][209]** If `false`, zooming the map by scrolling will be disabled. (optional, default `true`) * `config.title` **[boolean][209]** If `true`, the map's title and owner is displayed in the upper right corner of the map. (optional, default `false`) * `config.fallback` **[boolean][209]** If `true`, serve a fallback raster map. (optional, default `false`) * `config.mapboxGLVersion` **[string][208]?** Specify a version of [Mapbox GL JS][218] to use to render the map. * `config.mapboxGLGeocoderVersion` **[string][208]?** Specify a version of the [Mapbox GL geocoder plugin][219] to use to render the map search box. * `config.ownerId` **[string][208]?** * `config.draft` **[boolean][209]** If `true` will retrieve the draft style, otherwise will retrieve the published style. (optional, default `false`) ## Static Static Images API service. Learn more about this service and its responses in [the HTTP service documentation][220]. ### getStaticImage Get a static map image. **If you just want the URL for the static map image, create a request and get it's URL with `MapiRequest#url`.** This is what prior versions of the SDK returned. #### Parameters * `config` **[Object][207]** * `config.ownerId` **[string][208]** The owner of the map style. * `config.styleId` **[string][208]** The map's style ID. * `config.width` **[number][212]** Width of the image in pixels, between 1 and 1280. * `config.height` **[number][212]** Height of the image in pixels, between 1 and 1280. * `config.position` **(`"auto"` | [Object][207])** If `"auto"`, the viewport will fit the bounds of the overlay(s). If an object, it could be either a bbox or a coordinate and a zoom as the required parameters.\ ` bbox` (required): Is an array of coordinate pairs, with the first coordinate pair referring to the southwestern corner of the box (the minimum longitude and latitude) and the second referring to the northeastern corner of the box (the maximum longitude and latitude). Otherwise the maps' position is described by an object with the following properties: `coordinates` (required): [`coordinates`][191] for the center of image. `zoom` (required): Between 0 and 20. `bearing` (optional): Between 0 and 360. `pitch` (optional): Between 0 and 60. * `config.padding` **[string][208]** A string value that denotes the minimum padding per side of the image. This can only be used with auto or bbox. The value resembles the CSS specification for padding and accepts 1-4 integers without units * `config.overlays` **[Array][216]\?** Overlays should be in z-index order: the first in the array will be on the bottom; the last will be on the top. Overlays are objects that match one of the following types: [`SimpleMarkerOverlay`][182], [`CustomMarkerOverlay`][184], [`PathOverlay`][186], [`GeoJsonOverlay`][188] * `config.highRes` **[boolean][209]** (optional, default `false`) * `config.before_layer` **[string][208]?** The ID of the style layer that overlays should be inserted *before*. * `config.addlayer` **[Object][207]?** Adds a Mapbox style layer to the map's style at render time. Can be combined with before\_layer. * `config.setfilter` **[Array][216]?** Applies a filter to an existing layer in a style using Mapbox's expression syntax. Must be used with layer\_id. * `config.layer_id` **[string][208]?** Denotes the layer in the style that the filter specified in setfilter is applied to. * `config.attribution` **[boolean][209]** Whether there is attribution on the map image. (optional, default `true`) * `config.logo` **[boolean][209]** Whether there is a Mapbox logo on the map image. (optional, default `true`) #### Examples ```javascript staticClient.getStaticImage({ ownerId: 'mapbox', styleId: 'streets-v11', width: 200, height: 300, position: { coordinates: [12, 13], zoom: 4 } }) .send() .then(response => { const image = response.body; }); ``` ```javascript staticClient.getStaticImage({ ownerId: 'mapbox', styleId: 'streets-v11', width: 200, height: 300, position: { // position as a bounding box bbox: [-77.04,38.8,-77.02,38.91], }, padding: '4' }) .send() .then(response => { const image = response.body; }); ``` ```javascript staticClient.getStaticImage({ ownerId: 'mapbox', styleId: 'streets-v11', width: 200, height: 300, position: { coordinates: [12, 13], zoom: 3 }, overlays: [ // Simple markers. { marker: { coordinates: [12.2, 12.8] } }, { marker: { size: 'large', coordinates: [14, 13.2], label: 'm', color: '#000' } }, { marker: { coordinates: [15, 15.2], label: 'airport', color: '#ff0000' } }, // Custom marker { marker: { coordinates: [10, 11], url: 'https://upload.wikimedia.org/wikipedia/commons/6/6f/0xff_timetracker.png' } } ] }) .send() .then(response => { const image = response.body; }); ``` ```javascript // To get the URL instead of the image, create a request // and get its URL without sending it. const request = staticClient .getStaticImage({ ownerId: 'mapbox', styleId: 'streets-v11', width: 200, height: 300, position: { coordinates: [12, 13], zoom: 4 } }); const staticImageUrl = request.url(); // Now you can open staticImageUrl in a browser. ``` ```javascript // Filter all buildings that have a height value that is less than 300 meters const request = staticClient .getStaticImage({ ownerId: 'mapbox', styleId: 'streets-v11', width: 200, height: 300, position: { coordinates: [12, 13], zoom: 4 }, setfilter: [">","height",300], layer_id: 'building', }); const staticImageUrl = request.url(); // Now you can open staticImageUrl in a browser. ``` ```javascript // Paint all the state and province level boundaries associated with the US worldview with a dashed line and insert it below the road-label layer const request = staticClient .getStaticImage({ ownerId: 'mapbox', styleId: 'streets-v11', width: 200, height: 300, position: { coordinates: [12, 13], zoom: 4 }, addlayer: {"id":"better-boundary","type":"line","source":"composite","source-layer":"admin","filter":["all",["==",["get","admin_level"],1],["==",["get","maritime"],"false"],["match",["get","worldview"],["all","US"],true,false]],"layout":{"line-join":"bevel"},"paint":{"line-color":"%236898B3","line-width":1.5,"line-dasharray":[1.5,1]}}, before_layer: 'road-label', }); const staticImageUrl = request.url(); // Now you can open staticImageUrl in a browser. ``` Returns **MapiRequest** ## Uploads Uploads API service. Learn more about this service and its responses in [the HTTP service documentation][221]. ### listUploads List the statuses of all recent uploads. See the [corresponding HTTP service documentation][222]. #### Parameters * `config` **[Object][207]?** * `config.reverse` **[boolean][209]?** List uploads in chronological order, rather than reverse chronological order. #### Examples ```javascript uploadsClient.listUploads() .send() .then(response => { const uploads = response.body; }); ``` Returns **MapiRequest** ### createUploadCredentials Create S3 credentials. See the [corresponding HTTP service documentation][223]. #### Examples ```javascript const AWS = require('aws-sdk'); const getCredentials = () => { return uploadsClient .createUploadCredentials() .send() .then(response => response.body); } const putFileOnS3 = (credentials) => { const s3 = new AWS.S3({ accessKeyId: credentials.accessKeyId, secretAccessKey: credentials.secretAccessKey, sessionToken: credentials.sessionToken, region: 'us-east-1' }); return s3.putObject({ Bucket: credentials.bucket, Key: credentials.key, Body: fs.createReadStream('/path/to/file.mbtiles') }).promise(); }; getCredentials().then(putFileOnS3); ``` Returns **MapiRequest** ### createUpload Create an upload. See the [corresponding HTTP service documentation][224]. #### Parameters * `config` **[Object][207]** * `config.tileset` **[string][208]** The tileset ID to create or replace, in the format `username.nameoftileset`. Limited to 32 characters (only `-` and `_` special characters allowed; limit does not include username). * `config.url` **[string][208]** HTTPS URL of the S3 object provided by [`createUploadCredentials`][39] * `config.name` **[string][208]?** The name of the tileset. Limited to 64 characters. #### Examples ```javascript // Response from a call to createUploadCredentials const credentials = { accessKeyId: '{accessKeyId}', bucket: '{bucket}', key: '{key}', secretAccessKey: '{secretAccessKey}', sessionToken: '{sessionToken}', url: '{s3 url}' }; uploadsClient.createUpload({ tileset: `${myUsername}.${myTileset}`, url: credentials.url, name: 'my uploads name', }) .send() .then(response => { const upload = response.body; }); ``` Returns **MapiRequest** ### getUpload Get an upload's status. See the [corresponding HTTP service documentation][225]. #### Parameters * `config` **[Object][207]** * `config.uploadId` **[string][208]** #### Examples ```javascript uploadsClient.getUpload({ uploadId: '{upload_id}' }) .send() .then(response => { const status = response.body; }); ``` Returns **MapiRequest** ### deleteUpload Delete an upload. See the [corresponding HTTP service documentation][226]. #### Parameters * `config` **[Object][207]** * `config.uploadId` **[string][208]** #### Examples ```javascript uploadsClient.deleteUpload({ uploadId: '{upload_id}' }) .send() .then(response => { // Upload successfully deleted. }); ``` Returns **MapiRequest** ## Datasets Datasets API service. Learn more about this service and its responses in [the HTTP service documentation][227]. ### listDatasets List datasets in your account. See the [corresponding HTTP service documentation][228]. #### Parameters * `config` **[Object][207]?** * `config.sortby` **[string][208]** Sort by either `modified` or `created` (default) dates. (optional, default `created`) #### Examples ```javascript datasetsClient.listDatasets() .send() .then(response => { const datasets = response.body; }); ``` ```javascript datasetsClient.listDatasets() .eachPage((error, response, next) => { // Handle error or response and call next. }); ``` Returns **MapiRequest** ### createDataset Create a new, empty dataset. See the [corresponding HTTP service documentation][229]. #### Parameters * `config` **[Object][207]** * `config.name` **[string][208]?** * `config.description` **[string][208]?** #### Examples ```javascript datasetsClient.createDataset({ name: 'example', description: 'An example dataset' }) .send() .then(response => { const datasetMetadata = response.body; }); ``` Returns **MapiRequest** ### getMetadata Get metadata about a dataset. See the [corresponding HTTP service documentation][230]. #### Parameters * `config` **[Object][207]** * `config.datasetId` **[string][208]** #### Examples ```javascript datasetsClient.getMetadata({ datasetId: 'dataset-id' }) .send() .then(response => { const datasetMetadata = response.body; }) ``` Returns **MapiRequest** ### updateMetadata Update user-defined properties of a dataset's metadata. See the [corresponding HTTP service documentation][231]. #### Parameters * `config` **[Object][207]** * `config.datasetId` **[string][208]** * `config.name` **[string][208]?** * `config.description` **[string][208]?** #### Examples ```javascript datasetsClient.updateMetadata({ datasetId: 'dataset-id', name: 'foo' }) .send() .then(response => { const datasetMetadata = response.body; }); ``` Returns **MapiRequest** ### deleteDataset Delete a dataset, including all features it contains. See the [corresponding HTTP service documentation][232]. #### Parameters * `config` **[Object][207]** * `config.datasetId` **[string][208]** #### Examples ```javascript datasetsClient.deleteDataset({ datasetId: 'dataset-id' }) .send() .then(response => { // Dataset is successfully deleted. }); ``` Returns **MapiRequest** ### listFeatures List features in a dataset. This endpoint supports pagination. Use `MapiRequest#eachPage` or manually specify the `limit` and `start` options. See the [corresponding HTTP service documentation][233]. #### Parameters * `config` **[Object][207]** * `config.datasetId` **[string][208]** * `config.limit` **[number][212]?** Only list this number of features. * `config.start` **[string][208]?** The ID of the feature from which the listing should start. #### Examples ```javascript datasetsClient.listFeatures({ datasetId: 'dataset-id' }) .send() .then(response => { const features = response.body; }); ``` Returns **MapiRequest** ### putFeature Add a feature to a dataset or update an existing one. See the [corresponding HTTP service documentation][234]. #### Parameters * `config` **[Object][207]** * `config.datasetId` **[string][208]** * `config.featureId` **[string][208]** * `config.feature` **[Object][207]** Valid GeoJSON that is not a `FeatureCollection`. If the feature has a top-level `id` property, it must match the `featureId` you specify. #### Examples ```javascript datasetsClient.putFeature({ datasetId: 'dataset-id', featureId: 'null-island', feature: { "type": "Feature", "properties": { "name": "Null Island" }, "geometry": { "type": "Point", "coordinates": [0, 0] } } }) .send() .then(response => { const feature = response.body; }); ``` Returns **MapiRequest** ### getFeature Get a feature in a dataset. See the [corresponding HTTP service documentation][235]. #### Parameters * `config` **[Object][207]** * `config.datasetId` **[string][208]** * `config.featureId` **[string][208]** #### Examples ```javascript datasetsClient.getFeature({ datasetId: 'dataset-id', featureId: 'feature-id' }) .send() .then(response => { const feature = response.body; }); ``` Returns **MapiRequest** ### deleteFeature Delete a feature in a dataset. See the [corresponding HTTP service documentation][236]. #### Parameters * `config` **[Object][207]** * `config.datasetId` **[string][208]** * `config.featureId` **[string][208]** #### Examples ```javascript datasetsClient.deleteFeature({ datasetId: 'dataset-id', featureId: 'feature-id' }) .send() .then(response => { // Feature is successfully deleted. }); ``` Returns **MapiRequest** ## Tilequery Tilequery API service. Learn more about this service and its responses in [the HTTP service documentation][237]. ### listFeatures List features within a radius of a point on a map (or several maps). #### Parameters * `config` **[Object][207]** * `config.mapIds` **[Array][216]<[string][208]>** The maps being queried. If you need to composite multiple layers, provide multiple map IDs. * `config.coordinates` **[Coordinates][191]** The longitude and latitude to be queried. * `config.radius` **[number][212]** The approximate distance in meters to query for features. (optional, default `0`) * `config.limit` **[number][212]** The number of features to return, between 1 and 50. (optional, default `5`) * `config.dedupe` **[boolean][209]** Whether or not to deduplicate results. (optional, default `true`) * `config.geometry` **(`"polygon"` | `"linestring"` | `"point"`)?** Queries for a specific geometry type. * `config.layers` **[Array][216]<[string][208]>?** IDs of vector layers to query. #### Examples ```javascript tilequeryClient.listFeatures({ mapIds: ['mapbox.mapbox-streets-v8'], coordinates: [-122.42901, 37.80633], radius: 10 }) .send() .then(response => { const features = response.body; }); ``` Returns **MapiRequest** ## Tilesets Tilesets API service. Learn more about this service and its responses in [the HTTP service documentation][238]. ### listTilesets List a user's tilesets. #### Parameters * `config` **[Object][207]?** * `config.ownerId` **[string][208]?** * `config.type` **(`"raster"` | `"vector"`)?** Filter results by tileset type, either `raster` or `vector`. * `config.limit` **[number][212]** The maximum number of tilesets to return, from 1 to 500. (optional, default `100`) * `config.sortBy` **(`"created"` | `"modified"`)?** Sort the listings by their `created` or `modified` timestamps. * `config.start` **[string][208]?** The tileset after which to start the listing. * `config.visibility` **(`"public"` | `"private"`)?** Filter results by visibility, either `public` or `private` #### Examples ```javascript tilesetsClient.listTilesets() .send() .then(response => { const tilesets = response.body; }); ``` ```javascript tilesetsClient.listTilesets() .eachPage((error, response, next) => { // Handle error or response and call next. }); ``` Returns **MapiRequest** ### deleteTileset Delete a tileset #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset to be deleted in the form `username.tileset_id`. #### Examples ```javascript tilesetsClient.deleteTileset({ tilesetId: 'username.tileset_id' }) .send() .then(response => { const deleted = response.statusCode === 204; }); ``` Returns **MapiRequest** ### tileJSONMetadata Retrieve metadata about a tileset. #### Parameters * `config` **[Object][207]?** * `config.tilesetId` **[string][208]?** Unique identifier for the tileset in the format `username.id`. Returns **MapiRequest** ### createTilesetSource Create a tileset source #### Parameters * `config` **[Object][207]** * `config.id` **[string][208]** ID of the tileset source to be created. * `config.file` **[UploadableFile][190]** Line-delimeted GeoJSON file. * `config.ownerId` **[string][208]?** #### Examples ```javascript tilesetsClient.createTilesetSource({ id: 'tileset_source_id', // The string filename value works in Node. // In the browser, provide a Blob. file: 'path/to/file.geojson.ld' }) .send() .then(response => { const tilesetSource = response.body; }); ``` Returns **MapiRequest** ### getTilesetSource Retrieve a tileset source information #### Parameters * `config` **[Object][207]** * `config.id` **[string][208]** ID of the tileset source. * `config.ownerId` **[string][208]?** #### Examples ```javascript tilesetsClient.getTilesetSource({ id: 'tileset_source_id' }) .send() .then(response => { const tilesetSource = response.body; }); ``` Returns **MapiRequest** ### listTilesetSources List tileset sources #### Parameters * `config` **[Object][207]?** * `config.ownerId` **[string][208]?** * `config.limit` **[number][212]** The maximum number of tilesets to return, from 1 to 500. (optional, default `100`) * `config.start` **[string][208]?** The tileset after which to start the listing. #### Examples ```javascript tilesetsClient.listTilesetSources() .send() .then(response => { const tilesetSources = response.body; }); ``` Returns **MapiRequest** ### deleteTilesetSource Delete a tileset source #### Parameters * `config` **[Object][207]** * `config.id` **[string][208]** ID of the tileset source to be deleted. * `config.ownerId` **[string][208]?** #### Examples ```javascript tilesetsClient.deleteTilesetSource({ id: 'tileset_source_id' }) .send() .then(response => { const deleted = response.statusCode === 201; }); ``` Returns **MapiRequest** ### createTileset Create a tileset #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset to be created in the form `username.tileset_name`. * `config.recipe` **[Object][207]** The [tileset recipe][239] to use in JSON format. * `config.name` **[string][208]** Name of the tileset. * `config.private` **[boolean][209]** A private tileset must be used with an access token from your account. (optional, default `true`) * `config.description` **[string][208]?** Description of the tileset. #### Examples ```javascript tilesetsClient.createTileset({ tilesetId: 'username.tileset_id', recipe: { version: 1, layers: { my_new_layer: { source: "mapbox://tileset-source/{username}/{id}", minzoom: 0, maxzoom: 8 } } }, name: 'My Tileset' }) .send() .then(response => { const message = response.body.message; }); ``` Returns **MapiRequest** ### publishTileset Publish a tileset #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset to publish in the form `username.tileset_name`. #### Examples ```javascript tilesetsClient.publishTileset({ tilesetId: 'username.tileset_id' }) .send() .then(response => { const tilesetPublishJob = response.body; }); ``` Returns **MapiRequest** ### updateTileset Update a tileset #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset in the form `username.tileset_name`. * `config.name` **[string][208]?** * `config.description` **[string][208]?** * `config.private` **[boolean][209]?** * `config.attribution` **[Array][216]?** * `string` **[string][208]** \[].text] * `string` **[string][208]** \[].link] #### Examples ```javascript tilesetsClient.updateTileset({ tilesetId: 'username.tileset_name', name: 'Tileset Name', private: true, attribution: [ { text: 'Source Name', link: 'https://example.com' } ] }) .send() .then(response => { const updated = response.statusCode === 204; }); ``` Returns **MapiRequest** ### tilesetStatus Retrieve the status of a tileset #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset in the form `username.tileset_name`. #### Examples ```javascript tilesetsClient.tilesetStatus({ tilesetId: 'username.tileset_name' }) .send() .then(response => { const tilesetStatus = response.body; }); ``` Returns **MapiRequest** ### tilesetJob Retrieve information about a single tileset job #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset in the form `username.tileset_name`. * `config.jobId` **[string][208]** The publish job's ID. #### Examples ```javascript tilesetsClient.tilesetJob({ tilesetId: 'username.tileset_name' jobId: 'job_id' }) .send() .then(response => { const tilesetJob = response.body; }); ``` Returns **MapiRequest** ### listTilesetJobs List information about all jobs for a tileset #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset in the form `username.tileset_name`. * `config.stage` **(`"processing"` | `"queued"` | `"success"` | `"failed"`)?** * `config.limit` **[number][212]** The maximum number of tilesets to return, from 1 to 500. (optional, default `100`) * `config.start` **[string][208]?** The tileset after which to start the listing. #### Examples ```javascript tilesetsClient.listTilesetJobs({ tilesetId: 'username.tileset_name' }) .send() .then(response => { const jobs = response.body; }); ``` Returns **MapiRequest** ### getTilesetsQueue View Tilesets API global queue #### Examples ```javascript tilesetsClient.getTilesetsQueue() .send() .then(response => { const queue = response.body; }); ``` Returns **MapiRequest** ### validateRecipe Validate a recipe #### Parameters * `config` **[Object][207]** * `config.recipe` **[Object][207]** The [tileset recipe][239] to validate in JSON format. #### Examples ```javascript tilesetsClient.validateRecipe({ recipe: { version: 1, layers: { my_new_layer: { source: "mapbox://tileset-source/{username}/{id}", minzoom: 0, maxzoom: 8 } } } }) .send() .then(response => { const validation = response.body; }); ``` Returns **MapiRequest** ### getRecipe Retrieve a recipe #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset in the form `username.tileset_name`. #### Examples ```javascript tilesetsClient.getRecipe({ tilesetId: 'username.tileset_name' }) .send() .then(response => { const recipe = response.body; }); ``` Returns **MapiRequest** ### updateRecipe Update a tileset recipe #### Parameters * `config` **[Object][207]** * `config.tilesetId` **[string][208]** ID of the tileset in the form `username.tileset_name`. * `config.recipe` **[Object][207]** The [tileset recipe][239] in JSON format. #### Examples ```javascript tilesetsClient.updateRecipe({ tilesetId: 'username.tileset_name', recipe: { version: 1, layers: { my_new_layer: { source: "mapbox://tileset-source/{username}/{id}", minzoom: 0, maxzoom: 8 } } } }) .send() .then(response => { const updated = response.statusCode === 204; }); ``` Returns **MapiRequest** ## Geocoding Geocoding API service. Learn more about this service and its responses in [the HTTP service documentation][240]. ### forwardGeocode Search for a place. See the [public documentation][241]. #### Parameters * `config` **[Object][207]** * `config.query` **[string][208]** A place name. * `config.mode` **(`"mapbox.places"` | `"mapbox.places-permanent"`)** Either `mapbox.places` for ephemeral geocoding, or `mapbox.places-permanent` for storing results and batch geocoding. (optional, default `"mapbox.places"`) * `config.countries` **[Array][216]<[string][208]>?** Limits results to the specified countries. Each item in the array should be an [ISO 3166 alpha 2 country code][242]. * `config.proximity` **([Coordinates][191] | `"ip"`)?** Bias local results based on a provided coordinate location or a user's IP address. * `config.types` **[Array][216]<(`"country"` | `"region"` | `"postcode"` | `"district"` | `"place"` | `"locality"` | `"neighborhood"` | `"address"` | `"poi"` | `"poi.landmark"`)>?** Filter results by feature types. * `config.autocomplete` **[boolean][209]** Return autocomplete results or not. (optional, default `true`) * `config.bbox` **[BoundingBox][192]?** Limit results to a bounding box. * `config.limit` **[number][212]** Limit the number of results returned. (optional, default `5`) * `config.language` **[Array][216]<[string][208]>?** Specify the language to use for response text and, for forward geocoding, query result weighting. Options are [IETF language tags][243] comprised of a mandatory [ISO 639-1 language code][244] and optionally one or more IETF subtags for country or script. * `config.routing` **[boolean][209]** Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. (optional, default `false`) * `config.fuzzyMatch` **[boolean][209]** Specify whether the Geocoding API should attempt approximate, as well as exact, matching. (optional, default `true`) * `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`) * `config.session_token` **[String][208]?** A unique session identifier generated by the client. #### Examples ```javascript geocodingClient.forwardGeocode({ query: 'Paris, France', limit: 2 }) .send() .then(response => { const match = response.body; }); ``` ```javascript // geocoding with proximity geocodingClient.forwardGeocode({ query: 'Paris, France', proximity: [-95.4431142, 33.6875431] }) .send() .then(response => { const match = response.body; }); // geocoding with countries geocodingClient.forwardGeocode({ query: 'Paris, France', countries: ['fr'] }) .send() .then(response => { const match = response.body; }); // geocoding with bounding box geocodingClient.forwardGeocode({ query: 'Paris, France', bbox: [2.14, 48.72, 2.55, 48.96] }) .send() .then(response => { const match = response.body; }); ``` Returns **MapiRequest** ### reverseGeocode Search for places near coordinates. See the [public documentation][245]. #### Parameters * `config` **[Object][207]** * `config.query` **[Coordinates][191]** Coordinates at which features will be searched. * `config.mode` **(`"mapbox.places"` | `"mapbox.places-permanent"`)** Either `mapbox.places` for ephemeral geocoding, or `mapbox.places-permanent` for storing results and batch geocoding. (optional, default `"mapbox.places"`) * `config.countries` **[Array][216]<[string][208]>?** Limits results to the specified countries. Each item in the array should be an [ISO 3166 alpha 2 country code][242]. * `config.types` **[Array][216]<(`"country"` | `"region"` | `"postcode"` | `"district"` | `"place"` | `"locality"` | `"neighborhood"` | `"address"` | `"poi"` | `"poi.landmark"`)>?** Filter results by feature types. * `config.bbox` **[BoundingBox][192]?** Limit results to a bounding box. * `config.limit` **[number][212]** Limit the number of results returned. If using this option, you must provide a single item for `types`. (optional, default `1`) * `config.language` **[Array][216]<[string][208]>?** Specify the language to use for response text and, for forward geocoding, query result weighting. Options are [IETF language tags][243] comprised of a mandatory [ISO 639-1 language code][244] and optionally one or more IETF subtags for country or script. * `config.reverseMode` **(`"distance"` | `"score"`)** Set the factors that are used to sort nearby results. (optional, default `'distance'`) * `config.routing` **[boolean][209]** Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. (optional, default `false`) * `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`) * `config.session_token` **[String][208]?** A unique session identifier generated by the client. #### Examples ```javascript geocodingClient.reverseGeocode({ query: [-95.4431142, 33.6875431] }) .send() .then(response => { // GeoJSON document with geocoding matches const match = response.body; }); ``` Returns **MapiRequest** ## Directions Directions API service. Learn more about this service and its responses in [the HTTP service documentation][246]. ### getDirections Get directions. Please read [the full HTTP service documentation][246] to understand all of the available options. #### Parameters * `config` **[Object][207]** * `config.profile` **(`"driving-traffic"` | `"driving"` | `"walking"` | `"cycling"`)** (optional, default `"driving"`) * `config.waypoints` **[Array][216]<[DirectionsWaypoint][174]>** An ordered array of [`DirectionsWaypoint`][174] objects, between 2 and 25 (inclusive). * `config.alternatives` **[boolean][209]** Whether to try to return alternative routes. (optional, default `false`) * `config.annotations` **[Array][216]<(`"duration"` | `"distance"` | `"speed"` | `"congestion"`)>?** Specify additional metadata that should be returned. * `config.bannerInstructions` **[boolean][209]** Should be used in conjunction with `steps`. (optional, default `false`) * `config.continueStraight` **[boolean][209]?** Sets the allowed direction of travel when departing intermediate waypoints. * `config.exclude` **[string][208]?** Exclude certain road types from routing. See HTTP service documentation for options. * `config.geometries` **(`"geojson"` | `"polyline"` | `"polyline6"`)** Format of the returned geometry. (optional, default `"polyline"`) * `config.language` **[string][208]** Language of returned turn-by-turn text instructions. See options listed in [the HTTP service documentation][247]. (optional, default `"en"`) * `config.overview` **(`"simplified"` | `"full"` | `"false"`)** Type of returned overview geometry. (optional, default `"simplified"`) * `config.roundaboutExits` **[boolean][209]** Emit instructions at roundabout exits. (optional, default `false`) * `config.steps` **[boolean][209]** Whether to return steps and turn-by-turn instructions. (optional, default `false`) * `config.voiceInstructions` **[boolean][209]** Whether or not to return SSML marked-up text for voice guidance along the route. (optional, default `false`) * `config.voiceUnits` **(`"imperial"` | `"metric"`)** Which type of units to return in the text for voice instructions. (optional, default `"imperial"`) * `config.engine` **(`"electric_no_recharge"` | `"electric"`)** Set to electric to enable electric vehicle routing. (optional, default `"electric_no_recharge"`) * `config.ev_initial_charge` **[number][212]?** Optional parameter to specify initial charge of vehicle in Wh (watt-hours) at the beginning of the route. * `config.ev_max_charge` **[number][212]?** Required parameter that defines the maximum possible charge of vehicle in Wh (watt-hours). * `config.ev_connector_types` **(`"ccs_combo_type1"` | `"ccs_combo_type1"` | `"tesla"`)?** Required parameter that defines the compatible connector-types for the vehicle. * `config.energy_consumption_curve` **[String][208]?** Required parameter that specifies in pairs the energy consumption in watt-hours per kilometer at a certain speed in kph. * `config.ev_charging_curve` **[String][208]?** Required parameter that specifies the maximum battery charging rate (W) at a given charge level (Wh) in a list of pairs. * `config.ev_unconditioned_charging_curve` **[String][208]?** Optional parameter that specifies the maximum battery charging rate (W) at a given charge level (Wh) in a list of pairs when the battery is in an unconditioned state (eg: cold). * `config.ev_pre_conditioning_time` **[number][212]?** Optional parameter that defines the time in minutes it would take for the vehicle's battery to condition. * `config.ev_max_ac_charging_power` **[number][212]?** Optional parameter to specify maximum AC charging power(W) that can be delivered by the onboard vehicle charger. * `config.ev_min_charge_at_destination` **[number][212]?** Optional parameter to define the minimum battery charge required at the final route destination (Wh). * `config.ev_min_charge_at_charging_station` **[number][212]?** Optional parameter to define the minimum charge when arriving at the charging station (Wh). * `config.auxiliary_consumption` **[number][212]?** Optional parameter to define the measure of the continuous power draw of the auxiliary systems in watts (E.G heating or AC). * `config.maxHeight` **[number][212]** Optional parameter to define the max vehicle height in meters. (optional, default `1.6`) * `config.maxWidth` **[number][212]** Optional parameter to define the max vehicle width in meters. (optional, default `1.9`) * `config.maxWeight` **[number][212]** Optional parameter to define the max vehicle weight in metric tons. (optional, default `2.5`) * `config.notifications` **[String][208]** Returns notification metadata associated with the route leg of the route object. (optional, default `"all"`) * `config.departAt` **[String][208]?** Optional parameter to define the departure time, formatted as a timestamp in ISO-8601 format in the local time at the route origin. * `config.arriveBy` **[String][208]?** Optional parameter to define the desired arrival time, formatted as a timestamp in ISO-8601 format in the local time at the route destination. #### Examples ```javascript directionsClient.getDirections({ profile: 'driving-traffic', waypoints: [ { coordinates: [13.4301, 52.5109], approach: 'unrestricted' }, { coordinates: [13.4265, 52.508] }, { coordinates: [13.4194, 52.5072], bearing: [100, 60] } ] }) .send() .then(response => { const directions = response.body; }); ``` Returns **MapiRequest** ## MapMatching Map Matching API service. Learn more about this service and its responses in [the HTTP service documentation][248]. ### getMatch Snap recorded location traces to roads and paths. #### Parameters * `config` **[Object][207]** * `config.points` **[Array][216]<[MapMatchingPoint][176]>** An ordered array of [`MapMatchingPoint`][176]s, between 2 and 100 (inclusive). * `config.profile` **(`"driving-traffic"` | `"driving"` | `"walking"` | `"cycling"`)** A directions profile ID. (optional, default `driving`) * `config.annotations` **[Array][216]<(`"duration"` | `"distance"` | `"speed"`)>?** Specify additional metadata that should be returned. * `config.geometries` **(`"geojson"` | `"polyline"` | `"polyline6"`)** Format of the returned geometry. (optional, default `"polyline"`) * `config.language` **[string][208]** Language of returned turn-by-turn text instructions. See [supported languages][247]. (optional, default `"en"`) * `config.overview` **(`"simplified"` | `"full"` | `"false"`)** Type of returned overview geometry. (optional, default `"simplified"`) * `config.steps` **[boolean][209]** Whether to return steps and turn-by-turn instructions. (optional, default `false`) * `config.tidy` **[boolean][209]** Whether or not to transparently remove clusters and re-sample traces for improved map matching results. (optional, default `false`) #### Examples ```javascript mapMatchingClient.getMatch({ points: [ { coordinates: [-117.17283, 32.712041], approach: 'curb' }, { coordinates: [-117.17291, 32.712256], isWaypoint: false }, { coordinates: [-117.17292, 32.712444] }, { coordinates: [-117.172922, 32.71257], waypointName: 'point-a', approach: 'unrestricted' }, { coordinates: [-117.172985, 32.7126] }, { coordinates: [-117.173143, 32.712597] }, { coordinates: [-117.173345, 32.712546] } ], tidy: false, }) .send() .then(response => { const matching = response.body; }) ``` Returns **MapiRequest** ## Matrix Map Matching API service. Learn more about this service and its responses in [the HTTP service documentation][249]. ### getMatrix Get a duration and/or distance matrix showing travel times and distances between coordinates. #### Parameters * `config` **[Object][207]** * `config.points` **[Array][216]<[MatrixPoint][178]>** An ordered array of [`MatrixPoint`][178]s, between 2 and 100 (inclusive). * `config.profile` **(`"driving-traffic"` | `"driving"` | `"walking"` | `"cycling"`)** A Mapbox Directions routing profile ID. (optional, default `driving`) * `config.sources` **(`"all"` | [Array][216]<[number][212]>)?** Use coordinates with given index as sources. * `config.destinations` **(`"all"` | [Array][216]<[number][212]>)?** Use coordinates with given index as destinations. * `config.annotations` **[Array][216]<(`"distance"` | `"duration"`)>?** Used to specify resulting matrices. #### Examples ```javascript matrixClient.getMatrix({ points: [ { coordinates: [2.2, 1.1] }, { coordinates: [2.2, 1.1], approach: 'curb' }, { coordinates: [3.2, 1.1] }, { coordinates: [4.2, 1.1] } ], profile: 'walking' }) .send() .then(response => { const matrix = response.body; }); ``` Returns **MapiRequest** ## Optimization Optimization API service. Learn more about this service and its responses in [the HTTP service documentation][250]. ### getOptimization Get a duration-optimized route. Please read [the full HTTP service documentation][250] to understand all of the available options. #### Parameters * `config` **[Object][207]** * `config.profile` **(`"driving"` | `"driving-traffic"` | `"walking"` | `"cycling"`)** (optional, default `"driving"`) * `config.waypoints` **[Array][216]<[OptimizationWaypoint][180]>** An ordered array of [`OptimizationWaypoint`][180] objects, with at least 2 * `config.annotations` **[Array][216]<(`"duration"` | `"distance"` | `"speed"`)>?** Specify additional metadata that should be returned. * `config.destination` **(`"any"` | `"last"`)** Returned route ends at `any` or `last` coordinate. (optional, default `"any"`) * `config.distributions` **[Array][216]<[Distribution][203]>?** An ordered array of [`Distribution`][203] objects, each of which includes a `pickup` and `dropoff` property. `pickup` and `dropoff` properties correspond to an index in the OptimizationWaypoint array. * `config.geometries` **(`"geojson"` | `"polyline"` | `"polyline6"`)** Format of the returned geometries. (optional, default `"polyline"`) * `config.language` **[string][208]** Language of returned turn-by-turn text instructions. See options listed in [the HTTP service documentation][247]. (optional, default `"en"`) * `config.overview` **(`"simplified"` | `"full"` | `"false"`)** Type of returned overview geometry. (optional, default `"simplified"`) * `config.roundtrip` **[boolean][209]** Specifies whether the trip should complete by returning to the first location. (optional, default `true`) * `config.source` **(`"any"` | `"first"`)** To begin the route, start either from the first coordinate or let the Optimization API choose. (optional, default `"any"`) * `config.steps` **[boolean][209]** Whether to return steps and turn-by-turn instructions. (optional, default `false`) Returns **MapiRequest** ## Tokens Tokens API service. Learn more about this service and its responses in [the HTTP service documentation][251]. ### listTokens List your access tokens. See the [corresponding HTTP service documentation][252]. #### Examples ```javascript tokensClient.listTokens() .send() .then(response => { const tokens = response.body; }); ``` Returns **MapiRequest** ### createToken Create a new access token. See the [corresponding HTTP service documentation][253]. #### Parameters * `config` **[Object][207]?** * `config.note` **[string][208]?** * `config.scopes` **[Array][216]<[string][208]>?** * `config.resources` **[Array][216]<[string][208]>?** * `config.allowedUrls` **[Array][216]<[string][208]>?** * `config.allowedApplications` **[Array][216]<{platform: [string][208], bundleId: [string][208]}>?** This option restricts tokens with an Application Bundle ID. The feature is in beta and is only available to our selected customers. For more information, please contact sales. #### Examples ```javascript tokensClient.createToken({ note: 'datasets-token', scopes: ['datasets:write', 'datasets:read'] }) .send() .then(response => { const token = response.body; }); ``` Returns **MapiRequest** ### createTemporaryToken Create a new temporary access token. See the [corresponding HTTP service documentation][254]. #### Parameters * `config` **[Object][207]** * `config.expires` **[string][208]** * `config.scopes` **[Array][216]<[string][208]>** #### Examples ```javascript tokensClient.createTemporaryToken({ scopes: ['datasets:write', 'datasets:read'] }) .send() .then(response => { const token = response.body; }); ``` Returns **MapiRequest** ### updateToken Update an access token. See the [corresponding HTTP service documentation][255]. #### Parameters * `config` **[Object][207]** * `config.tokenId` **[string][208]** * `config.note` **[string][208]?** * `config.scopes` **[Array][216]<[string][208]>?** * `config.resources` **[Array][216]<[string][208]>?** * `config.allowedUrls` **([Array][216]<[string][208]> | null)?** * `config.allowedApplications` **([Array][216]<{platform: [string][208], bundleId: [string][208]}> | null)?** This option restricts tokens with an Application Bundle ID. The feature is in beta and is only available to our selected customers. For more information, please contact sales. #### Examples ```javascript tokensClient.updateToken({ tokenId: 'cijucimbe000brbkt48d0dhcx', note: 'datasets-token', scopes: ['datasets:write', 'datasets:read'] }) .send() .then(response => { const token = response.body; }); ``` Returns **MapiRequest** ### getToken Get data about the client's access token. See the [corresponding HTTP service documentation][256]. #### Examples ```javascript tokensClient.getToken() .send() .then(response => { const token = response.body; }); ``` Returns **MapiRequest** ### deleteToken Delete an access token. See the [corresponding HTTP service documentation][257]. #### Parameters * `config` **[Object][207]** * `config.tokenId` **[string][208]** #### Examples ```javascript tokensClient.deleteToken({ tokenId: 'cijucimbe000brbkt48d0dhcx' }) .send() .then(response => { // Token successfully deleted. }); ``` Returns **MapiRequest** ### listScopes List your available scopes. Each item is a metadata object about the scope, not just the string scope. See the [corresponding HTTP service documentation][258]. #### Examples ```javascript tokensClient.listScopes() .send() .then(response => { const scopes = response.body; }); ``` Returns **MapiRequest** ## Data structures Data structures used in service method configuration. ### DirectionsWaypoint Type: [Object][207] #### Properties * `coordinates` **[Coordinates][191]** * `approach` **(`"unrestricted"` | `"curb"`)?** Used to indicate how requested routes consider from which side of the road to approach the waypoint. * `bearing` **\[[number][212], [number][212]]?** 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 a `radius`. The first value is an angle clockwise from true north between 0 and 360, and the second is the range of degrees the angle can deviate by. * `radius` **([number][212] | `"unlimited"`)?** Maximum distance in meters that the coordinate is allowed to move when snapped to a nearby road segment. * `waypointName` **[string][208]?** Custom name for the waypoint used for the arrival instruction in banners and voice instructions. ### MapMatchingPoint Type: [Object][207] #### Properties * `coordinates` **[Coordinates][191]** * `approach` **(`"unrestricted"` | `"curb"`)?** Used to indicate how requested routes consider from which side of the road to approach a waypoint. * `radius` **[number][212]?** A number in meters indicating the assumed precision of the used tracking device. * `isWaypoint` **[boolean][209]?** Whether this coordinate is waypoint or not. The first and last coordinates will always be waypoints. * `waypointName` **[string][208]?** Custom name for the waypoint used for the arrival instruction in banners and voice instructions. Will be ignored unless `isWaypoint` is `true`. * `timestamp` **([string][208] | [number][212] | [Date][213])?** Datetime corresponding to the coordinate. ### MatrixPoint Type: [Object][207] #### Properties * `coordinates` **[Coordinates][191]** `[longitude, latitude]` * `approach` **(`"unrestricted"` | `"curb"`)?** Used to indicate how requested routes consider from which side of the road to approach the point. ### OptimizationWaypoint Type: [Object][207] #### Properties * `coordinates` **[Coordinates][191]** * `approach` **(`"unrestricted"` | `"curb"`)?** Used to indicate how requested routes consider from which side of the road to approach the waypoint. * `bearing` **\[[number][212], [number][212]]?** 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 a `radius`. The first value is an angle clockwise from true north between 0 and 360, and the second is the range of degrees the angle can deviate by. * `radius` **([number][212] | `"unlimited"`)?** Maximum distance in meters that the coordinate is allowed to move when snapped to a nearby road segment. ### SimpleMarkerOverlay A simple marker overlay. Type: [Object][207] #### Properties * `marker` **[Object][207]** * `marker.coordinates` **\[[number][212], [number][212]]** `[longitude, latitude]` * `marker.size` **(`"large"` | `"small"`)?** * `marker.label` **[string][208]?** Marker symbol. Options are an alphanumeric label `a` through `z`, `0` through `99`, or a valid [Maki][259] icon. If a letter is requested, it will be rendered in uppercase only. * `marker.color` **[string][208]?** A 3- or 6-digit hexadecimal color code. ### CustomMarkerOverlay A marker overlay with a custom image. Type: [Object][207] #### Properties * `marker` **[Object][207]** * `marker.coordinates` **\[[number][212], [number][212]]** `[longitude, latitude]` * `marker.url` **[string][208]** ### PathOverlay A stylable line. Type: [Object][207] #### Properties * `path` **[Object][207]** * `path.coordinates` **[Array][216]<[Coordinates][191]>** An array of coordinates describing the path. * `path.strokeWidth` **[number][212]?** * `path.strokeColor` **[string][208]?** * `path.strokeOpacity` **[number][212]?** Must be paired with strokeColor. * `path.fillColor` **[string][208]?** Must be paired with strokeColor. * `path.fillOpacity` **[number][212]?** Must be paired with fillColor. ### GeoJsonOverlay GeoJSON to overlay the map. Type: [Object][207] #### Properties * `geoJson` **[Object][207]** Valid GeoJSON. ### UploadableFile In Node, files must be `ReadableStream`s or paths pointing for the file in the filesystem. In the browser, files must be `Blob`s or `ArrayBuffer`s. Type: ([Blob][260] | [ArrayBuffer][261] | [string][208] | ReadableStream) ### Coordinates `[longitude, latitude]` Type: [Array][216]<[number][212]> ### BoundingBox `[minLongitude, minLatitude, maxLongitude, maxLatitude]` Type: [Array][216]<[number][212]> ## Isochrone Isochrone API service. Learn more about this service and its responses in [the HTTP service documentation][262]. ### getContours Given a location and a routing profile, retrieve up to four isochrone contours #### Parameters * `config` **[Object][207]** * `config.profile` **(`"driving"` | `"driving-traffic"` | `"walking"` | `"cycling"`)** A Mapbox Directions routing profile ID. (optional, default `"driving"`) * `config.coordinates` **[Coordinates][191]** A {longitude,latitude} coordinate pair around which to center the isochrone lines. * `config.minutes` **[Array][216]<[number][212]>?** The times in minutes to use for each isochrone contour. You can specify up to four contours. Times must be in increasing order. The maximum time that can be specified is 60 minutes. Setting minutes and meters in the same time is an error. * `config.meters` **[Array][216]<[number][212]>?** The distances in meters to use for each isochrone contour. You can specify up to four contours. Distances must be in increasing order. The maximum distance that can be specified is 100000 meters. Setting minutes and meters in the same time is an error. * `config.colors` **[Array][216]<[string][208]>?** The colors to use for each isochrone contour, specified as hex values without a leading # (for example, ff0000 for red). If this parameter is used, there must be the same number of colors as there are entries in contours\_minutes or contours\_meters. If no colors are specified, the Isochrone API will assign a default rainbow color scheme to the output. * `config.polygons` **[boolean][209]?** Specify whether to return the contours as GeoJSON polygons (true) or linestrings (false, default). When polygons=true, any contour that forms a ring is returned as a polygon. * `config.denoise` **[number][212]?** A floating point value from 0.0 to 1.0 that can be used to remove smaller contours. The default is 1.0. A value of 1.0 will only return the largest contour for a given time value. A value of 0.5 drops any contours that are less than half the area of the largest contour in the set of contours for that same time value. * `config.generalize` **[number][212]?** A positive floating point value in meters used as the tolerance for Douglas-Peucker generalization. There is no upper bound. If no value is specified in the request, the Isochrone API will choose the most optimized generalization to use for the request. Note that the generalization of contours can lead to self-intersections, as well as intersections of adjacent contours. Returns **MapiRequest** ## GeocodingV6 Geocoding API service. Learn more about this service and its responses in [the HTTP service documentation][263]. ### forwardGeocode Search for a place. See the [public documentation][264]. #### Parameters * `config` **[Object][207]** * `config.query` **[string][208]** A place name. * `config.mode` **(`"standard"` | `"structured"`)** Either `standard` for common forward geocoding, or `structured` for increasing the accuracy of results. To use Structured Input, the query parameter must be dropped in favor of a separate parameter for individual feature components. (optional, default `"standard"`) * `config.countries` **([Array][216]<[string][208]> | [string][208])?** Limits results to the specified countries. Each item in the array should be an [ISO 3166 alpha 2 country code][242]. \[OR] if used with input mode="structured" denotes single country in free form. * `config.proximity` **([Coordinates][191] | `"ip"`)?** Bias local results based on a provided coordinate location or a user's IP address. * `config.types` **[Array][216]<(`"street"` | `"country"` | `"region"` | `"postcode"` | `"district"` | `"place"` | `"locality"` | `"neighborhood"` | `"address"` | `"secondary_address"`)>?** Filter results by feature types. * `config.bbox` **[BoundingBox][192]?** Limit results to a bounding box. * `config.limit` **[number][212]** Limit the number of results returned. (optional, default `5`) * `config.format` **(`"geojson"` | `"v5"`)** Specify the desired response format of results (geojson, default) or for backwards compatibility (v5). (optional, default `'geojson'`) * `config.language` **[String][208]?** Specify the language to use for response text and, for forward geocoding, query result weighting. Options are [IETF language tags][243] comprised of a mandatory [ISO 639-1 language code][244] and optionally one or more IETF subtags for country or script. * `config.address_line1` **[String][208]?** A string including address\_number and street. These values can alternatively be provided as separate parameters. (Stuctured Input specific field) * `config.address_number` **[String][208]?** The number associated with the house (Stuctured Input specific field) * `config.street` **[String][208]?** The name of the street in the address (Stuctured Input specific field) * `config.block` **[String][208]?** In some countries like Japan, the block is a component in the address (Stuctured Input specific field) * `config.place` **[String][208]?** Typically these are cities, villages, municipalities, etc. (Stuctured Input specific field) * `config.region` **[String][208]?** Top-level sub-national administrative features, such as states in the United States or provinces in Canada or China. (Stuctured Input specific field) * `config.neighborhood` **[String][208]?** Colloquial sub-city features often referred to in local parlance (Stuctured Input specific field) * `config.postcode` **[String][208]?** Postal codes used in country-specific national addressing systems. (Stuctured Input specific field) * `config.locality` **[String][208]?** Official sub-city features (Stuctured Input specific field) * `config.autocomplete` **[boolean][209]** Return autocomplete results or not. (optional, default `true`) * `config.permanent` **[boolean][209]** Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely. (optional, default `false`) * `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`) * `config.session_token` **[String][208]?** A unique session identifier generated by the client. #### Examples ```javascript geocodingClient.forwardGeocode({ query: 'Paris, France', limit: 2 }) .send() .then(response => { const match = response.body; }); ``` ```javascript // geocoding in structured input mode geocodingClient.forwardGeocode({ mode: 'structured', address_number: '12', street: 'Main str.' }) .send() .then(response => { const match = response.body; }); ``` ```javascript // geocoding with proximity geocodingClient.forwardGeocode({ query: 'Paris, France', proximity: [-95.4431142, 33.6875431] }) .send() .then(response => { const match = response.body; }); // geocoding with countries geocodingClient.forwardGeocode({ query: 'Paris, France', countries: ['fr'] }) .send() .then(response => { const match = response.body; }); // geocoding with bounding box geocodingClient.forwardGeocode({ query: 'Paris, France', bbox: [2.14, 48.72, 2.55, 48.96] }) .send() .then(response => { const match = response.body; }); ``` Returns **MapiRequest** ### reverseGeocode Search for places near coordinates. See the [public documentation][265]. #### Parameters * `config` **[Object][207]** * `config.longitude` **[number][212]** longitude coordinate at which features will be searched. * `config.latitude` **[number][212]** latitude coordinate at which features will be searched. * `config.countries` **[Array][216]<[string][208]>?** Limits results to the specified countries. Each item in the array should be an [ISO 3166 alpha 2 country code][242]. * `config.types` **[Array][216]<(`"street"` | `"country"` | `"region"` | `"postcode"` | `"district"` | `"place"` | `"locality"` | `"neighborhood"` | `"address"`)>?** Filter results by feature types. * `config.bbox` **[BoundingBox][192]?** Limit results to a bounding box. * `config.limit` **[number][212]** Limit the number of results returned. If using this option, you must provide a single item for `types`. (optional, default `1`) * `config.language` **[string][208]?** Specify the language to use for response text and, for forward geocoding, query result weighting. Options are [IETF language tags][243] comprised of a mandatory [ISO 639-1 language code][244] and optionally one or more IETF subtags for country or script. * `config.permanent` **[boolean][209]** Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely. (optional, default `false`) * `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`) * `config.session_token` **[String][208]?** A unique session identifier generated by the client. #### Examples ```javascript geocodingClient.reverseGeocode({ longitude: -73.990593, latitude: 40.740121 }) .send() .then(response => { // GeoJSON document with geocoding matches const match = response.body; }); ``` Returns **MapiRequest** ## Distribution Type: [Object][207] ### Properties * `pickup` **[number][212]** Array index of the item containing coordinates for the pick-up location in the OptimizationWaypoint array. * `dropoff` **[number][212]** Array index of the item containing coordinates for the drop-off location in the OptimizationWaypoint array. [1]: #styles [2]: #getstyle [3]: #parameters [4]: #examples [5]: #createstyle [6]: #parameters-1 [7]: #examples-1 [8]: #updatestyle [9]: #parameters-2 [10]: #examples-2 [11]: #deletestyle [12]: #parameters-3 [13]: #examples-3 [14]: #liststyles [15]: #parameters-4 [16]: #examples-4 [17]: #putstyleicon [18]: #parameters-5 [19]: #examples-5 [20]: #deletestyleicon [21]: #parameters-6 [22]: #examples-6 [23]: #getstylesprite [24]: #parameters-7 [25]: #examples-7 [26]: #getfontglyphrange [27]: #parameters-8 [28]: #examples-8 [29]: #getembeddablehtml [30]: #parameters-9 [31]: #static [32]: #getstaticimage [33]: #parameters-10 [34]: #examples-9 [35]: #uploads [36]: #listuploads [37]: #parameters-11 [38]: #examples-10 [39]: #createuploadcredentials [40]: #examples-11 [41]: #createupload [42]: #parameters-12 [43]: #examples-12 [44]: #getupload [45]: #parameters-13 [46]: #examples-13 [47]: #deleteupload [48]: #parameters-14 [49]: #examples-14 [50]: #datasets [51]: #listdatasets [52]: #parameters-15 [53]: #examples-15 [54]: #createdataset [55]: #parameters-16 [56]: #examples-16 [57]: #getmetadata [58]: #parameters-17 [59]: #examples-17 [60]: #updatemetadata [61]: #parameters-18 [62]: #examples-18 [63]: #deletedataset [64]: #parameters-19 [65]: #examples-19 [66]: #listfeatures [67]: #parameters-20 [68]: #examples-20 [69]: #putfeature [70]: #parameters-21 [71]: #examples-21 [72]: #getfeature [73]: #parameters-22 [74]: #examples-22 [75]: #deletefeature [76]: #parameters-23 [77]: #examples-23 [78]: #tilequery [79]: #listfeatures-1 [80]: #parameters-24 [81]: #examples-24 [82]: #tilesets [83]: #listtilesets [84]: #parameters-25 [85]: #examples-25 [86]: #deletetileset [87]: #parameters-26 [88]: #examples-26 [89]: #tilejsonmetadata [90]: #parameters-27 [91]: #createtilesetsource [92]: #parameters-28 [93]: #examples-27 [94]: #gettilesetsource [95]: #parameters-29 [96]: #examples-28 [97]: #listtilesetsources [98]: #parameters-30 [99]: #examples-29 [100]: #deletetilesetsource [101]: #parameters-31 [102]: #examples-30 [103]: #createtileset [104]: #parameters-32 [105]: #examples-31 [106]: #publishtileset [107]: #parameters-33 [108]: #examples-32 [109]: #updatetileset [110]: #parameters-34 [111]: #examples-33 [112]: #tilesetstatus [113]: #parameters-35 [114]: #examples-34 [115]: #tilesetjob [116]: #parameters-36 [117]: #examples-35 [118]: #listtilesetjobs [119]: #parameters-37 [120]: #examples-36 [121]: #gettilesetsqueue [122]: #examples-37 [123]: #validaterecipe [124]: #parameters-38 [125]: #examples-38 [126]: #getrecipe [127]: #parameters-39 [128]: #examples-39 [129]: #updaterecipe [130]: #parameters-40 [131]: #examples-40 [132]: #geocoding [133]: #forwardgeocode [134]: #parameters-41 [135]: #examples-41 [136]: #reversegeocode [137]: #parameters-42 [138]: #examples-42 [139]: #directions [140]: #getdirections [141]: #parameters-43 [142]: #examples-43 [143]: #mapmatching [144]: #getmatch [145]: #parameters-44 [146]: #examples-44 [147]: #matrix [148]: #getmatrix [149]: #parameters-45 [150]: #examples-45 [151]: #optimization [152]: #getoptimization [153]: #parameters-46 [154]: #tokens [155]: #listtokens [156]: #examples-46 [157]: #createtoken [158]: #parameters-47 [159]: #examples-47 [160]: #createtemporarytoken [161]: #parameters-48 [162]: #examples-48 [163]: #updatetoken [164]: #parameters-49 [165]: #examples-49 [166]: #gettoken [167]: #examples-50 [168]: #deletetoken [169]: #parameters-50 [170]: #examples-51 [171]: #listscopes [172]: #examples-52 [173]: #data-structures [174]: #directionswaypoint [175]: #properties [176]: #mapmatchingpoint [177]: #properties-1 [178]: #matrixpoint [179]: #properties-2 [180]: #optimizationwaypoint [181]: #properties-3 [182]: #simplemarkeroverlay [183]: #properties-4 [184]: #custommarkeroverlay [185]: #properties-5 [186]: #pathoverlay [187]: #properties-6 [188]: #geojsonoverlay [189]: #properties-7 [190]: #uploadablefile [191]: #coordinates [192]: #boundingbox [193]: #isochrone [194]: #getcontours [195]: #parameters-51 [196]: #geocodingv6 [197]: #forwardgeocode-1 [198]: #parameters-52 [199]: #examples-53 [200]: #reversegeocode-1 [201]: #parameters-53 [202]: #examples-54 [203]: #distribution [204]: #properties-8 [205]: https://docs.mapbox.com/api/maps/#styles [206]: https://docs.mapbox.com/api/maps/#retrieve-a-style [207]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object [208]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [209]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [210]: https://docs.mapbox.com/api/maps/#create-a-style [211]: https://docs.mapbox.com/api/maps/#update-a-style [212]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number [213]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date [214]: https://docs.mapbox.com/api/maps/#retrieve-a-sprite-image-or-json [215]: https://docs.mapbox.com/api/maps/#retrieve-font-glyph-ranges [216]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array [217]: https://docs.mapbox.com/api/maps/#request-embeddable-html [218]: https://docs.mapbox.com/mapbox-gl-js/api/ [219]: https://github.com/mapbox/mapbox-gl-geocoder [220]: https://docs.mapbox.com/api/maps/#static-images [221]: https://docs.mapbox.com/api/maps/#uploads [222]: https://docs.mapbox.com/api/maps/#retrieve-recent-upload-statuses [223]: https://docs.mapbox.com/api/maps/#retrieve-s3-credentials [224]: https://docs.mapbox.com/api/maps/#create-an-upload [225]: https://docs.mapbox.com/api/maps/#retrieve-upload-status [226]: https://docs.mapbox.com/api/maps/#remove-an-upload-status [227]: https://docs.mapbox.com/api/maps/#datasets [228]: https://docs.mapbox.com/api/maps/#list-datasets [229]: https://docs.mapbox.com/api/maps/#create-a-dataset [230]: https://docs.mapbox.com/api/maps/#retrieve-a-dataset [231]: https://docs.mapbox.com/api/maps/#update-a-dataset [232]: https://docs.mapbox.com/api/maps/#delete-a-dataset [233]: https://docs.mapbox.com/api/maps/#list-features [234]: https://docs.mapbox.com/api/maps/#insert-or-update-a-feature [235]: https://docs.mapbox.com/api/maps/#retrieve-a-feature [236]: https://docs.mapbox.com/api/maps/#delete-a-feature [237]: https://docs.mapbox.com/api/maps/#tilequery [238]: https://docs.mapbox.com/api/maps/#tilesets [239]: https://docs.mapbox.com/help/troubleshooting/tileset-recipe-reference/ [240]: https://docs.mapbox.com/api/search/#geocoding [241]: https://docs.mapbox.com/api/search/#forward-geocoding [242]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 [243]: https://en.wikipedia.org/wiki/IETF_language_tag [244]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes [245]: https://docs.mapbox.com/api/search/#reverse-geocoding [246]: https://docs.mapbox.com/api/navigation/#directions [247]: https://docs.mapbox.com/api/navigation/#instructions-languages [248]: https://docs.mapbox.com/api/navigation/#map-matching [249]: https://docs.mapbox.com/api/navigation/#matrix [250]: https://docs.mapbox.com/api/navigation/#optimization [251]: https://docs.mapbox.com/api/accounts/#tokens [252]: https://docs.mapbox.com/api/accounts/#list-tokens [253]: https://docs.mapbox.com/api/accounts/#create-a-token [254]: https://docs.mapbox.com/api/accounts/#create-a-temporary-token [255]: https://docs.mapbox.com/api/accounts/#update-a-token [256]: https://docs.mapbox.com/api/accounts/#retrieve-a-token [257]: https://docs.mapbox.com/api/accounts/#delete-a-token [258]: https://docs.mapbox.com/api/accounts/#list-scopes [259]: https://www.mapbox.com/maki/ [260]: https://developer.mozilla.org/docs/Web/API/Blob [261]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer [262]: https://docs.mapbox.com/api/navigation/#isochrone [263]: https://docs.mapbox.com/api/search/geocoding-v6/ [264]: https://docs.mapbox.com/api/search/geocoding-v6/#forward-geocoding [265]: https://docs.mapbox.com/api/search/geocoding-v6/#reverse-geocoding