Mapbox API
api.mapbox.com · Location
Custom maps, geocoding, routing, directions, and isochrones. Highly customizable map styles, satellite imagery, and real-time traffic. Free tier: 100,000 requests/month.
Authentication
Sample Requests
Convert an address to coordinates.
Hover any highlighted part to learn what it does
curl -X GET "https://api.mapbox.com/geocoding/v5/mapbox.places/Eiffel Tower Paris.json?limit=1&access_token=YOUR_TOKEN"
import requests
params = {
"limit": "1",
"access_token": "YOUR_TOKEN"
}
response = requests.get(
"https://api.mapbox.com/geocoding/v5/mapbox.places/Eiffel Tower Paris.json",
params=params,
)
print(response.json())const url = new URL('https://api.mapbox.com/geocoding/v5/mapbox.places/Eiffel Tower Paris.json');
url.searchParams.set('limit', '1');
url.searchParams.set('access_token', 'YOUR_TOKEN');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.mapbox.com/geocoding/v5/mapbox.places/Eiffel Tower Paris.json")
q := baseURL.Query()
q.Set("limit", "1")
q.Set("access_token", "YOUR_TOKEN")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.mapbox.com/geocoding/v5/mapbox.places/Eiffel Tower Paris.json")
uri.query = URI.encode_www_form({
"limit" => "1",
"access_token" => "YOUR_TOKEN"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.mapbox.com/geocoding/v5/mapbox.places/Eiffel Tower Paris.json?" . http_build_query([
"limit" => "1",
"access_token" => "YOUR_TOKEN"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Get driving directions between two NYC points.
Hover any highlighted part to learn what it does
curl -X GET "https://api.mapbox.com/directions/v5/mapbox/driving/-73.989,40.733;-73.962,40.756?steps=true&geometries=geojson&access_token=YOUR_TOKEN"
import requests
params = {
"steps": "true",
"geometries": "geojson",
"access_token": "YOUR_TOKEN"
}
response = requests.get(
"https://api.mapbox.com/directions/v5/mapbox/driving/-73.989,40.733;-73.962,40.756",
params=params,
)
print(response.json())const url = new URL('https://api.mapbox.com/directions/v5/mapbox/driving/-73.989,40.733;-73.962,40.756');
url.searchParams.set('steps', 'true');
url.searchParams.set('geometries', 'geojson');
url.searchParams.set('access_token', 'YOUR_TOKEN');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.mapbox.com/directions/v5/mapbox/driving/-73.989,40.733;-73.962,40.756")
q := baseURL.Query()
q.Set("steps", "true")
q.Set("geometries", "geojson")
q.Set("access_token", "YOUR_TOKEN")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.mapbox.com/directions/v5/mapbox/driving/-73.989,40.733;-73.962,40.756")
uri.query = URI.encode_www_form({
"steps" => "true",
"geometries" => "geojson",
"access_token" => "YOUR_TOKEN"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.mapbox.com/directions/v5/mapbox/driving/-73.989,40.733;-73.962,40.756?" . http_build_query([
"steps" => "true",
"geometries" => "geojson",
"access_token" => "YOUR_TOKEN"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Sign up at mapbox.com and get a free access token
- Pass access_token=YOUR_TOKEN as query param
- Geocode: GET /geocoding/v5/mapbox.places/{address}.json?access_token=TOKEN
- Directions: GET /directions/v5/mapbox/{profile}/{lon1},{lat1};{lon2},{lat2}?access_token=TOKEN
- Profiles: driving, walking, cycling, driving-traffic
What can you build with Mapbox API?
Mapbox API is a Location API. Developers commonly use location APIs for:
- tracking assets and vehicles in real time
- building delivery and logistics apps
- finding nearby businesses or services
- geo-fencing and location-based notifications
- address validation and autocomplete
API Key authentication. You'll receive a key after signing up. Send it with every request — in a header or query parameter. Keep it out of client-side code and never commit it to version control. Mapbox API is free to use up to a usage limit, making it a low-risk choice to experiment with.
New to APIs? Read our beginner's guide