oslew docs
Console
Menu

Validating an address

Geocoding asks where is this. Validation asks is this right, and what is it really: it compares what someone typed, part by part, with the addresses the data holds, and answers a verdict, the corrected address, and a line of evidence for every part. The useful place for it is a form, while the person who typed the address is still there to fix it.

curl
curl -G "https://api.oslew.com/v1/validate" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  --data-urlencode 'text=Avenida Insurgentes Sur 1602, Ciudad de México 03940, MX'
Python
from oslew import Client

# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")

answer = client.validate(
    text="Avenida Insurgentes Sur 1602, Ciudad de México 03940, MX",
)
TypeScript
import { Client } from "@oslew/client";

// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });

const answer = await client.validate({ text: "Avenida Insurgentes Sur 1602, Ciudad de México 03940, MX" });
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 296
ratelimit-reset: 1

{
  "verdict": "confirmed",
  "formatted": "1602 AVENIDA INSURGENTES SUR, Ciudad de México, 03940, MX",
  "components": [
    {
      "name": "house_number",
      "input": "1602",
      "matched": "1602",
      "quality": "exact"
    },
    {
      "name": "street",
      "input": "Avenida Insurgentes Sur",
      "matched": "AVENIDA INSURGENTES SUR",
      "quality": "exact"
    },
    {
      "name": "locality",
      "input": "Ciudad de México",
      "matched": "Ciudad de México",
      "quality": "exact"
    },
    {
      "name": "region",
      "input": null,
      "matched": null,
      "quality": "missing"
    },
    {
      "name": "postcode",
      "input": "03940",
      "matched": "03940",
      "quality": "exact"
    },
    {
      "name": "country",
      "input": "MX",
      "matched": "MX",
      "quality": "exact"
    }
  ],
  "lat": 19.364069672979937,
  "lon": -99.18198831998704,
  "precision": "rooftop",
  "confidence": 0.3960396,
  "candidates": 25,
  "why": "matched AVENIDA INSURGENTES SUR 1602 (an address point) among 25 candidates",
  "epoch": 30,
  "release": "2026-08-19.0",
  "took_us": 3210
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

Every part given matched exactly, and the match is an address point with that house number, so the verdict isconfirmed. region is missing because none was given. Thewhy line says what matched and among how many candidates.

Input: text, parts, or both

Every input is an optional string. Send text, or the parts, or both:

FieldIs
textThe whole address as one line: number street, locality, region postcode, country, in any subset.
house_numberAs written: 1602, 12A.
streetThe street, with its type: Avenida Insurgentes Sur.
localityThe city or town.
regionThe state or province.
postcodeThe postal code.
countryAn ISO 3166-1 code, MX.

A part given explicitly overrides what text parses to. So a form can send the line a user typed as text and the country from a dropdown as country, and the dropdown wins.

The one requirement is text or at least street; without either the answer is400. There is no q parameter here — /v1/validate?q=… is a common mistake carried over from geocoding, and because unknown parameters are dropped silently, it reaches the route as a request with no address at all:

Response
HTTP/1.1 400 Bad Request
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 292
ratelimit-reset: 1

{
  "error": "give `text`, or at least `street`"
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

How text is read

Unlike geocoding, which splits only at the last comma, validation reads every comma:

  • The first part is the number and street. The number may lead (1602 Avenida Insurgentes Sur) or trail (Avenida Insurgentes Sur 1602); only the last word can trail, becauseCalle 5 de Mayo 32 has numbers in both places and only one is the house. A number glued to the street — Herradura22 — is read too. A first part with no number is either a street or the name of a business, and both are searched.
  • In each later part, everything from the first word containing a digit is the postcode:Ciudad de México 03940 is a locality and a postcode.
  • A later part of exactly two letters is the country. Otherwise the first unclaimed of locality, region and country takes it, in that order.

That parse is a good guess, not an oracle. If your form already has the parts in fields, send the fields; there is nothing to gain by joining them into a line for the service to take apart again.

GET or POST

GET /v1/validate takes the inputs as query parameters. POST /v1/validate takes the same inputs as a JSON object, and is the better fit for a form: the fields map one to one, nothing needs URL-encoding, and an address in a request body stays out of the URL — which is what proxies and access logs record.

curl
curl -X POST "https://api.oslew.com/v1/validate" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"house_number":"9999999","street":"Avenida Insurgentes Sur","locality":"Ciudad de México"}'
Python
from oslew import Client

# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")

answer = client.post_validate(
    {
    "house_number": "9999999",
    "street": "Avenida Insurgentes Sur",
    "locality": "Ciudad de México",
},
)
TypeScript
import { Client } from "@oslew/client";

// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });

const answer = await client.post_validate({
  house_number: "9999999",
  street: "Avenida Insurgentes Sur",
  locality: "Ciudad de México",
});
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 294
ratelimit-reset: 1

{
  "verdict": "partial",
  "formatted": "AVENIDA INSURGENTES SUR, Ciudad de México, 04530, MX",
  "components": [
    {
      "name": "house_number",
      "input": "9999999",
      "matched": null,
      "quality": "partial"
    },
    {
      "name": "street",
      "input": "Avenida Insurgentes Sur",
      "matched": "AVENIDA INSURGENTES SUR",
      "quality": "exact"
    },
    {
      "name": "locality",
      "input": "Ciudad de México",
      "matched": "Ciudad de México",
      "quality": "exact"
    },
    {
      "name": "region",
      "input": null,
      "matched": null,
      "quality": "missing"
    },
    {
      "name": "postcode",
      "input": null,
      "matched": "04530",
      "quality": "missing"
    },
    {
      "name": "country",
      "input": null,
      "matched": "MX",
      "quality": "missing"
    }
  ],
  "lat": 19.306485580000658,
  "lon": -99.18666049037793,
  "precision": "street",
  "confidence": 0.35,
  "candidates": 25,
  "why": "matched AVENIDA INSURGENTES SUR (an address point) among 25 candidates; house_number \"9999999\" contradicts the match; postcode inferred as \"04530\"; country inferred as \"MX\"",
  "epoch": 30,
  "release": "2026-08-19.0",
  "took_us": 2252
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

Three things refuse a POST before the route runs, as plain text rather than JSON:

  • No Content-Type: application/json header: 415. Both clients set it.
  • A body that is not JSON: 400.
  • A field of the wrong type: 422. Every field is a string, so {"house_number": 1602} is refused and {"house_number": "1602"} is not. Send numbers as strings; a house number is not always a number anyway.

The four verdicts

Each part the input gives is compared with the matched address and graded. The verdict follows from the grades by fixed rules:

VerdictExactly when
confirmedEvery part given that can be checked is exact, and the match is an address row — rooftop or address precision.
correctedEvery part given that can be checked is exact or within two edits, and the house number, if given, is exact. Also where everything is exact but the match is a place rather than an address point, or a street row with no number: nothing was confirmed, but nothing was wrong. formatted is the corrected address.
partialThe house number does not match, or the street shares a word with the match but is not within two edits of it, or another part — the postcode, the locality — contradicts the match.
unconfirmedNothing matched, or the street (or business name) is neither within two edits of the best candidate's nor shares a word with it beyond words like calle and avenida.

A misspelt street is the typical corrected. Insurjentes is one edit fromInsurgentes, so the street is fuzzy, the number and postcode are exact, and the answer says what it changed and what it filled in:

curl
curl -G "https://api.oslew.com/v1/validate" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  --data-urlencode 'house_number=1602' \
  --data-urlencode 'street=Avenida Insurjentes Sur' \
  --data-urlencode 'postcode=03940'
Python
from oslew import Client

# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")

answer = client.validate(
    house_number="1602",
    street="Avenida Insurjentes Sur",
    postcode="03940",
)
TypeScript
import { Client } from "@oslew/client";

// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });

const answer = await client.validate({
  house_number: "1602",
  street: "Avenida Insurjentes Sur",
  postcode: "03940",
});
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 295
ratelimit-reset: 1

{
  "verdict": "corrected",
  "formatted": "1602 AVENIDA INSURGENTES SUR, Ciudad de México, 03940, MX",
  "components": [
    {
      "name": "house_number",
      "input": "1602",
      "matched": "1602",
      "quality": "exact"
    },
    {
      "name": "street",
      "input": "Avenida Insurjentes Sur",
      "matched": "AVENIDA INSURGENTES SUR",
      "quality": "fuzzy"
    },
    {
      "name": "locality",
      "input": null,
      "matched": "Ciudad de México",
      "quality": "missing"
    },
    {
      "name": "region",
      "input": null,
      "matched": null,
      "quality": "missing"
    },
    {
      "name": "postcode",
      "input": "03940",
      "matched": "03940",
      "quality": "exact"
    },
    {
      "name": "country",
      "input": null,
      "matched": "MX",
      "quality": "missing"
    }
  ],
  "lat": 19.364069672979937,
  "lon": -99.18198831998704,
  "precision": "rooftop",
  "confidence": 0.5967742,
  "candidates": 25,
  "why": "matched AVENIDA INSURGENTES SUR 1602 (an address point) among 25 candidates; street corrected from \"Avenida Insurjentes Sur\" to \"AVENIDA INSURGENTES SUR\"; locality inferred as \"Ciudad de México\"; country inferred as \"MX\"",
  "epoch": 30,
  "release": "2026-08-19.0",
  "took_us": 1734
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

The partial example above is the other common case: a real street and a house number it does not have. The number is graded partial — it contradicts the match — and the match is a row of the street with no number, so precision is street and the position is that row's, not the house's. Note the postcode, 04530: it was inferred from whichever row of that long avenue matched, not from anything the user typed. formatted on a partial is a description of the match, not an address to save.

Reading components

One entry per part: name (house_number, street, name for a business, locality, region, postcode, country), what was given asinput, what the match has as matched, and a quality:

qualityMeans
exactEqual after folding case, accents and punctuation.
fuzzyWithin two edits. Never for a house number or a postcode, where one character is a different place, and never for a country code.
partialShares a word with the match without being close to it — or contradicts it outright. A house number or postcode that differs is partial.
missingNot given — in which case matched, when set, is what the match infers — or given but impossible to check.

Two parts often cannot be checked, and are graded missing even when given:

  • region against an address. Address rows keep no region. Where a source has no postal city, its locality column holds the state, so a region equal to the row's locality agrees; any other region is unverifiable, and formatted keeps the one you sent.
  • country as a name. Codes compare: MX against MX is exact,US against MX contradicts. Mexico is not a code, and cannot be checked.

A word like calle, avenida, paseo or street is never agreement on its own.Calle Falsa and Calle 123 share only calle, and agreeing on that is agreeing on nothing: the street is graded as contradicting, and the verdict is unconfirmed.

The rest of the answer

FieldSays
formattedThe address from the match, one line: number and street, locality, region and postcode, country. A part the match cannot speak to comes from your input; a part it contradicts never does. It is written number first whatever the country — geocoding's normalized.formatted follows each country's order — and in the source's casing, so build your own line from components if the layout matters.
lat, lon, precisionThe matched row's position and what it locates. null when nothing matched.
confidenceThe match's calibrated confidence, the same measure geocoding reports. 0 when nothing matched.
candidatesHow many candidates were compared.
whyThe trail in words: what matched, and each correction, contradiction and inference — street corrected from "Avenida Insurjentes Sur" to "AVENIDA INSURGENTES SUR". For a person to read; branch on verdict and components.

Branch on verdict, not on whether lat is present. An unconfirmed answer normally has no position, but when the best candidate carries the house number asked for on a street that contradicts yours, it comes back unconfirmed with that candidate's position — which is not a position for the address you sent.

How it differs from geocoding

Both read addresses the same way — the same folding, the same house-number rule — so an address parsed one way by validation and another by search would be a bug. What differs is the question, and so the ranking:

  • A validator's ranking. The geocoder ranks by words matched. The validator fetches up to 25 candidates per search and per index segment, compares each part by part — exact is worth most, then within two edits, then a shared word — and keeps the one that agrees on the most parts. 123 Calle Juares should land on 123 Calle Juárez, not on 123 Calle Morelos, though both share two words with it.
  • It widens in steps. Number and street in the first context the index knows (the locality, then the postcode, then the region); then without context; then the street alone. It stops at the first step that finds anything.
  • No interpolation, no tie count, no context resolution through divisions. It answers whether the address is in the data as given. For a position for an address the data does not hold exactly, geocode it.

Use validation where a person can act on the answer — a checkout, a signup, an address book. Usegeocoding or a batch job to place addresses you already have. Validating a warehouse of old addresses tells you how many are wrong, not which changes a customer would accept.

What to do with each verdict in a form

VerdictIn a checkout or address form
confirmedAccept it. Store the parts from components and the position. If house_number was not given, ask for it first — see the warning above.
correctedShow "Did you mean …" with formatted, marking the parts graded fuzzy and offering the inferred ones (missing with a matched value) as fill-ins. Save the corrected version only when the person accepts it.
partialAsk the person to check the parts graded partial — usually the house number or the postcode. Do not replace their address with formatted. Let them keep what they typed: new buildings are not in any dataset yet.
unconfirmedAsk them to check the street. If they insist, accept it as typed and flag it for a person to look at. Do not block a sale on it.
Python
from oslew import Client

client = Client(base_url="https://api.oslew.com")

def check(form: dict) -> dict:
    # Every value a string; empty fields left out.
    body = {k: str(v) for k, v in form.items() if v}
    if "house_number" not in body:
        return {"action": "ask", "fields": ["house_number"]}

    v = client.post_validate(body)
    graded = {c["name"]: c for c in v["components"]}

    if v["verdict"] == "confirmed":
        return {"action": "accept", "address": graded, "at": (v["lat"], v["lon"])}
    if v["verdict"] == "corrected":
        changed = [n for n, c in graded.items() if c["quality"] == "fuzzy"]
        filled = [n for n, c in graded.items() if c["quality"] == "missing" and c["matched"]]
        return {"action": "suggest", "formatted": v["formatted"], "changed": changed, "filled": filled}
    if v["verdict"] == "partial":
        wrong = [n for n, c in graded.items() if c["quality"] == "partial"]
        return {"action": "ask", "fields": wrong}
    return {"action": "ask", "fields": ["street"], "allow_as_typed": True}
TypeScript
import { Client } from "@oslew/client";

const client = new Client({ baseUrl: "https://api.oslew.com" });

async function check(form: Record<string, string | undefined>) {
  // Every value a string; empty fields left out.
  const body = Object.fromEntries(Object.entries(form).filter(([, v]) => v));
  if (!body.house_number) return { action: "ask", fields: ["house_number"] };

  const v = await client.post_validate(body);
  const graded = Object.fromEntries(v.components.map((c) => [c.name, c]));
  const named = (q: string) => v.components.filter((c) => c.quality === q);

  switch (v.verdict) {
    case "confirmed":
      return { action: "accept", address: graded, at: [v.lat, v.lon] };
    case "corrected":
      return {
        action: "suggest",
        formatted: v.formatted,
        changed: named("fuzzy").map((c) => c.name),
        filled: named("missing").filter((c) => c.matched).map((c) => c.name),
      };
    case "partial":
      return { action: "ask", fields: named("partial").map((c) => c.name) };
    default:
      return { action: "ask", fields: ["street"], allowAsTyped: true };
  }
}

The key stays on your server: call validation from your backend and let the form talk to that. Theaddress form example shows the whole round trip.

When the user accepts

Once the person filling in the form accepts an address, send the accepted version toPOST /v1/validate/commit. It validates exactly as POST /v1/validate does and adds areceipt: the store epoch and release that answered, and a SHA-256 of the verdict, the formatted address and the position. Store the receipt with the address, and you can later show which data release vouched for it and that the stored row is what the service said. With selected_rank, the choice is also sent asfeedback.

Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 293
ratelimit-reset: 1

{
  "verdict": "partial",
  "formatted": "1602 AVENIDA INSURGENTES SUR, Ciudad de México, 03940, MX",
  "components": [
    {
      "name": "house_number",
      "input": "1602",
      "matched": "1602",
      "quality": "exact"
    },
    {
      "name": "street",
      "input": "Avenida Insurgentes Sur",
      "matched": "AVENIDA INSURGENTES SUR",
      "quality": "exact"
    },
    {
      "name": "locality",
      "input": "Crédito Constructor",
      "matched": "Ciudad de México",
      "quality": "partial"
    },
    {
      "name": "region",
      "input": null,
      "matched": null,
      "quality": "missing"
    },
    {
      "name": "postcode",
      "input": "03940 Ciudad de México",
      "matched": "03940",
      "quality": "partial"
    },
    {
      "name": "country",
      "input": null,
      "matched": "MX",
      "quality": "missing"
    }
  ],
  "lat": 19.364069672979937,
  "lon": -99.18198831998704,
  "precision": "rooftop",
  "confidence": 0.25609756,
  "candidates": 25,
  "why": "matched AVENIDA INSURGENTES SUR 1602 (an address point) among 25 candidates; locality \"Crédito Constructor\" contradicts the match (\"Ciudad de México\"); postcode \"03940 Ciudad de México\" contradicts the match (\"03940\"); country inferred as \"MX\"",
  "epoch": 30,
  "release": "2026-08-19.0",
  "receipt": {
    "epoch": 30,
    "release": "2026-08-19.0",
    "payload_sha256": "5ad2ed3344fa7133d5380a3fff17f9484b02087567b655d76982055291abda55",
    "alg": "sha256"
  },
  "took_us": 2084
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

More on receipts, and how to recompute one: decisions and receipts.

Errors

  • 400, give `text`, or at least `street` — neither was sent, or both were blank. Check the parameter names: a misspelt one is dropped, not refused.
  • 415, 400, 422 on POST, as plain text — the content type, the JSON, or a field's type. See errors.

An address that is not in the data is not an error: it is 200 with verdict: unconfirmed.

Endpoints

GET/v1/validateaddress

Validate an address against the addresses and places layers: a verdict (confirmed, corrected, partial, unconfirmed), the corrected form, and each component's agreement.

POST/v1/validateaddress

The same, with the address as a JSON body of the same fields.

POST/v1/validate/commitaddress

Validate an address, seal a receipt, and optionally record the accepted correction as feedback for traffic learning.