API Directory › 🌍 Geo & Location › Mapbox
API KeyHTTPSCORS

Mapbox API

Maps, geocoding, directions and navigation APIs with a free monthly quota.

Auth
API Key
HTTPS
Yes
CORS
Yes
Open Mapbox docs ↗

What it does

Mapbox is a full location platform: geocoding (address ↔ coordinates), turn-by-turn directions, isochrones, distance/duration matrices, static and interactive maps, vector tiles, elevation and a search-as-you-type API. One access_token covers all of it.

Base URL

https://api.mapbox.com

Authentication

Create an account and use a public token (pk.…) as ?access_token=YOUR_TOKEN. Restrict tokens by URL and scope. Secret tokens (sk.…) are only for server-side upload/admin APIs.

Code examples

curl (geocoding v6)
curl -s "https://api.mapbox.com/search/geocode/v6/forward?q=Eiffel+Tower&access_token=$MAPBOX_TOKEN"
Python (directions)
import requests

coords = "13.388,52.517;13.397,52.529"  # lon,lat;lon,lat
r = requests.get(
    f"https://api.mapbox.com/directions/v5/mapbox/driving/{coords}",
    params={"access_token": TOKEN, "overview": "false"}, timeout=10)
route = r.json()["routes"][0]
print(route["distance"], "m", route["duration"], "s")

Rate limits & quotas

Generous free monthly allowances per product — on the order of 100,000 geocoding requests and 50,000 map loads — billed only above that. Per-endpoint rate limits apply (geocoding is around 600–1,000 requests/minute). Headers (X-Rate-Limit-Remaining) report your window.

Key response fields

features[].geometry.coordinates[lon, lat] — note the order
features[].properties.full_addressFormatted address (geocoding v6)
features[].properties.contextParent regions: place, region, country…
routes[].distance / durationMetres and seconds for a directions request
routes[].geometryEncoded polyline or GeoJSON of the route

Common errors

401Missing, malformed or URL-restricted token.
403Token lacks the scope for that API, or account is over its free limit without billing.
422Invalid coordinates (remember: lon,lat order) or parameters.
429Per-minute rate limit exceeded.

When to use it (and alternatives)

The choice when you need maps, routing and geocoding together with production-grade reliability. For geocoding-only on open data with storage rights, OpenCage is cheaper; Google’s platform is the other major commercial option.

FAQ

Is Mapbox free?

It has a free monthly tier per product that covers small and medium apps. You add a card and pay per request only once you exceed those allowances.

Why are my coordinates in the wrong place?

Mapbox (and GeoJSON generally) uses [longitude, latitude] order, the opposite of the lat,lon most people say aloud. Double-check the order.

Can I use a Mapbox token in front-end code?

Yes — that is what public pk. tokens are for. Lock them to your domain(s) with URL restrictions so others can’t rack up your bill.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

IP LookupDNS Lookup

Related Geo & Location APIs

← Back

More Geo & Location APIs · All 196 APIs