APIs
Address validation API
An address validation API checks whether an address exists as written and, when it does not quite, says what it should have been. oslew compares every part of the input — house number, street, locality, postcode, country — with the address records it holds, and answers with one of four verdicts, a grade for each component and a corrected single-line address. Send the address as one line or as separate fields, by query string or JSON body; it runs on the Address product at the same rate as geocoding.
Last reviewed
Validation starts from a different assumption than geocoding. A geocoder assumes the text names somewhere and tries to find where; a validator assumes nothing and compares what was typed against what exists. The output is therefore not a ranked list of candidates but a judgement: this address is right, or nearly right and here is the fix, or wrong in these specific parts. The explainer on validation versus geocoding covers when you need which; this page is about what the validator itself does.
Four verdicts, decided by rules
Every part of the input is compared with the best-matching address record and graded. The verdict is then derived from those grades by fixed rules, not by a score crossing a threshold, so the same input always earns the same verdict for the same reason:
| Verdict | Given when |
|---|---|
confirmed |
Every part that was sent and can be checked matches exactly, and the match is an address record — an address point with its number, or an address row. |
corrected |
Every checkable part is exact or within two edits of the record, and a house number, if sent, is exact. Also returned when everything matches but the record is a place or a street row without a number: nothing was wrong, and nothing was confirmed either. |
partial |
The house number is not on that street, or the street only shares a word with the match, or another part — typically the postcode or the locality — contradicts it. |
unconfirmed |
Nothing matched, or the street is neither within two edits of the best candidate nor shares a meaningful word with it. |
A misspelt street is the typical correction: one letter off, graded fuzzy, with the number and postcode exact. The typical partial is a real street with a house number it does not have. An unconfirmed address is a success response, not an error — the question was answered, and the answer was no.
A grade for every part
The components array holds one entry per part — house number, street, a business name if the first part had no number, locality, region, postcode and country — with what you sent as input, what the record holds as matched, and a quality:
exact— equal once case, accents and punctuation are folded.fuzzy— within two edits. Never awarded to a house number, a postcode or a country code, where one character is a different place.partial— shares a word without being close, or contradicts the record outright. A differing number or postcode lands here.missing— not sent, in which casematchedshows what the record would fill in, or sent but impossible to check.
Two parts often cannot be checked even when present. Address records generally hold no region, so a region you send usually cannot be verified against one: it is graded missing and carried through into formatted. And a country written as a name rather than an ISO code cannot be compared; send MX, not Mexico. Generic street words — calle, avenida, street — never count as agreement on their own: two streets that share only the word calle agree on nothing, and the verdict says so.
Branch your code on verdict and the component grades. The why field spells out each correction, contradiction and inference in words, which is for a person reading a log rather than for a program.
The corrected line and the normalised parts
formatted is the address rebuilt from the matched record, as one line. A part the record cannot speak to is taken from your input; a part the record contradicts never is. It is written house number first whatever the country’s convention, and in the casing its source used, so if the layout matters, assemble your own line from the component values. Alongside it come lat, lon and precision for the matched record, a calibrated confidence on the same scale as geocoding, and candidates, the number of records compared.
Treat formatted on a partial verdict as a description of what was matched, not as an address to save. And do not infer the verdict from whether a position came back: an unconfirmed answer can carry the position of a candidate on a different street.
Address normalisation, done the same way twice
Normalisation is what lets Av. Insurgentes Sur and avenida insurgentes sur be compared at all. oslew does not offer it as a separate call; it runs inside every address answer, and it runs identically when the index is built and when a query arrives, so the two cannot drift apart. Case and accents are folded; punctuation becomes a space; common abbreviations collapse to one word, so av, avda and ave all become avenida; a house number glued to its street is taken off; and a number is found whether it leads or trails the street name. Scripts are left alone: nothing is transliterated or translated.
The result is visible in two places. Validation returns the address broken into components, graded; geocoding, reverse and batch answers each carry a normalized block with the parts and a one-line form in the country’s own order. Storing those parts, rather than the string a person typed, is what makes later deduplication and matching tractable.
Sending an address: text, fields, GET or POST
Every input is an optional string: text for the whole address on one line, or house_number, street, locality, region, postcode and country as fields, or both. A field sent explicitly overrides whatever the line parses to, so a form can pass the typed line as text and a country from a dropdown as country, and the dropdown wins. The only requirement is text or at least street.
Unlike geocoding, which splits only at the last comma, validation reads every comma in text. The first part is the number and street; in each later part, everything from the first word containing a digit is the postcode; a later part of exactly two letters is the country; the rest fill locality, region and country in that order. It is a good guess rather than an oracle, so if you already hold the parts in separate fields, send the fields.
POST /v1/validate takes those fields as a JSON object and is the better fit for anything a person submits. It is strict about its body: no JSON content type is refused with 415, malformed JSON with 400, and a field of the wrong type with 422 — every value is a string, including the house number, which is not always a number anyway. GET /v1/validate takes the same fields in the query string.
Where validation stops
Validation answers whether an address is in the data as given. It does not interpolate a missing house number, report a tie count, or resolve context through the administrative divisions the way geocoding does. Its search widens in steps — number and street within the first of the locality, postcode or region that the index knows, then without context, then the street alone — and stops at the first step that finds anything. For a position for an address the data does not hold exactly, geocode it instead.
A verdict also grades only what was sent. Validate a street and postcode with no house number, and the best record can be any numbered address on that street: every part given was exact, so the verdict can be confirmed while the number is graded missing and matched shows someone else’s. If the number matters, require it before calling. The checkout form use case shows how a form handles each verdict; the customer data clean-up uses validation as a second opinion on doubtful geocodes.
What it costs
Validation belongs to the Address product, which every plan includes; Free allows 1 requests a second sustained, burst 5, and the Address plan is $99 a month for 20 requests a second sustained, burst 100. Each call, GET or POST, takes one token from the key’s address bucket. A form that validates once on submit spends one request per submitted address, however many times the person edits it first.
Limits worth knowing
- A verdict is only as current as the loaded address data. New developments and thinly covered areas come back unconfirmed while being real, so never block a person on that verdict alone.
- Regions and country names usually cannot be checked; send ISO country codes.
- Two edits can turn one real street name into another. A correction is a suggestion until a person accepts it.
- The service sends no CORS headers and reads the key only from the Authorization header, so a browser form calls your own server, which calls validation.
Bottom line
Use validation where someone can still act on the answer: it tells you whether an address is right, which part is wrong, and what the data thinks it should be. Branch on the verdict, show the corrected line as a suggestion rather than a silent rewrite, and store the graded components rather than the string that was typed.
Questions
What is the difference between a confirmed and a corrected address?
Confirmed means every part you sent that can be checked matched exactly, and the match is an address record rather than a street or a place. Corrected means every checkable part is exact or within two edits, with the house number exact if given. The corrected line is the address as the data spells it; whether to adopt it is a decision for the person who typed the original.
Should I call address validation with GET or POST?
Both run the same check. POST takes the fields as a JSON object, which maps one to one onto a form, needs no URL-encoding and keeps the address out of URLs, where proxies and access logs record it. GET takes the same fields as query parameters and suits a quick test from a shell.
Does address validation tell me a parcel can be delivered?
No. It says whether the address as written agrees with an address record in the loaded open data, part by part. It does not consult a postal operator or a carrier, so it cannot say that anyone delivers there, and a building newer than the data can come back unconfirmed while being perfectly real.
What is address normalisation?
Rewriting an address into one consistent form — case and accents folded, abbreviations expanded, the house number separated from the street — so that two spellings of the same address compare equal. oslew runs the same normalisation when it builds its index and when a query arrives, and returns the address broken into components you can store.
Why does my validation request say no street was given?
Usually because the address was sent as q, the geocoding parameter. Validation takes text for a one-line address, or street and the other parts as separate fields. A parameter the route does not know is dropped without complaint, so a request carrying only q reaches it with no address in it at all.