Address geocoding format guide
Forward geocoding converts location text into geographic coordinates, turning 2 Lincoln Memorial Circle NW into -77.050,38.889. A basic Geocoding API request with an address looks like:
https://api.mapbox.com/search/geocode/v6/forward?q=2%20Lincoln%20Memorial%20Cir%20NW&access_token=YOUR_MAPBOX_ACCESS_TOKEN
Use the following address formatting guidelines to make sure that your Mapbox Geocoding API requests retrieve the right results.
Encode the address correctly
The search text must be expressed as a URL-encoded UTF-8 string. The address cannot contain the semicolon character ; (either raw or URL-encoded).
- ✅
2%20Lincoln%20Memorial%20Cir%20NW - ❌
2 Lincoln Memorial Circle NW
Unencoded, the address must be 20 words and numbers or fewer, separated by spacing and punctuation. The unencoded address can be 256 characters at most.
Use one building number, not a number range
Use a single building number rather than a range of numbers when constructing a query.
- ✅
123 Main St - ❌
123-127 Main St
Format address components consistently
Addresses in the United States
For addresses in the United States, pass in the address components in the format {house number} {street} {city} {state} {zip}.
- ✅
123 Main St Boston MA 02111(US)
Addresses outside the United States
For geocoding in countries other than the United States, you have a few options. You can either submit the components in the same order as you would use for an address in the United States ({house number} {street} {city} {state} {zip}), or you can follow local address formatting standards for those countries.
- ✅
123 Main St Swindon SN2 2DQ(UK)