Skip to content
oslew
Get a free key

Switching guide

How to migrate from the Mapbox Geocoding API

oslew answers Mapbox Geocoding v5 requests at a compatibility path, in Mapbox’s own response shape, so a v5 client can move by changing its host and sending its key in an Authorization header instead of access_token. A v6 client needs code changes, because only the v5 shape is served. Before cutover, account for the filters that are accepted but ignored, re-tune any threshold on relevance, and test on places whose positions you know; later, move call sites to the native geocoder, which takes latitude first.

Last reviewed

Mapbox’s geocoder and oslew’s are close enough in shape that most of a v5 migration is configuration. What makes it worth reading a guide is the handful of places where the same field name now carries a different meaning, and the filters that stop filtering without raising an error. This page walks through both, then covers the test to run and the route to the native API.

A v5 endpoint with oslew’s data inside

GET /compat/mapbox/geocoding/v5/mapbox.places/{search_text} takes the v5 request and returns a v5 FeatureCollection. Nothing is sent to Mapbox. Each feature is built from oslew’s own index, its properties carry a provenance object naming the dataset and licence, and the collection’s attribution names the service and the licence codes in the answer. The route is part of the Address product, so every plan can call it and it draws on the same rate as native geocoding. The switching overview lists the other providers served this way.

v6 clients have a choice to make

Only the v5 shape is served. If your code already calls v6, rewriting it back to v5 to use the compatibility route means changing its URL, its parameters and its parser, and at that point the native geocoder is the smaller step, because it gives you the fields v5 has no room for. The migration checker is still useful for a v6 client: it recognises the URL, lists which parameters have an equivalent and which do not, and writes the native request.

One caution about its output. For a reverse lookup, the checker writes a compatibility URL built for forward text, and its native URL keeps Mapbox’s longitude-first order where GET /v1/reverse wants latitude first. Build reverse requests by hand from the steps on this page.

Tokens move to your server

access_token plays no part in authentication. An oslew key goes in the Authorization header. A key grants every product its plan includes: there are no per-key scopes, IP allowlists or referrer restrictions. No oslew key is therefore safe to ship in a web page. If your geocoding runs in the browser today, add a small endpoint on your server that takes the search text, calls oslew with the key, and returns the answer. The service would refuse the browser call anyway, since it sends no CORS headers.

Fields that keep their names and change their meaning

  • relevance is a calibrated confidence rather than a text-match score, and one on every reverse lookup. It is comparable across queries, which Mapbox-tuned thresholds may not expect.
  • bbox describes how far the point may be wrong, not how big the feature is. A town-level answer gets a wide box and an address point a tight one; neither traces the outline of the place.
  • id is the place type, a dot and the result’s position in the data segment that answered. It is not stable across data releases, so it is no use as a stored key.
  • place_type always has exactly one entry: address, street, postcode, place, region, country or poi.
  • properties.accuracy holds oslew’s precision value, and properties.accuracy_m the estimated error in metres, which is the more useful of the two for deciding whether to trust an answer.
  • context has at most a postcode, a place, a region and a country, and the country’s short_code is lower case.

Filtering without filters

The table below lists which parameters are ignored. What to do about each is the part it cannot say. A country restriction becomes context: write the country, or its ISO code, after the last comma of the search text, and it is resolved before any candidate is scored. A postcode in the same position narrows further than anything else you can send. A types restriction becomes a check on place_type in your own code, after asking for a few more results. A bbox restriction becomes a check on the returned coordinates. proximity has no replacement on this path; the native near parameter exists, but it is a hard filter to a cell of about 10 km around a point rather than a preference, so use it only when the answer must be inside that cell. Type-ahead moves to address autocomplete, which is a separate product.

Testing before you cut over

Build two samples. For forward geocoding, take a few hundred addresses with independently known positions and compare each answer’s distance from the truth, the share that come back empty, and the reported accuracy_m. For reverse geocoding, take points whose correct address you know and check the address returned. If a large share of reverse answers is empty or wildly far off, suspect a coordinate order swapped somewhere in your code before suspecting the data.

Check error handling in the same pass. Refusals are oslew’s, a JSON object with one error sentence, and a key going faster than its plan gets HTTP 429 with a Retry-After header in whole seconds. Code that parsed Mapbox’s error messages needs to read the HTTP status instead.

From the compatibility path to the native routes

Forward calls move to GET /v1/geocode with the text as q; reverse calls move to /v1/reverse with at as latitude then longitude. center[1] and center[0] become lat and lon, place_name becomes normalized.formatted, and relevance becomes confidence plus tied_at_top, the count of candidates that scored equal first. When that count is above one, the text did not name one place, and a map that silently flies to the first answer is guessing. Reverse geocoding explains what a point lookup returns natively.

A reverse lookup on the compatibility path: longitude first
curl -H "Authorization: Bearer $OSLEW_KEY" \
"https://api.oslew.com/compat/mapbox/geocoding/v5/mapbox.places/-99.1332,19.4326.json"
The same point on the native route: latitude first
curl -H "Authorization: Bearer $OSLEW_KEY" \
"https://api.oslew.com/v1/reverse?at=19.4326,-99.1332"

Bottom line

A v5 client moves by changing its host and its credential; a v6 client should skip the compatibility path and go native. Either way, rebuild filtering in the query text, re-tune any relevance threshold, and test reverse lookups for coordinate order before anything else. The cost, storage and map-terms case for moving at all is on the Mapbox comparison.

Moving from Mapbox, step by step

  1. 1. Confirm which Mapbox API version you call

    Look at the request path. A v5 call goes to /geocoding/v5/mapbox.places/ and can move by configuration. A call with /geocode/v6/ in its path needs code changes, because oslew answers only the v5 shape; for a v6 client, going straight to the native geocoder is usually less work.

  2. 2. Ask /v1/migrate what carries over

    Paste a real request URL into /v1/migrate, with a placeholder where your access token was; it needs no key. It lists every parameter as carried or not and writes the v5 compatibility request and the native one. Ignore its cost estimate: its Mapbox price matches neither Mapbox’s Temporary nor its Permanent price. For reverse lookups, take the paths from this guide rather than from its output.

  3. 3. Send the key in a header, not access_token

    Create a key in the oslew console and send it as Authorization: Bearer on every call. access_token is accepted so an old URL does not fail, then ignored. Because the key is only read from a header and no CORS headers are sent, the call has to come from your server.

  4. 4. Swap the host and keep the v5 path

    Replace https://api.mapbox.com/geocoding/v5/mapbox.places/ with https://api.oslew.com/compat/mapbox/geocoding/v5/mapbox.places/ and keep the search text, the optional .json suffix and limit exactly as they were.

  5. 5. Keep longitude first on this path

    Two numbers as the search text are a reverse lookup, read longitude then latitude, as Mapbox reads them. Leave reverse calls alone while they use the compatibility path, and swap the order only when they move to /v1/reverse.

  6. 6. Rebuild filtering and type-ahead

    country, types, bbox, proximity and language no longer narrow anything. Put a country, region or postcode after the last comma of the search text, filter by place_type or coordinates in your own code, and send type-ahead calls to /v1/autocomplete.

  7. 7. Re-tune thresholds on places you know

    relevance is now a calibrated confidence, so a cut-off chosen on Mapbox answers will not transfer. Geocode a few hundred addresses whose positions you know, and set the new threshold from how often answers above it land where they should.

  8. 8. Move to /v1/geocode and /v1/reverse

    The native routes take latitude first, return plain numbers rather than coordinate arrays, and add tied_at_top and context resolution. Move one call site at a time, swapping the coordinate order as you go.

What the Mapbox Geocoding v5 endpoint accepts

Served at GET /compat/mapbox/geocoding/v5/mapbox.places/{search_text}, returning at most 10 results. Parameters that carry over: {search_text}, limit.

ParameterWhat happens to it
access_tokenIgnored: accepted and ignored: this service authenticates with Authorization: Bearer …, never a query parameter.
proximityIgnored: accepted and ignored: it is not a bias here, and forward lookups run with no near.
countryIgnored: accepted and ignored: filtering is by administrative name, not by ISO code.
autocompleteIgnored: accepted and ignored: there is no autocomplete mode on this path; /v1/autocomplete is the route for that.
languageIgnored: answers are in the language their source recorded; no translation layer exists.
typesIgnored: one index answers every kind of place; there is no feature-type filter yet.
bboxIgnored: a bounding-box filter is not exposed; near constrains to roughly a city instead.
  • This is the v5 shape, not v6. /v1/migrate recognises a v6 URL as Mapbox, but the compatibility route answers v5.
  • search_text may end in .json. Two numbers are a reverse lookup, in Mapbox’s lon,lat order — the opposite of every /v1 route.
  • relevance is the calibrated confidence, and 1 on a reverse lookup; bbox is west, south, east, north.
  • limit defaults to 5, at most 10.

Should you switch at all?

This page is about how. Whether the move is worth making — price, data, licence, and where Mapbox is the better choice — is on the oslew vs the Mapbox Geocoding API page.

Questions

Can a Mapbox v6 client use oslew’s compatibility endpoint?

Not without changes. The endpoint serves the v5 path and response shape only. The migration checker will recognise a v6 URL as a Mapbox request and write a v5 equivalent, but a v6 client would have to change both its URL and its parsing, so moving it to the native /v1/geocode route is usually the better use of the effort.

Which coordinate order does the Mapbox-compatible path expect?

Longitude, then latitude, for a reverse lookup written as the search text, the same as Mapbox. The coordinates in each answer’s center and geometry are longitude first too. Every native /v1 route is the other way round, latitude first, so the order changes when a call site moves off the compatibility path.

What does relevance mean in oslew’s Mapbox-shaped answers?

It is oslew’s calibrated confidence: an estimate of how often answers of that shape turn out to be right, not a measure of how similar the strings are. On a reverse lookup it is always one. Thresholds tuned on Mapbox’s relevance need to be chosen again from a test on your own data.

Why does the bbox around an address look so small?

On oslew the bbox is an error bar. It is a square reaching the answer’s estimated error either side of the point, not the outline of the building, street or town, so a precise address gets a tight box and a town-level answer a wide one. Code that fits a map to it will zoom accordingly.

Is autocomplete available on the Mapbox-compatible path?

No. The autocomplete parameter is ignored there. oslew’s type-ahead is a separate route, /v1/autocomplete, on the Search product, which suggests names as someone types; the geocode that follows their choice is what returns a position and a confidence.

Browse every page →