### Configure Claude Desktop for Mapbox MCP Server Source: https://docs.mapbox.com/api/guides/mcp-server/ Example JSON configuration for Claude Desktop to connect to a Mapbox MCP Server. This setup specifies the Node.js command to run the MCP server and provides the Mapbox Access Token via environment variables. ```json { "mcpServers": { "MapboxServer": { "command": "node", "args": ["/Users/username/github-projects/mcp-server/dist/index.js"], "env": { "MAPBOX_ACCESS_TOKEN": "YOUR_MAPBOX_ACCESS_TOKEN" } } } } ``` -------------------------------- ### Mapbox Datasets Feature Management Examples Source: https://docs.mapbox.com/api/maps/datasets/ Command-line examples for interacting with Mapbox Datasets API to manage features. ```curl # Insert or update a feature $curl "https://api.mapbox.com/datasets/v1/YOUR_MAPBOX_USERNAME/{dataset_id}/features/{feature_id}?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \ -X PUT \ -H "Content-Type: application/json" \ -d @file.geojson # Retrieve a feature $curl "https://api.mapbox.com/datasets/v1/YOUR_MAPBOX_USERNAME/{dataset_id}/features/{feature_id}?access_token=YOUR_MAPBOX_ACCESS_TOKEN" ``` -------------------------------- ### Example Response: Create a changeset Source: https://docs.mapbox.com/api/maps/mapbox-tiling-service/ An example JSON response structure for creating or appending to a Mapbox changeset. ```json { "file_size": 10592, "files": 1, "id": "mapbox://tileset-changeset/username/hello-world", "source_size": 10592 } ``` -------------------------------- ### Install with NPM Source: https://github.com/mapbox/pixelmatch Command to install the pixelmatch library using npm for Node.js projects. ```bash npm install pixelmatch ``` -------------------------------- ### Install Mapbox CLI with Pip (Python) Source: https://github.com/mapbox/mapbox-cli-py Instructions for installing the Mapbox CLI for users familiar with Python. It is recommended to use a virtual environment before installation. ```bash virtualenv venv source venv/bin/activate pip install mapbox-cli-py ``` -------------------------------- ### Install Mapbox SDK Source: https://github.com/mapbox/mapbox-sdk-js Installs the Mapbox SDK for JavaScript using npm. Ensure you have Node.js and npm installed. For older browsers, a Promise polyfill like es6-promise might be required. ```bash npm install @mapbox/mapbox-sdk ``` -------------------------------- ### Install mapbox-sdk Gem Source: https://github.com/mapbox/mapbox-sdk-rb Installs the mapbox-sdk gem for Ruby, allowing integration with Mapbox services. ```bash gem install mapbox-sdk ``` -------------------------------- ### Install mapbox-sdk Gem Source: https://github.com/mapbox/mapbox-sdk-rb Installs the mapbox-sdk gem for Ruby, which provides an interface to various Mapbox APIs. ```ruby gem install mapbox-sdk ``` -------------------------------- ### Install MCP Server Dependencies Source: https://docs.mapbox.com/api/guides/mcp-server/ This command uses npm (Node Package Manager) to install all the necessary libraries and dependencies required for the Mapbox MCP Server to run. Ensure Node.js and npm are installed on your system before running this. ```bash npm install ``` -------------------------------- ### Install Mapbox CLI Source: https://github.com/mapbox/mapbox-cli-py Installs the mapboxcli Python package. Supports local installation with or without a virtual environment, and global installation (not recommended). ```shell pip install mapboxcli ``` ```shell pip install --user mapboxcli ``` ```shell sudo pip install mapboxcli ``` -------------------------------- ### Example Request: Create Tileset Source Source: https://docs.mapbox.com/api/maps/mapbox-tiling-service/ An example using curl to send a POST request to create a tileset source, uploading a GeoJSON file to Mapbox Tiling Service. ```curl $ curl -X POST "https://api.mapbox.com/tilesets/v1/sources/YOUR_MAPBOX_USERNAME/hello-world?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \ -F file=@/Users/username/data/mts/countries.geojson.ld \ --header "Content-Type: multipart/form-data" ``` -------------------------------- ### Pixelmatch Node.js Example Source: https://github.com/mapbox/pixelmatch Provides an example of using pixelmatch within a Node.js application. It requires the 'fs' module for file system operations, 'pngjs' for reading PNG files, and 'pixelmatch' itself. The example shows reading two PNG images and preparing them for comparison. ```javascript import fs from 'fs'; import {PNG} from 'pngjs'; import pixelmatch from 'pixelmatch'; const img1 = PNG.sync.read(fs.readFileSync('img1.png')); const img2 = PNG.sync.read ``` -------------------------------- ### Install pixelmatch via npm Source: https://github.com/mapbox/pixelmatch Installs the pixelmatch library using npm, the Node Package Manager. This is the standard way to add the library to your JavaScript project. ```bash npm install pixelmatch ``` -------------------------------- ### Install Mapbox SDK Source: https://github.com/mapbox/mapbox-sdk-js Installs the Mapbox SDK for JavaScript using npm. This command is used to add the SDK to your project's dependencies. ```bash npm install @mapbox/mapbox-sdk ``` -------------------------------- ### Example Request (curl) Source: https://docs.mapbox.com/api/navigation/ev-charge-finder/ An example command using curl to fetch details of a charge point near San Jose Airport, demonstrating the API endpoint and parameter usage. ```shell # Get details of a charge point near San Jose Airport. curl "https://api.mapbox.com/ev/v1/locations/dXJuOm1ieGV2OmY3Y2E2ZmNlLTZjYTAtMTFlZC1hYjVjLWEwNDIzZjQyYWYwNjtzcmM9NA?access_token=YOUR_MAPBOX_ACCESS_TOKEN" ``` -------------------------------- ### Install Pixelmatch via NPM Source: https://github.com/mapbox/pixelmatch Installs the pixelmatch library using the Node Package Manager (npm). This is the standard way to add the library to a JavaScript project for server-side or build-tool environments. ```shell npm install pixelmatch ``` -------------------------------- ### Example Response: Append to Changeset Source: https://docs.mapbox.com/api/maps/mapbox-tiling-service/ An example JSON response structure indicating the details of a successfully appended changeset, including file size, number of files, changeset ID, and source size. ```json { "file_size": 10592, "files": 2, "id": "mapbox://tileset-changeset/username/hello-world", "source_size": 20884 } ``` -------------------------------- ### Mapbox Tilequery API Example Requests Source: https://docs.mapbox.com/api/maps/tilequery/ Provides example cURL commands for querying Mapbox Tilequery API with rasterarray tilesets. Demonstrates how to specify bands, layers, and query multiple tilesets. ```curl # Retrieve point specific features for multiple bands from a single layer curl "https://api.mapbox.com/v4/{tileset_id}/tilequery/-122.42901,37.80633.json?bands=1663516800,1663520400&layers=temperature&access_token=YOUR_MAPBOX_ACCESS_TOKEN" ``` ```curl # Query multiple tilesets curl "https://api.mapbox.com/v4/{tileset_id_1},{tileset_id_2},{tileset_id_3}/tilequery/-122.42901,37.80633.json?bands=1663516800,1663520400&layers=temperature&access_token=YOUR_MAPBOX_ACCESS_TOKEN" ``` -------------------------------- ### Specify Departure Time Source: https://docs.mapbox.com/api/navigation/directions/ Example curl request to get directions for driving, specifying a departure time to account for traffic conditions. ```shell # Specify a departure time curl "https://api.mapbox.com/directions/v5/mapbox/driving/-122.396112,37.791399;-122.433904,37.757812?access_token=YOUR_MAPBOX_ACCESS_TOKEN&depart_at=2019-05-02T15:00" ``` -------------------------------- ### Mapbox SDK Initialization and Request Sending Source: https://github.com/mapbox/mapbox-sdk-js Demonstrates initializing the Mapbox SDK client with an access token, creating service instances for styles and tilesets, and sending requests using the .send() method. Includes examples for creating a style and listing tilesets, showing how to handle responses and errors with Promises. ```javascript const mbxClient = require('@mapbox/mapbox-sdk'); const mbxStyles = require('@mapbox/mapbox-sdk/services/styles'); const mbxTilesets = require('@mapbox/mapbox-sdk/services/tilesets'); const baseClient = mbxClient({ accessToken: MY_ACCESS_TOKEN }); const stylesService = mbxStyles(baseClient); const tilesetsService = mbxTilesets(baseClient); // Create a style. stylesService.createStyle({..}) .send() .then(response => {..}, error => {..}); // List tilesets. tilesetsService.listTilesets() .send() .then(response => {..}, error => {..}) ``` -------------------------------- ### Get Best Location Engine (Java/Kotlin) Source: https://docs.mapbox.com/android/core/guides/ Obtain the most suitable LocationEngine instance for Android using LocationEngineProvider.getBestLocationEngine(). This simplifies setup by abstracting away the underlying location provider. ```Java LocationEngine locationEngine = LocationEngineProvider.getBestLocationEngine(this); ``` ```Kotlin var locationEngine = LocationEngineProvider.getBestLocationEngine(this) ``` -------------------------------- ### Example Response: Create Tileset Source Source: https://docs.mapbox.com/api/maps/mapbox-tiling-service/ Illustrates the structure of a successful response when a new tileset source is created. ```APIDOC { "file_size": 10592, "files": 1, "id": "mapbox://tileset-source/username/hello-world", "source_size": 10592 } ``` -------------------------------- ### Initialize Theme from URL or Local Storage Source: https://docs.mapbox.com/resources/demos-and-projects/ This script initializes the website's theme. It first checks the URL query parameters for 'docusaurus-theme'. If not found, it attempts to retrieve the theme from local storage. The theme is then applied as a data attribute to the document element, defaulting to 'light' if no theme is specified. ```javascript function(){ var t,e=function(){ try{ return new URLSearchParams(window.location.search).get("docusaurus-theme") }catch(t){} }()||function(){ try{ return localStorage.getItem("theme") }catch(t){} }(); t=null!==e?e:"light",document.documentElement.setAttribute("data-theme",t) }() ``` -------------------------------- ### Docusaurus Data Attribute Setup Source: https://docs.mapbox.com/api/navigation/isochrone/ This JavaScript code snippet iterates through URL search parameters starting with 'docusaurus-data-' and sets corresponding data attributes on the document's root element. ```javascript function(){try{for(var\[t,e\]of new URLSearchParams(window.location.search).entries())if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}() ``` -------------------------------- ### Mapbox Search API: Get Category List Source: https://docs.mapbox.com/api/search/search-box/ Documentation for the Mapbox Search API's `/list/category` endpoint, which retrieves a list of available POI categories. Includes request parameters, example requests, and response structure. ```APIDOC Endpoint: GET https://api.mapbox.com/search/searchbox/v1/list/category Description: The request to the `/list/category` endpoint will return a list of all the available categories with their canonical ID and name in the `language` you specified. This endpoint does not describe parent/child relationships and cannot be used to infer relationships between categories. Parameters: Required: access_token (string): A Mapbox access token with default permissions. Optional: language (string): The ISO language code to be returned. If not provided, English (en) will be used as the default. Example Request: $curl -X GET "https://api.mapbox.com/search/searchbox/v1/list/category?access_token=YOUR_MAPBOX_ACCESS_TOKEN&language=en" Response Structure: The response will be a collection of category list items. Properties: list_items (array of objects): An array of category objects. Each item has: canonical_id (string): [required] The canonical category ID to use in a category “Hot Button” search. icon (string): [required] The Maki icon to use with the category. name (string): [required] The category name in the requested language. attribution (string): The attribution data for results. version (string): The service version information. ``` -------------------------------- ### Create a Service Client Source: https://github.com/mapbox/mapbox-sdk-js Demonstrates how to create a service client for a specific Mapbox service, such as Styles, by importing its factory function and providing an access token. ```javascript const mbxStyles = require('@mapbox/mapbox-sdk/services/styles'); const stylesService = mbxStyles({ accessToken: MY_ACCESS_TOKEN }); ``` -------------------------------- ### Share Base Client Across Services Source: https://github.com/mapbox/mapbox-sdk-js Shows how to initialize a base Mapbox client with an access token and then use that base client to create multiple service clients, promoting configuration sharing. ```javascript const mbxClient = require('@mapbox/mapbox-sdk'); const mbxStyles = require('@mapbox/mapbox-sdk/services/styles'); const mbxTilesets = require('@mapbox/mapbox-sdk/services/tilesets'); const baseClient = mbxClient({ accessToken: MY_ACCESS_TOKEN }); const stylesService = mbxStyles(baseClient); const tilesetsService = mbxTilesets(baseClient); ``` -------------------------------- ### List Mapbox Tilesets Source: https://github.com/mapbox/mapbox-sdk-js Demonstrates how to use the Mapbox SDK to list available tilesets. It initializes a client, calls the listTilesets method, and handles the response using promises. ```javascript mapboxClient.tilesets.listTilesets().send().then(..); mapboxClient.tilesets.listTilesets().send().then(..); ``` -------------------------------- ### Install Mapbox CLI with Homebrew Source: https://github.com/mapbox/mapbox-cli-py This command installs the Mapbox CLI for users on OS X using the Homebrew package manager. It's the recommended installation method for macOS. ```shell $ brew install mapbox/cli/mapbox ``` -------------------------------- ### Example EV Route Request using cURL Source: https://docs.mapbox.com/api/navigation/directions/ This snippet demonstrates how to request an Electric Vehicle (EV) route using the Mapbox Directions API via cURL. It specifies routing parameters such as starting and ending coordinates, EV-specific options like initial charge, maximum charge, connector types, energy consumption, and charging curves, along with an access token. ```shell $curl "https://api.mapbox.com/directions/v5/mapbox/driving/11.59838875578771,48.1498484882143;11.646071564986642,48.157168731123306.json?overview=false&alternatives=true&waypoints_per_route=true&engine=electric&ev_initial_charge=600&ev_max_charge=50000&ev_connector_types=ccs_combo_type1,ccs_combo_type2&energy_consumption_curve=0,300;20,160;80,140;120,180&ev_charging_curve=0,100000;40000,70000;60000,30000;80000,10000&ev_min_charge_at_charging_station=1&access_token=YOUR_MAPBOX_ACCESS_TOKEN" ``` -------------------------------- ### Share Base Client Across Mapbox SDK Services Source: https://github.com/mapbox/mapbox-sdk-js This example demonstrates a more efficient way to initialize multiple Mapbox SDK services by creating a single base client configuration first. This base client, containing common settings like the access token, is then passed to factory functions for individual services such as Styles and Tilesets, promoting code reuse and consistency. ```javascript const mbxClient = require('@mapbox/mapbox-sdk'); const mbxStyles = require('@mapbox/mapbox-sdk/services/styles'); const mbxTilesets = require('@mapbox/mapbox-sdk/services/tilesets'); const baseClient = mbxClient({ accessToken: MY_ACCESS_TOKEN }); const stylesService = mbxStyles(baseClient); const tilesetsService = mbxTilesets(baseClient); ``` -------------------------------- ### Install Mapbox CLI with Pip (Local User) Source: https://github.com/mapbox/mapbox-cli-py Installs the Mapbox CLI locally for the current user without a virtual environment. After installation, ensure that `~/.local/bin` is included in your system's PATH. ```python $ pip install --user mapboxcli ``` -------------------------------- ### Run All Tests Source: https://github.com/mapbox/mapbox-sdk-rb Command to execute the entire test suite for the Mapbox SDK for Ruby. Requires setting the Mapbox access token as an environment variable. ```Ruby MapboxAccessToken= bundle exec ruby -Itest test/all_tests.rb ``` -------------------------------- ### Initialize Mapbox Client with UMD build Source: https://github.com/mapbox/mapbox-sdk-js An example of initializing the Mapbox SDK client using a UMD build loaded via CDN. It creates a global `mapboxSdk` function to instantiate the client with an access token and access services. ```javascript var mapboxClient = mapboxSdk({ accessToken: MY_ACCESS_TOKEN }); // Example usage of services mapboxClient.styles.getStyle(..) // Replace .. with actual parameters .send() .then(response => { /* handle response */ }); mapboxClient.tilesets.listTilesets(..) // Replace .. with actual parameters .send() .then(response => { /* handle response */ }); ``` -------------------------------- ### Mapbox Datasets Create and Update Operations Source: https://github.com/mapbox/mapbox-cli-py Documentation for creating and updating Mapbox datasets, including specifying names and descriptions. Covers usage, parameters, and required scopes. ```APIDOC mapbox datasets create [OPTIONS] Create a new dataset. Prints a JSON object containing the attributes of the new dataset. $ mapbox datasets create All endpoints require authentication. An access token with `datasets:write` scope is required, see `mapbox --help`. Options: -n, --name TEXT Name for the dataset -d, --description TEXT Description for the dataset --help Show this message and exit. mapbox datasets update-dataset [OPTIONS] DATASET Update the name and description of a dataset. Prints a JSON object containing the updated dataset attributes. $ mapbox datasets update-dataset dataset-id All endpoints require authentication. An access token with `datasets:write` scope is required, see `mapbox --help`. Options: -n, --name TEXT Name for the dataset -d, --description TEXT Description for the dataset --help Show this message and exit. ``` -------------------------------- ### Build Mapbox MCP Server Project Source: https://docs.mapbox.com/api/guides/mcp-server/ This command executes the build script defined in the project's package.json. It compiles the source code and prepares the Mapbox MCP Server for execution, typically creating output files in a 'dist' directory. ```bash npm run build ``` -------------------------------- ### Initialize Mapbox Client and Make Requests Source: https://github.com/mapbox/mapbox-sdk-js Demonstrates how to initialize the Mapbox SDK client with an access token and then use it to make API calls, such as fetching map styles or listing tilesets. It uses a promise-based approach for handling asynchronous responses. ```javascript var mapboxClient = mapboxSdk({ accessToken: MY_ACCESS_TOKEN }); mapboxClient.styles.getStyle(..) .send() .then(..); mapboxClient.tilesets.listTilesets(..) .send() .then(..); ``` -------------------------------- ### Example Response: Create Token Source: https://docs.mapbox.com/api/accounts/tokens/ Example JSON response when creating a standard Mapbox API token. ```json { "client": "api", "note": "My top secret project", "usage": "pk", "id": "cijucimbe000brbkt48d0dhcx", "default": false, "scopes": ["styles:read", "fonts:read"], "created": "2016-01-25T19:07:07.621Z", "modified": "2016-01-25T19:07:07.621Z", "allowedUrls": ["https://docs.mapbox.com"], "token": "pk.eyJ1Ijoic2NvdGhpcyIsImEiOiJjaWp1Y2ltYmUwMDBicmJrdDQ4ZDBkaGN4In0.sbihZCZJ56-fsFNKHXF8YQ"} ``` -------------------------------- ### Example Routing Solution JSON Source: https://docs.mapbox.com/api/navigation/optimization/ A sample JSON structure representing a routing solution, including dropped services, routes, vehicle details, and stop information with ETAs and odometer readings. ```json { "dropped": { "services": ["service-3", "service-4"], "shipments": [] }, "routes": [ { "vehicle": "xyz", "stops": [ { "type": "depart", "location": "warehouse", "eta": "2022-08-02T09:00:00Z", "odometer": 0 }, { "type": "service", "location": "location-1", "services": ["service-1"], "eta": "2022-08-02T14:42:00Z", "odometer": 100, "wait": 300 }, { "type": "break", "eta": "2022-08-02T14:42:00Z", "wait": 3600 }, { "type": "service", "services": ["service-2"], "location": "location-2", "eta": "2022-08-02T15:42:00Z", "wait": 0, "odometer": 200 }, { "type": "arrive", "location": "warehouse", "eta": "2022-08-02T20:24:00Z", "odometer": 300 } ] } ] } ``` -------------------------------- ### Delete Font Example Request Source: https://docs.mapbox.com/api/maps/fonts/ Example using curl to DELETE a font from the Mapbox Fonts API. ```bash curl -X DELETE "https://api.mapbox.com/fonts/v1/YOUR_MAPBOX_USERNAME/Custom Font Regular?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" ``` -------------------------------- ### Basic Usage Example Source: https://github.com/mapbox/pixelmatch Demonstrates how to use the pixelmatch function to compare two images and count differing pixels. It takes image data buffers, an optional output buffer for highlighting differences, image dimensions, and an options object. ```javascript const numDiffPixels = pixelmatch(img1, img2, diff, 800, 600, {threshold: 0.1}); ``` -------------------------------- ### List Fonts Example Request Source: https://docs.mapbox.com/api/maps/fonts/ Example using curl to list fonts for a specific Mapbox username. ```bash curl "https://api.mapbox.com/fonts/v1/YOUR_MAPBOX_USERNAME?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" ``` -------------------------------- ### Create and Send a Style Request Source: https://github.com/mapbox/mapbox-sdk-js Illustrates the process of creating a request for a Mapbox service (e.g., creating a style) using a service client and then sending the request asynchronously using its `send` method. ```javascript const mbxClient = require('@mapbox/mapbox-sdk'); const mbxStyles = require('@mapbox/mapbox-sdk/services/styles'); const baseClient = mbxClient({ accessToken: MY_ACCESS_TOKEN }); const stylesService = mbxStyles(baseClient); stylesService.createStyle({..}) .send() .then(response => { /* handle response */ }, error => { /* handle error */ }); ``` -------------------------------- ### Add Font Example Request Source: https://docs.mapbox.com/api/maps/fonts/ Example using curl to POST a font file to the Mapbox Fonts API. ```bash curl -X POST "https://api.mapbox.com/fonts/v1/YOUR_MAPBOX_USERNAME/?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \ --data-binary @PermanentMarker-Regular.ttf ``` -------------------------------- ### Mapbox CLI Help Command Source: https://github.com/mapbox/mapbox-cli-py Shows how to display the help message for the Mapbox CLI tool, providing an overview of available commands and options. ```bash $ python -m mapboxcli --help ``` -------------------------------- ### Example Response: Create Temporary Token Source: https://docs.mapbox.com/api/accounts/tokens/ Example JSON response containing a newly created temporary Mapbox token. ```json { "token": "tk.eyJ1IjoibWFwYm94IiwiZXhwIjoxNDczOTY3NjczLCJpYXQiOjE0NzM5Njc2NDMsInNjb3BlcyI6WyJzdHlsZXM6cmVhZCIsImZvbnRzOnJlYWQiXSwiY2xpZW50IjoiYXBpIn0.ZepsWvpjTMlpePE4IQBs0g" } ``` -------------------------------- ### Install Mapbox GL Geocoder Source: https://github.com/mapbox/mapbox-gl-geocoder Installs the Mapbox GL Geocoder package using npm. This is the first step to integrate the geocoder into your project. ```bash npm install --save @mapbox/mapbox-gl-geocoder ``` -------------------------------- ### Mapbox API: Create Tileset Source: https://docs.mapbox.com/api/maps/mapbox-tiling-service/ API endpoint and example for creating a new Mapbox tileset. Requires a tileset recipe and optionally accepts name, description, and attribution details. Requires `tilesets:write` scope. ```APIDOC POST /tilesets/v1/{tileset_id} Description: Create a new tileset. Prerequisites: Create a tileset source and write a tileset recipe. Token Scope: tilesets:write Parameters: tileset_id (string, required): The ID for the tileset (username.id). Limited to 32 characters (excluding username). Allowed special characters: `-`, `_`. Request Body (JSON, required): recipe (object, required): Defines how GeoJSON data is transformed into tiles. See Recipe reference and examples. name (string, required): The name of the tileset. Limited to 64 characters. private (boolean, optional): Whether the tileset requires an access token from your Mapbox account. Defaults to true. description (string, optional): A description of the tileset. Limited to 500 characters. attribution (array of objects, optional): Attribution details. Limited to three objects. Each object has `text` (string, max 80 chars) and `link` (string, max 1000 chars). Example Request: $ curl -X POST "https://api.mapbox.com/tilesets/v1/{tileset_id}?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \ -d @tileset-information-and-recipe.json \ --header "Content-Type:application/json" Example Request Body: { "recipe": { "version": 1, "layers": { "hello_world": { "source": "mapbox://tileset-source/username/hello-world", "minzoom": 0, "maxzoom": 5 } } }, "name": "Hello World", "description": "Spaceship Earth with all of the people, places, and things.", "attribution": [{ "text": "© Hello Legal World", "link": "" }] } ``` ```bash $ curl -X POST "https://api.mapbox.com/tilesets/v1/{tileset_id}?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \ -d @tileset-information-and-recipe.json \ --header "Content-Type:application/json" ``` ```json { "recipe": { "version": 1, "layers": { "hello_world": { "source": "mapbox://tileset-source/username/hello-world", "minzoom": 0, "maxzoom": 5 } } }, "name": "Hello World", "description": "Spaceship Earth with all of the people, places, and things.", "attribution": [{ "text": "© Hello Legal World", "link": "" }] } ``` -------------------------------- ### Example Match Object Source: https://docs.mapbox.com/api/navigation/map-matching/ An example JSON object representing a match, including confidence, distance, duration, geometry, and associated legs. ```json { "confidence": 0.9548844020537051, "distance": 103.7, "duration": 16.4, "geometry": "gatfEfidjUi@Le@@Y?E??J?^Hf@", "legs": [] } ``` -------------------------------- ### Example Response: Create an Upload Source: https://docs.mapbox.com/api/maps/uploads/ A sample JSON response structure for a successful Mapbox upload creation request. ```json { "complete": false, "tileset": "example.markers", "error": null, "id": "hij456", "name": "example-markers", "modified": "{timestamp}", "created": "{timestamp}", "owner": "{username}", "progress": 0 } ``` -------------------------------- ### Example Response: Retrieve Feature Source: https://docs.mapbox.com/api/maps/datasets/ An example JSON object representing a successful response when retrieving a feature from a Mapbox dataset. ```JSON { "id": "{feature_id}", "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ 100, 0 ], [ 101, 0 ], [ 101, 1 ], [ 100, 1 ], [ 100, 0 ] ] ] }, "properties": { "prop0": "value0" } } ``` -------------------------------- ### Example Request: Create Temporary Token Source: https://docs.mapbox.com/api/accounts/tokens/ Example cURL command to request a temporary Mapbox token with specified scopes and expiration. ```curl # Request a temporary token with "styles:read" and "font:read" scopes $curl -H "Content-Type: application/json" -X POST -d '{"expires": "2025-07-15T15:25:00.002Z","scopes": ["styles:read", "fonts:read"]}' 'https://api.mapbox.com/tokens/v2/YOUR_MAPBOX_USERNAME?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN' ``` -------------------------------- ### Install Mapbox GL Geocoder Source: https://github.com/mapbox/mapbox-gl-geocoder Installs the Mapbox GL Geocoder package using npm. This command adds the geocoder library as a dependency to your project. ```shell npm install --save @mapbox/mapbox-gl-geocoder ``` -------------------------------- ### Retrieve Font Metadata Example Request Source: https://docs.mapbox.com/api/maps/fonts/ Example using curl to retrieve metadata for a specific font from the Mapbox Fonts API. ```bash curl "https://api.mapbox.com/fonts/v1/YOUR_MAPBOX_USERNAME/Custom Font Regular/metadata?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" ``` -------------------------------- ### Banner Instruction Object Example Source: https://docs.mapbox.com/api/navigation/directions/ An example JSON object representing a banner instruction for navigation, detailing turns, road names, and icons. ```json { "distanceAlongGeometry": 100, "primary": { "type": "turn", "modifier": "left", "text": "I 495 North / I 95", "components": [ { "text": "I 495", "imageBaseURL": "https://s3.amazonaws.com/mapbox/shields/v3/i-495", "type": "icon" }, { "text": "North", "type": "text", "abbr": "N", "abbr_priority": 0 }, { "text": "/", "type": "delimiter" }, { "text": "I 95", "imageBaseURL": "https://s3.amazonaws.com/mapbox/shields/v3/i-95", "type": "icon" } ] }, "secondary": { "type": "turn", "modifier": "left", "text": "Baltimore / Northern Virginia", "components": [ { "text": "Baltimore", "type": "text" }, { "text": "/", "type": "text" }, { "text": "Northern Virginia", "type": "text" } ] }, "sub": { "text": "", "components": [ { "text": "", "type": "lane", "directions": ["left"], "active": true }, { "text": "", "type": "lane", "directions": ["left", "straight"], "active": true }, { "text": "", "type": "lane", "directions": ["right"], "active": false } ] } } ```