Switching guide
How to migrate from the Google Geocoding API
To migrate from the Google Geocoding API, point your existing client at oslew’s Google-compatible endpoint, which takes the same address and latlng parameters and answers in Google’s response shape with oslew’s data inside, and move the credential from the key parameter into an Authorization header. Then handle HTTP 429 alongside the status field, replace what language and components were doing, and compare answers on a sample of your own addresses before moving traffic. Rewriting call sites for the native geocoder can wait until you want what Google’s shape cannot carry.
Last reviewed
The expensive part of changing geocoder is rarely the geocoder. It is the call sites, the response parsers, the test fixtures and the dashboards that expect a particular JSON shape. oslew serves the Google Geocoding API’s request and response shape so that the first step of a move is configuration rather than code, and the rewrite, if you want one, happens later and one call site at a time.
What the Google-shaped endpoint is, and is not
GET /compat/google/maps/api/geocode/json accepts a Google-style request and answers in Google’s JSON layout, but nothing is forwarded to Google and nothing about your traffic reaches it. Every answer comes from oslew’s own index, and each result gains a provenance object naming the dataset, release and licence it came from, which your existing parser will ignore and a person reading the payload can use. The endpoint is billed as the Address product, so it runs on every plan, Free included, from the same bucket as the native geocoder. The idea is described in general terms on the switching hub and in the glossary entry for a compatibility shim.
Credentials: from the URL to a header
A key is read only from the Authorization header; a key in the query string is ignored, including on the compatibility routes. The reason is practical: a key in a URL ends up in web-server logs, load-balancer logs, error trackers and browser history, and each of those is a place it can leak from. The Google request’s key parameter is therefore tolerated so an unchanged URL does not fail, but it plays no part in authentication.
Two consequences follow. A Google client library that cannot add a custom header cannot authenticate here, so call the path from your own HTTP client instead. And a geocoding call made from a web page today has to move behind your server. The service sends no CORS headers, so a page on another origin cannot call it from a browser. A key grants every product on its plan with no referrer restriction, so a key shipped to a browser would be usable by anyone who opened the developer tools.
Two layers of errors
Google clients often look only at the status field. On oslew that field still works for the outcomes of a geocode that ran: a match, no match, or a malformed request. Everything that stops a request before the geocoder is an HTTP status with oslew’s own JSON body, a single error sentence, rather than Google’s envelope: 401 for a missing or unknown key, and 429 when the key is going faster than its plan. A request that finds its bucket empty is refused with 429 and a Retry-After in whole seconds, never less than one.
Handle the two layers in order: check the HTTP status, then read status. Admitted responses also carry headers that let a client slow down before it is refused. Admitted requests carry RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset, with X-RateLimit-* aliases. An interactive request should usually fail fast on a 429 and say so; a backfill should wait the Retry-After seconds and continue. Rate limits against quotas explains why a 429 here means slow down rather than stop until next month.
Identifiers, boxes and address parts
Three fields look the same as Google’s and mean something narrower.
- place_id carries the result’s position within the data segment that answered. It is not stable across data releases, so do not store it as a lasting key for a place, and never mix it with the Google place IDs you already hold. Keep coordinates, the normalised address and the provenance instead.
- viewport is an error bar, not the extent of a building or a city: a square reaching the result’s estimated error either side of the point. Code that fits a map to it will zoom closer for a precise answer and wider for a vague one, which is often useful, but it is an error bar rather than the outline of the place.
- address_components uses a small set of types — street number, route, locality, first-level administrative area, postal code and country — and
long_nameandshort_namealways hold the same value, which for a region or a country is often a code.
location_type is derived from oslew’s own precision and never claims more than actually matched, so an interpolated house number reports itself as interpolated.
Living without language and components
Filtering moves into the address text. Where a request used a component filter to hold results to a country, put the country’s name or ISO code after the last comma of address; where it pinned a postcode, put the postcode there, which narrows the search more than anything else you can send. Only one piece of context is read after that comma, so choose the one that narrows most. There is no translation layer: if your interface shows place names in the user’s language, those names need to come from your own data.
A held-out test before cutover
Do not judge the move on a handful of hand-typed addresses. Gather a few hundred whose true positions you know independently — delivery confirmations with a GPS fix, sites you have surveyed, addresses customers later pinned on a map — and run the same text through both providers. For each answer record the distance to the truth, whether it came back empty, and the precision and confidence oslew reported. Then look at the distribution rather than the average, and choose a confidence threshold below which your application asks the user instead of accepting the answer. The accuracy page describes how oslew runs the same kind of test on addresses it has never seen.
A second check is worth an afternoon: send a copy of a slice of production requests to oslew in the background for a few days, log both answers, and serve only Google’s. Disagreements cluster, and the clusters tell you which address formats to fix in your own input.
From the Google shape to the native geocoder
The compatibility endpoint returns at most 10 results and has nowhere to put the fields that say whether an answer can be trusted. GET /v1/geocode does. The mapping is short: geometry.location becomes lat and lon, formatted_address becomes normalized.formatted, location_type becomes precision with an error radius in metres, and status gives way to the HTTP status, where an empty result list is still a 200. The new field that changes behaviour most is tied_at_top: when more than one candidate shares the best score, the text did not name one place, and the right move is to ask rather than to take the first. Geocoding precision levels explains how to act on each level.
curl -H "Authorization: Bearer $OSLEW_KEY" \
"https://api.oslew.com/compat/google/maps/api/geocode/json?address=Museo+Soumaya,+Miguel+Hidalgo"curl -H "Authorization: Bearer $OSLEW_KEY" \
"https://api.oslew.com/v1/geocode?q=Museo+Soumaya,+Miguel+Hidalgo&limit=5"Bottom line
Start with the base URL and the header, fix error handling so a 429 is waited out, move filtering into the address text, and prove the switch on addresses whose answers you already know. Whether the move is worth it on cost, storage terms and data is argued on the Google Maps comparison; this page is only about doing it safely.
Moving from Google Maps Platform, step by step
1. Price the switch with /v1/migrate
Paste one real request URL from each call site into /v1/migrate. It needs no key, writes the equivalent compatibility and native requests, marks each parameter as carried or not with a reason, and estimates a month’s cost at one Google list price, without Google’s cheaper high-volume bands. Swap your Google key for a placeholder first: credentials come back redacted, but the URL still travels.
2. Mint a key and keep it on the server
Sign up in the console and create a key; the Free plan is enough to build against. A key grants every product on its plan and carries no referrer or IP restriction, so it belongs in server configuration, never in a browser or a mobile app.
3. Move the credential into the Authorization header
Send Authorization: Bearer followed by your oslew key on every request. A key in the query string is ignored, so a leftover Google key parameter does not break the call, but it does leave a secret in your logs. Remove it.
4. Point the base URL at the compatibility path
Replace https://maps.googleapis.com with https://api.oslew.com/compat/google and keep the rest of the path, /maps/api/geocode/json, and your address or latlng parameter unchanged. Existing response parsing keeps working.
5. Handle HTTP 429 as well as the status field
status still reports OK, ZERO_RESULTS or INVALID_REQUEST inside a 200, but never OVER_QUERY_LIMIT. Going faster than the plan returns HTTP 429 with a Retry-After header before the request reaches the geocoder, so check the HTTP status first and wait the seconds it gives.
6. Replace what language and components did
Both are ignored. Put the country, city or postcode you used to filter by after the last comma of the address text, where it is resolved as context before any candidate is scored. Names come back in the language their source recorded.
7. Compare both providers on a held-out sample
Take a few hundred addresses whose true positions you know, geocode them through Google and through oslew, and record each answer’s distance from the truth, the empty answers and the precision reported. Cut over only when the results are acceptable for your use.
8. Move call sites to /v1/geocode when you need more
The native route adds tied_at_top, the full precision scale, context resolution and up to 50 results per request. Move one call site at a time, starting where an ambiguous answer costs you the most.
What the Google Geocoding API endpoint accepts
Served at GET /compat/google/maps/api/geocode/json, returning at most 10 results. Parameters that carry over: address, latlng, limit.
| Parameter | What happens to it |
|---|---|
| key | Ignored: accepted and ignored: this service authenticates with Authorization: Bearer …, never a query parameter. |
| language | Ignored: answers are in the language their source recorded; no translation layer exists. |
| components | Ignored: component filtering is not implemented; put the locality after a comma in the query. |
addressis a forward lookup andlatlnga reverse one; when both are sent,latlngwins.limitis not Google’s parameter: results default to 5, at most 10.statusis real — OK, ZERO_RESULTS, or INVALID_REQUEST with an error_message inside a 200 — and is never OVER_QUERY_LIMIT; going faster than the plan is an HTTP 429 with Retry-After.place_idis prefixedgeoalt:so that one stored and later sent to Google fails loudly.- Each result gains
precision_m,confidenceand aprovenanceobject.
Should you switch at all?
This page is about how. Whether the move is worth making — price, data, licence, and where Google Maps Platform is the better choice — is on the oslew vs Google Maps Platform geocoding page.
Questions
How much code changes when moving Google geocoding calls to oslew?
At first, very little: the host in the base URL and the way the key is sent. The path, the address and latlng parameters and the response shape stay as they are. The real work is in error handling, because rate limiting arrives as an HTTP status rather than a status value, and in replacing any language or components filtering.
Why is the key parameter in my Google request ignored?
oslew reads keys only from the Authorization header, on every route. A key in a URL is copied into access logs, proxy logs and analytics, which is why the parameter is accepted so old requests do not break, and then ignored. Send Authorization: Bearer with your oslew key instead.
Can I keep using my stored Google place IDs?
Keep them as Google identifiers, but do not send them to oslew or mix them with oslew’s. oslew’s place_id is its own, deliberately shaped so it cannot be mistaken for Google’s, and it is not a durable key for a place. Store the coordinates, the normalised address and the provenance instead.
Will oslew ever return OVER_QUERY_LIMIT?
No. A request over the plan’s rate is refused with HTTP 429 and a Retry-After header in whole seconds, before the geocoder runs, so there is no response body with a status field to read. A client that only inspects status needs to check the HTTP code first.
Can I call the Google-compatible endpoint from a browser?
No. The service sends no CORS headers and reads the key only from a header, so a page on another origin cannot call it. Add a small endpoint on your own server that forwards the address and returns the answer, and keep the key there.