oslew docs
Console
Menu

Geocoding an address

GET /v1/geocode turns a written address or a place name into ranked candidates. Each one says what matched, what the position locates, and how often answers like it are right, and the answer as a whole says whether the question had one answer at all and what to do about it. That last part is the one most integrations ignore, and the one worth reading first.

curl
curl -G "https://api.oslew.com/v1/geocode" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  --data-urlencode 'q=Museo Soumaya' \
  --data-urlencode 'limit=3'
Python
from oslew import Client

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

answer = client.geocode("Museo Soumaya", limit=3)
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.geocode("Museo Soumaya", { limit: 3 });
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1

{
  "query": "Museo Soumaya",
  "name": "Museo Soumaya",
  "context": null,
  "parse": {
    "name": "Museo Soumaya",
    "method": "passthrough"
  },
  "context_resolution": null,
  "near": null,
  "results": [
    {
      "doc": 348329,
      "name": "Museo Soumaya",
      "lat": 19.44062110346353,
      "lon": -99.20465953606559,
      "bbox": [
        19.440487037931074,
        19.440755168997644,
        -99.20478863854248,
        -99.20453043361198
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Miguel Hidalgo",
        "region": "CMX",
        "country": "MX",
        "category": "museum",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Miguel Hidalgo",
        "region": "CMX",
        "country": "MX",
        "formatted": "Museo Soumaya, Miguel Hidalgo, CMX, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.5,
      "why": {
        "tokens": [
          "museo",
          "soumaya"
        ],
        "matched": 2,
        "extra": 0,
        "mode": "all",
        "tied": false,
        "prominence": 5,
        "rerank": 87
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": {
        "rating": null,
        "reviews": 0,
        "price": null,
        "hours": [
          [
            0,
            0
          ],
          [
            0,
            0
          ],
          [
            0,
            0
          ],
          [
            0,
            0
          ],
          [
            0,
            0
          ],
          [
            0,
            0
          ],
          [
            0,
            0
          ]
        ],
        "photo": "https://commons.wikimedia.org/wiki/Special:FilePath/Museo_Soumaya%2C_Ciudad_de_M%C3%A9xico%2C_M%C3%A9xico%2C_2015-07-18%2C_DD_12.JPG",
        "provenance": {
          "name": "wikidata",
          "release": "2026-11-23",
          "license": "CC0; images under their Commons licences"
        }
      }
    },
    {
      "doc": 318314,
      "name": "Museo Soumaya",
      "lat": 19.33886538628843,
      "lon": -99.19254435060174,
      "bbox": [
        19.338731342470982,
        19.33899943010779,
        -99.19267344656319,
        -99.19241525466357
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Álvaro Obregón",
        "region": "CMX",
        "country": "MX",
        "category": "museum",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Álvaro Obregón",
        "region": "CMX",
        "country": "MX",
        "formatted": "Museo Soumaya, Álvaro Obregón, CMX, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.5,
      "why": {
        "tokens": [
          "museo",
          "soumaya"
        ],
        "matched": 2,
        "extra": 0,
        "mode": "all",
        "tied": false,
        "prominence": 0,
        "rerank": 85
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": null
    },
    {
      "doc": 385507,
      "name": "Museo Soumaya - Auguste Rondin",
      "lat": 19.53106621771892,
      "lon": -99.23296424906052,
      "bbox": [
        19.530932130179863,
        19.531200305259414,
        -99.23309336673412,
        -99.23283513141011
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Tlalnepantla de Baz",
        "region": null,
        "country": "MX",
        "category": "museum",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Tlalnepantla de Baz",
        "country": "MX",
        "formatted": "Museo Soumaya - Auguste Rondin, Tlalnepantla de Baz, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.5,
      "why": {
        "tokens": [
          "museo",
          "soumaya"
        ],
        "matched": 2,
        "extra": 2,
        "mode": "all",
        "tied": false,
        "prominence": 0,
        "rerank": 55
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": null
    }
  ],
  "mode": "all",
  "tied_at_top": 1,
  "tie_probe": 32,
  "interpolated": false,
  "decision": {
    "action": "refuse",
    "margin": 0.03733337
  },
  "epoch": 30,
  "release": "2026-08-19.0",
  "examined": 420,
  "postings": 424,
  "segments": 2,
  "store_requests": 0,
  "store_bytes": 0,
  "took_us": 12238
}

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

Three places carry the name. The first is the museum in Miguel Hidalgo; the second is another museum of the same name in Álvaro Obregón. Both matched both words exactly, and the first ranks higher on why.prominence— 5 against 0, from how widely the place is referenced in Wikidata — so they do not tie, andtied_at_top is 1. The third matched too, but its name has two words the query did not ask for (why.extra: 2), which puts it below both.

Not tied is not the same as settled. decision.action is refuse: the two museums are within 0.04 of each other on the service's margin score, under the 0.12 it takes to call one the answer. There really are two Museo Soumaya buildings, and nothing in Museo Soumaya says which you meant. Branch ondecision first; decisions and receipts has the rules.

confidence is 0.5 on all three. That is not a coin toss: it is the calibration saying it has not measured enough answers of this shape — a name with no context that nothing ties — to say more. Seereading a result for every field.

Parameters

ParameterDefaultWhat it does
qrequiredThe text. Everything after the last comma is administrative context; everything before it is the name. Blank is 400, q is required.
nearnonelat,lon. Keeps only candidates in the grid cell of about 10 km that holds the point. A filter, not a bias.
limit5Results returned, clamped to 1–50. limit=500 answers 50; it is not refused.
interpolatetruePlace a house number the data does not hold between the two recorded numbers either side of it. false returns the nearest recorded row instead.
countrynoneComma-separated ISO codes, MX. Results in any other country are dropped after ranking. A filter on the answer, not context for the search.
licensenoneKeep only results whose licence is on the list: permissive, odbl, or a fragment of an SPDX id such as CDLA. For when you will store results and cannot take share-alike.
receiptfalsetrue adds a receipt: which store answered and a SHA-256 of the answer, to keep beside a stored result. See receipts.
releasenoneRequire this data release; 400 if the service is answering from another. For a pipeline that must not mix releases.
epochnoneAnswer from an earlier store epoch, where the deployment keeps them; otherwise 400. See conventions.

There is no postcode or city parameter. A parameter the route does not take is dropped silently, so &postcode=03940 changes nothing: a postcode or a city goes in q, after the last comma. country is the exception, and it filters rather than informs the search.

The last comma

q is split once, at its last comma. The part before is the name: the street and house number, or the name of a place. The part after is the context: one postcode, one city, one region or one country. The answer echoes both, as name and context, so you can see how your text was read.

You sendNameContext
Avenida Insurgentes Sur 1602, 03940Avenida Insurgentes Sur 160203940
Avenida Insurgentes Sur 1602, Ciudad de MéxicoAvenida Insurgentes Sur 1602Ciudad de México
Avenida Insurgentes Sur 1602, 03940, MXAvenida Insurgentes Sur 1602, 03940MX only
Museo SoumayaMuseo Soumayanone
Museo Soumaya,Museo Soumaya,none — an empty side means no split

The third row is the mistake to avoid. Only MX is context there; 03940 becomes a word of the name, and no address row has a postcode among its words. The row can still win, but as a partial match, with the lower confidence that goes with one. The same happens to a colonia or a second address line left in the middle: every word before the last comma is a word the name has to match. Send the one piece of context that narrows the most — usually the postcode — and nothing between it and the street.

curl
curl -G "https://api.oslew.com/v1/geocode" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  --data-urlencode 'q=Avenida Insurgentes Sur 1602, 03940' \
  --data-urlencode 'limit=1'
Python
from oslew import Client

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

answer = client.geocode("Avenida Insurgentes Sur 1602, 03940", limit=1)
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.geocode("Avenida Insurgentes Sur 1602, 03940", { limit: 1 });
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1

{
  "query": "Avenida Insurgentes Sur 1602, 03940",
  "name": "Avenida Insurgentes Sur 1602",
  "context": "03940",
  "parse": {
    "name": "Avenida Insurgentes Sur 1602",
    "context": "03940",
    "house_number": "1602",
    "street": "Avenida Insurgentes Sur",
    "postcode": "03940",
    "method": "comma_parts"
  },
  "context_resolution": {
    "terms": [
      "03940"
    ],
    "divisions": [],
    "known": true,
    "fallback": false
  },
  "near": null,
  "results": [
    {
      "doc": 1645192,
      "name": "AVENIDA INSURGENTES SUR 1602",
      "lat": 19.364069672979937,
      "lon": -99.18198831998704,
      "bbox": [
        19.3639356260916,
        19.36420371987013,
        -99.18211741026626,
        -99.18185922973113
      ],
      "precision": "rooftop",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Ciudad de México",
        "region": null,
        "country": "MX",
        "category": null,
        "postcode": "03940",
        "street": "AVENIDA INSURGENTES SUR"
      },
      "normalized": {
        "house_number": "1602",
        "street": "AVENIDA INSURGENTES SUR",
        "locality": "Ciudad de México",
        "postcode": "03940",
        "country": "MX",
        "formatted": "AVENIDA INSURGENTES SUR 1602, Ciudad de México, 03940, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "exact",
        "street": "exact",
        "locality": "exact",
        "region": "missing",
        "postcode": "exact",
        "country": "missing"
      },
      "confidence": 0.72772276,
      "why": {
        "tokens": [
          "1602",
          "avenida",
          "insurgentes",
          "sur"
        ],
        "matched": 4,
        "extra": 0,
        "mode": "all",
        "tied": false,
        "prominence": 0,
        "rerank": 100
      },
      "provenance": {
        "name": "overture-addresses",
        "release": "2026-08-19.0",
        "license": "permissive (per-source, see record)"
      },
      "attributes": null
    }
  ],
  "mode": "all",
  "tied_at_top": 1,
  "tie_probe": 16,
  "interpolated": false,
  "decision": {
    "action": "act",
    "margin": 0.18940592
  },
  "epoch": 30,
  "release": "2026-08-19.0",
  "examined": 1612,
  "postings": 3471,
  "segments": 2,
  "store_requests": 0,
  "store_bytes": 0,
  "took_us": 15244
}

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

The postcode resolved (known: true: some address spells it), the house number matched a recorded address point, and the answer is rooftop with a confidence of 0.73 and decision.actionact. components.locality is exact because the context was satisfied.

How the context is resolved

A caller spells an area the way they know it, and an address row spells it the way its source did —CMX, MX-CMX, Ciudad de México, or a borough inside it. So the context is matched three ways, and a result found by any of them is in context:

  1. As spelled, ignoring case and accents, against what each row records: a place's locality, region and country; an address's locality, postcode and country. A postcode therefore narrows addresses. Places are not indexed by postcode, so for a named place — a museum, a shop — send the city instead.
  2. As an ISO code. When a country or region division bears the name, its code joins the terms: a country's ISO 3166-1 code, and a region's ISO 3166-2 code both with and without the country prefix (MX-CMX and CMX).
  3. By containment. Any division bearing the name — up to four of them — is searched by its polygon, so a place inside it counts whatever its own address says.

Division names are matched exactly first, and only when no division has the exact name, as a whole-word prefix:Polanco then finds the divisions whose names begin with the word Polanco, and neverPolancos.

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

{
  "query": "Avenida Insurgentes Sur 1602, Ciudad de México",
  "name": "Avenida Insurgentes Sur 1602",
  "context": "Ciudad de México",
  "parse": {
    "name": "Avenida Insurgentes Sur 1602",
    "context": "Ciudad de México",
    "house_number": "1602",
    "street": "Avenida Insurgentes Sur",
    "locality": "Ciudad de México",
    "method": "comma_parts"
  },
  "context_resolution": {
    "terms": [
      "Ciudad de México",
      "MX-CMX",
      "CMX"
    ],
    "divisions": [
      {
        "doc": 1560,
        "id": "bc8dbc34-544b-47c4-bdb1-d3f5ecfc6af7",
        "name": "Ciudad de México",
        "subtype": "region",
        "country": "MX",
        "region": "MX-CMX",
        "admin_level": 1,
        "via": "interior",
        "provenance": {
          "name": "overture-divisions",
          "release": "2026-08-19.0",
          "license": "ODbL-1.0"
        }
      },
      {
        "doc": 1522,
        "id": "2b1d49e2-98ef-4665-b9f6-1ce96c9f015b",
        "name": "Ciudad de México",
        "subtype": "locality",
        "country": "MX",
        "region": "MX-CMX",
        "admin_level": null,
        "via": "interior",
        "provenance": {
          "name": "overture-divisions",
          "release": "2026-08-19.0",
          "license": "ODbL-1.0"
        }
      }
    ],
    "known": true,
    "fallback": false
  },
  "near": null,
  "results": [
    {
      "doc": 1645192,
      "name": "AVENIDA INSURGENTES SUR 1602",
      "lat": 19.364069672979937,
      "lon": -99.18198831998704,
      "bbox": [
        19.3639356260916,
        19.36420371987013,
        -99.18211741026626,
        -99.18185922973113
      ],
      "precision": "rooftop",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Ciudad de México",
        "region": null,
        "country": "MX",
        "category": null,
        "postcode": "03940",
        "street": "AVENIDA INSURGENTES SUR"
      },
      "normalized": {
        "house_number": "1602",
        "street": "AVENIDA INSURGENTES SUR",
        "locality": "Ciudad de México",
        "postcode": "03940",
        "country": "MX",
        "formatted": "AVENIDA INSURGENTES SUR 1602, Ciudad de México, 03940, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "exact",
        "street": "exact",
        "locality": "exact",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.3960396,
      "why": {
        "tokens": [
          "1602",
          "avenida",
          "insurgentes",
          "sur"
        ],
        "matched": 4,
        "extra": 0,
        "mode": "all",
        "tied": false,
        "prominence": 0,
        "rerank": 89
      },
      "provenance": {
        "name": "overture-addresses",
        "release": "2026-08-19.0",
        "license": "permissive (per-source, see record)"
      },
      "attributes": null
    },
    {
      "doc": 131752,
      "name": "AVENIDA INSURGENTES SUR",
      "lat": 19.306485580000658,
      "lon": -99.18666049037793,
      "bbox": [
        19.30635154353446,
        19.306619616468854,
        -99.18678958317274,
        -99.18653139760642
      ],
      "precision": "street",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Ciudad de México",
        "region": null,
        "country": "MX",
        "category": null,
        "postcode": "04530",
        "street": "AVENIDA INSURGENTES SUR"
      },
      "normalized": {
        "street": "AVENIDA INSURGENTES SUR",
        "locality": "Ciudad de México",
        "postcode": "04530",
        "country": "MX",
        "formatted": "AVENIDA INSURGENTES SUR, Ciudad de México, 04530, MX"
      },
      "components": {
        "name": "partial",
        "house_number": "missing",
        "street": "partial",
        "locality": "exact",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.35,
      "why": {
        "tokens": [
          "1602",
          "avenida",
          "insurgentes",
          "sur"
        ],
        "matched": 3,
        "extra": 0,
        "mode": "all",
        "tied": true,
        "prominence": 0,
        "rerank": 67
      },
      "provenance": {
        "name": "overture-addresses",
        "release": "2026-08-19.0",
        "license": "permissive (per-source, see record)"
      },
      "attributes": null
    },
    {
      "doc": 131754,
      "name": "AVENIDA INSURGENTES SUR",
      "lat": 19.305591323802492,
      "lon": -99.18614134691849,
      "bbox": [
        19.30545728760145,
        19.305725360005535,
        -99.18627043943381,
        -99.18601225442644
      ],
      "precision": "street",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Ciudad de México",
        "region": null,
        "country": "MX",
        "category": null,
        "postcode": "04530",
        "street": "AVENIDA INSURGENTES SUR"
      },
      "normalized": {
        "street": "AVENIDA INSURGENTES SUR",
        "locality": "Ciudad de México",
        "postcode": "04530",
        "country": "MX",
        "formatted": "AVENIDA INSURGENTES SUR, Ciudad de México, 04530, MX"
      },
      "components": {
        "name": "partial",
        "house_number": "missing",
        "street": "partial",
        "locality": "exact",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.35,
      "why": {
        "tokens": [
          "1602",
          "avenida",
          "insurgentes",
          "sur"
        ],
        "matched": 3,
        "extra": 0,
        "mode": "all",
        "tied": true,
        "prominence": 0,
        "rerank": 67
      },
      "provenance": {
        "name": "overture-addresses",
        "release": "2026-08-19.0",
        "license": "permissive (per-source, see record)"
      },
      "attributes": null
    }
  ],
  "mode": "all",
  "tied_at_top": 1,
  "tie_probe": 371,
  "interpolated": false,
  "decision": {
    "action": "refuse",
    "margin": 0.076227725,
    "ask_for": [
      "postcode"
    ]
  },
  "epoch": 30,
  "release": "2026-08-19.0",
  "examined": 29202,
  "postings": 353658,
  "segments": 2,
  "store_requests": 0,
  "store_bytes": 0,
  "took_us": 22012
}

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

context_resolution reports what happened. terms is every spelling searched — here the name as written, then MX-CMX and CMX from the region division. divisionslists the divisions that bear the name: a region and a locality, both called Ciudad de México.known says whether the context named anything the index knows at all.

Compare it with the postcode answer above. The same rooftop wins, but Mexico City holds two million addresses where a postcode holds about a thousand, so confidence falls to 0.40 and decision is refuse withask_for: ["postcode"]: the service says what would settle it.

fallback is the one to branch on. When nothing satisfies the context, the search runs again without it rather than answering nothing, and says so: fallback: true, every result'scomponents.locality is missing, and confidence is scored as if no context had been sent. The results are then the best matches for the name anywhere, which is rarely what a caller who typed a city wanted. Tell the user, or ask. context_resolution is null when q had no comma.

near is a filter, not a bias

near=lat,lon keeps only candidates inside the level-10 grid cell that contains the point — a square of roughly 10 km, fixed on the cell grid, not a circle centred on you. Everything outside that cell is gone, however good a match, and there is no fallback: a near that excludes every match answers an empty list. A point close to a cell's edge excludes places a few hundred metres away on the other side of it.

Without it, a name borne by many places answers from wherever the index happens to hold them first:

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

{
  "query": "OXXO",
  "name": "OXXO",
  "context": null,
  "parse": {
    "name": "OXXO",
    "method": "passthrough"
  },
  "context_resolution": null,
  "near": null,
  "results": [
    {
      "doc": 19524,
      "name": "OXXO",
      "lat": 20.612046892212046,
      "lon": -105.23387968256127,
      "bbox": [
        20.611911606339586,
        20.612182178088325,
        -105.23401122598554,
        -105.2337481391495
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Puerto Vallarta",
        "region": null,
        "country": "MX",
        "category": "convenience_store",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Puerto Vallarta",
        "country": "MX",
        "formatted": "OXXO, Puerto Vallarta, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.99148935,
      "why": {
        "tokens": [
          "oxxo"
        ],
        "matched": 1,
        "extra": 0,
        "mode": "all",
        "tied": true,
        "prominence": 0,
        "rerank": 75
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": null
    },
    {
      "doc": 20122,
      "name": "OXXO",
      "lat": 20.610405973859322,
      "lon": -105.23397110804532,
      "bbox": [
        20.61027068832683,
        20.610541259395642,
        -105.23410265149454,
        -105.23383956460859
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Puerto Vallarta",
        "region": null,
        "country": "MX",
        "category": "convenience_store",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Puerto Vallarta",
        "country": "MX",
        "formatted": "OXXO, Puerto Vallarta, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.99148935,
      "why": {
        "tokens": [
          "oxxo"
        ],
        "matched": 1,
        "extra": 0,
        "mode": "all",
        "tied": true,
        "prominence": 0,
        "rerank": 75
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": null
    },
    {
      "doc": 20812,
      "name": "OXXO",
      "lat": 20.62072596660037,
      "lon": -105.22510306857126,
      "bbox": [
        20.620590680172317,
        20.620861253032217,
        -105.2252346095983,
        -105.22497152755672
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Puerto Vallarta",
        "region": null,
        "country": "MX",
        "category": "convenience_store",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Puerto Vallarta",
        "country": "MX",
        "formatted": "OXXO, Puerto Vallarta, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.99148935,
      "why": {
        "tokens": [
          "oxxo"
        ],
        "matched": 1,
        "extra": 0,
        "mode": "all",
        "tied": true,
        "prominence": 0,
        "rerank": 75
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": null
    }
  ],
  "mode": "all",
  "tied_at_top": 16,
  "tie_probe": 32,
  "interpolated": false,
  "decision": {
    "action": "refuse",
    "margin": 0,
    "disambiguation": {
      "tied": 16,
      "options": [
        {
          "rank": 1,
          "label": "OXXO, Puerto Vallarta, MX",
          "country": "MX",
          "locality": "Puerto Vallarta"
        },
        {
          "rank": 2,
          "label": "OXXO, Puerto Vallarta, MX",
          "country": "MX",
          "locality": "Puerto Vallarta"
        },
        {
          "rank": 3,
          "label": "OXXO, Puerto Vallarta, MX",
          "country": "MX",
          "locality": "Puerto Vallarta"
        },
        {
          "rank": 4,
          "label": "OXXO, Puerto Vallarta, JAL, MX",
          "country": "MX",
          "locality": "Puerto Vallarta"
        },
        {
          "rank": 5,
          "label": "OXXO, Puerto Vallarta, MX",
          "country": "MX",
          "locality": "Puerto Vallarta"
        },
        {
          "rank": 6,
          "label": "Oxxo, Boca de Tomatlán, JAL, MX",
          "country": "MX",
          "locality": "Boca de Tomatlán"
        },
        {
          "rank": 7,
          "label": "oxxo, Pérula, JAL, MX",
          "country": "MX",
          "locality": "Pérula"
        },
        {
          "rank": 8,
          "label": "OXXO, Tomatlán, MX",
          "country": "MX",
          "locality": "Tomatlán"
        }
      ]
    }
  },
  "epoch": 30,
  "release": "2026-08-19.0",
  "examined": 98,
  "postings": 1736,
  "segments": 2,
  "store_requests": 0,
  "store_bytes": 0,
  "took_us": 805
}

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

With the Zócalo as near, the same query answers from the cell around it:

curl
curl -G "https://api.oslew.com/v1/geocode" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  --data-urlencode 'q=OXXO' \
  --data-urlencode 'near=19.4326,-99.1332' \
  --data-urlencode 'limit=3'
Python
from oslew import Client

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

answer = client.geocode("OXXO", near="19.4326,-99.1332", limit=3)
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.geocode("OXXO", { near: "19.4326,-99.1332", limit: 3 });
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 298
ratelimit-reset: 1

{
  "query": "OXXO",
  "name": "OXXO",
  "context": null,
  "parse": {
    "name": "OXXO",
    "method": "passthrough"
  },
  "context_resolution": null,
  "near": [
    19.4326,
    -99.1332
  ],
  "results": [
    {
      "doc": 312143,
      "name": "OXXO",
      "lat": 19.41387107720213,
      "lon": -99.18570872993081,
      "bbox": [
        19.413737020076393,
        19.414005134329585,
        -99.18583782221324,
        -99.18557963767167
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Miguel Hidalgo",
        "region": "CMX",
        "country": "MX",
        "category": "convenience_store",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Miguel Hidalgo",
        "region": "CMX",
        "country": "MX",
        "formatted": "OXXO, Miguel Hidalgo, CMX, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.99148935,
      "why": {
        "tokens": [
          "oxxo"
        ],
        "matched": 1,
        "extra": 0,
        "mode": "all",
        "tied": true,
        "prominence": 0,
        "rerank": 75
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": null
    },
    {
      "doc": 312176,
      "name": "Oxxo",
      "lat": 19.41758879104772,
      "lon": -99.186833538943,
      "bbox": [
        19.417454733014733,
        19.417722849082416,
        -99.18696263183097,
        -99.18670444607832
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Miguel Hidalgo",
        "region": "CMX",
        "country": "MX",
        "category": "convenience_store",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Miguel Hidalgo",
        "region": "CMX",
        "country": "MX",
        "formatted": "Oxxo, Miguel Hidalgo, CMX, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.99148935,
      "why": {
        "tokens": [
          "oxxo"
        ],
        "matched": 1,
        "extra": 0,
        "mode": "all",
        "tied": true,
        "prominence": 0,
        "rerank": 75
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": null
    },
    {
      "doc": 312833,
      "name": "Oxxo",
      "lat": 19.405177436199025,
      "lon": -99.184670458663,
      "bbox": [
        19.40504338092024,
        19.405311491479537,
        -99.18479955038647,
        -99.18454136696286
      ],
      "precision": "poi",
      "precision_m": 6.756173533775122,
      "hierarchy": {
        "locality": "Miguel Hidalgo",
        "region": "CMX",
        "country": "MX",
        "category": "convenience_store",
        "postcode": null,
        "street": null
      },
      "normalized": {
        "locality": "Miguel Hidalgo",
        "region": "CMX",
        "country": "MX",
        "formatted": "Oxxo, Miguel Hidalgo, CMX, MX"
      },
      "components": {
        "name": "exact",
        "house_number": "missing",
        "street": "missing",
        "locality": "missing",
        "region": "missing",
        "postcode": "missing",
        "country": "missing"
      },
      "confidence": 0.99148935,
      "why": {
        "tokens": [
          "oxxo"
        ],
        "matched": 1,
        "extra": 0,
        "mode": "all",
        "tied": true,
        "prominence": 0,
        "rerank": 75
      },
      "provenance": {
        "name": "overture-places",
        "release": "2026-08-19.0",
        "license": "CDLA-Permissive-2.0"
      },
      "attributes": null
    }
  ],
  "mode": "all",
  "tied_at_top": 16,
  "tie_probe": 16,
  "interpolated": false,
  "decision": {
    "action": "refuse",
    "margin": 0,
    "disambiguation": {
      "tied": 16,
      "options": [
        {
          "rank": 1,
          "label": "OXXO, Miguel Hidalgo, CMX, MX",
          "country": "MX",
          "locality": "Miguel Hidalgo"
        },
        {
          "rank": 2,
          "label": "Oxxo, Miguel Hidalgo, CMX, MX",
          "country": "MX",
          "locality": "Miguel Hidalgo"
        },
        {
          "rank": 3,
          "label": "Oxxo, Miguel Hidalgo, CMX, MX",
          "country": "MX",
          "locality": "Miguel Hidalgo"
        },
        {
          "rank": 4,
          "label": "Oxxo, Miguel Hidalgo, CMX, MX",
          "country": "MX",
          "locality": "Miguel Hidalgo"
        },
        {
          "rank": 5,
          "label": "oxxo, MX",
          "country": "MX"
        },
        {
          "rank": 6,
          "label": "OXXO, San Pedro De Los Pinos, Ciudad de México, MX",
          "country": "MX",
          "locality": "San Pedro De Los Pinos"
        },
        {
          "rank": 7,
          "label": "Oxxo, Álvaro Obregón, CMX, MX",
          "country": "MX",
          "locality": "Álvaro Obregón"
        },
        {
          "rank": 8,
          "label": "OXXO, Ciudad de México, Ciudad de México, MX",
          "country": "MX",
          "locality": "Ciudad de México"
        }
      ]
    }
  },
  "epoch": 30,
  "release": "2026-08-19.0",
  "examined": 18,
  "postings": 25,
  "segments": 2,
  "store_requests": 0,
  "store_bytes": 0,
  "took_us": 361
}

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

Three things in that answer are worth reading:

  • The first result is about 6 km from the point. Inside the cell, results are ranked exactly as they would be without near; a tie is not broken by distance. For the nearest one, ask for a largerlimit and sort by distance yourself, or use nearby places with a category.
  • tied_at_top equals tie_probe, at 16: every candidate the search kept shared the top rank, so the true number of OXXOs in that cell is larger than 16.
  • examined fell from 98 to 18. The index is stored in cell order, so the filter is applied before anything is scored: near makes a query cheaper, not dearer.

Use near when you know the answer must be in that area — a user's own city, a delivery zone. Do not use it to mean "prefer things close to me": it will silently drop the right answer when it is 11 km away. A malformed value is 400: near must be lat,lon, or near is out of range.

limit, and ties counted before it

limit defaults to 5 and is clamped to 1–50. However small it is, every search keeps at least eight candidates (or limit, if that is more), and tied_at_top is counted over everything keptbefore the list is cut. So asking for one result does not make an ambiguous query look unique:limit=1 on OXXO still says 16.

tie_probe is how many candidates the count was taken over. When tied_at_top equals it, every candidate kept was tied and the tie runs past what the search kept, so read it as "at least this many". For a decision it rarely matters: more than one is already the answer, and decision.action isrefuse.

Interpolation

The commonest thing a real address does is carry a house number the data does not hold. Its neighbours usually are held, and house numbers run along a block in order, so the service places the number between them. The rules are strict on purpose, because a guess dressed as an observation is worse than a coarser answer that says what it is:

  • Only the top result is interpolated; the alternates keep what they matched.
  • Only when the query has a house number, the top result is an address or street row (rooftop, address or street), and its own number is not already the one asked for.
  • The two numbers either side are looked up on the same street, in the same context. Same parity is tried first — even numbers run down one pavement and odd down the other, and a road is ten to twenty metres wide — and mixed parity only if that finds nothing.
  • No extrapolation. A number above the highest recorded or below the lowest is not placed; that is where a naive implementation puts a house in a field.
  • No more than a kilometre. Two recorded numbers further apart than 1,000 m are two runs of the same street name, not a block, and nothing is placed between them.

When it happens, the answer says so in four places:

FieldBecomes
interpolated (top level)true
precisioninterpolated
betweenThe two recorded numbers it was placed between, as strings: the evidence for a position no row holds. Absent otherwise.
precision_mHalf the distance between those two, or the usual cell error if that is larger: what the placement can actually be wrong by.

name and normalized carry the number you asked for, written in the country's order. In the accuracy benchmark, interpolation took the median error on a postcode-scoped address from 93 m to 19 m. interpolate=false turns it off for one request and returns the nearest recorded row instead — which is what to compare against if you want to see what it did.

Messy input

The same normalisation runs when the index is built and when a query arrives, so the two only ever have to agree with themselves. What it does:

  • Case and accents are folded. ciudad de mexico and Ciudad de México are the same words. Only Latin, Greek and Cyrillic accents are stripped; marks that carry meaning in other scripts are kept.
  • Punctuation is a space. Av. Insurgentes Sur is the words av insurgentes sur.
  • Word order does not matter. The query is a set of words: 1602 Avenida Insurgentes Sur and Avenida Insurgentes Sur 1602 are the same query, and a repeated word counts once. The house number is found at either end.
  • Abbreviations fold to one word, in the index and the query alike: av, ave,avda and avenue are avenida; calz is calzada,cda cerrada, col colonia, gral general,sta santa, ampl ampliacion, esqesquina; nte, ote and pte are the compass points;rd, ln, ct, hwy, pkwy, pl andsq are the English street types; and ordinals fold both ways — 5a isquinta, 5th is fifth.
  • dr, st and str depend on position. The last word that is not a number decides: there, dr is drive and st is street; anywhere before it, they are doctor and saint. So Dr Vértiz is Doctor Vértiz, andOcean Dr 123 is Ocean Drive with the number ignored for the decision. Folding either one way unconditionally made real streets unfindable.
  • A house number glued to the street is read. In Cerrada La Herradura22 the number 22 is taken off the end of the word, so interpolation still has a number to place, and the search splits the word into two terms it knows where it can.
  • Misspellings are repaired, and say so. A word of three or more letters the index has never seen is tried as an adjacent transposition (Banotre for Banorte), then as one edit, then as two known words run together (callejuarez). A result reached that way reports mode: fuzzy and components.name: fuzzy, never all, so a salvaged answer cannot pass for an exact one.
  • No transliteration and no translation. Normalisation leaves scripts and languages alone: Москва and Moskva are different words, and so are München and Munich. Chinese, Japanese and Korean, written without spaces, are matched as overlapping character pairs.

You do not need to clean input before sending it, and cleaning it is a way to lose information: an accent you strip costs nothing, but a house number you drop turns a rooftop answer into a street.

How results are ranked

Every candidate — from the places layer and the address layer, and from every way the context resolved — is merged into one list and ordered by three things, in this order:

  1. Words matched (why.matched), most first. One more matched word outranks anything else.
  2. Words in the name the query did not ask for (why.extra), fewest first. An exact name beats a longer one.
  3. Prominence (why.prominence, 0–15), highest first: a log scale of how widely a place is referenced in Wikidata, 0 where it is not matched there. Addresses have none.

Candidates equal on all three are tied. tied_at_top counts the ones tied with the first;why.tied on a result says whether any other candidate shares that result's rank. In the city example above, the two street rows are tied with each other and not with the top, which is why they saytied: true while tied_at_top is 1.

mode says how the best candidate was found: all (every word matched as typed),partial (some did), fuzzy (through a repair) or none. Matching counts words rather than requiring all of them, deliberately: a query often carries a word the index does not have, and requiring every word would answer nothing, which cannot be told apart from "no such place".

Branching on the answer

decision folds the margin, the ties and the missing fields into one of three actions, so start there. Then two things it does not decide for you: whether the context was ignored, and what the position locates.

Python
from oslew import Client

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

def locate(q: str):
    answer = client.geocode(q, limit=5)
    results = answer["results"]
    if not results:
        return "nothing", []                  # answered, and found nothing

    resolution = answer["context_resolution"]
    if resolution and resolution["fallback"]:
        return "context-ignored", results     # the city or postcode matched nothing

    decision = answer["decision"]
    if decision["action"] == "refuse":
        return "choose", results              # too close to call: show them, or add context
    if decision["action"] == "ask":
        return "ask", decision.get("ask_for", [])  # e.g. ["postcode"]: ask for that, then retry

    top = results[0]
    if top["precision"] in ("street", "address"):
        return "street-only", [top]           # found the street, not the door
    return "located", [top]                   # rooftop, interpolated, or a place
TypeScript
import { Client } from "@oslew/client";

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

async function locate(q: string) {
  const answer = await client.geocode(q, { limit: 5 });
  const results = answer.results;
  if (results.length === 0) return { kind: "nothing", results };

  if (answer.context_resolution?.fallback) {
    return { kind: "context-ignored", results }; // the city or postcode matched nothing
  }
  const { action, ask_for } = answer.decision;
  if (action === "refuse") return { kind: "choose", results };   // too close to call
  if (action === "ask") return { kind: "ask", fields: ask_for ?? [] }; // e.g. ["postcode"]

  const top = results[0];
  if (top.precision === "street" || top.precision === "address") {
    return { kind: "street-only", results: [top] };
  }
  return { kind: "located", results: [top] };     // rooftop, interpolated, or a place
}
  • decision is a top-level field of the answer, computed over every candidate the search kept, before limit cut the list. A tied answer can carry a high confidence (the OXXO answers above say 0.99, since each is an exact match for the name) and still not say which one; that isrefuse, and decision.disambiguation lists the tied options with a label for each.
  • precision says what the position locates; precision_m says how far off it can be. A street result is the position of one address row on that street, and itsprecision_m is about that row, not about where on the street your number is.
  • confidence is the share of answers with the same shape that were right on a scored hold-out: 0.99 means 99 in 100. 0.5 means the shape was not measured often enough to say. It is an upper bound on field accuracy, so use it to order a review queue, not as a probability to multiply. decisionalready weighs it.
  • doc is a position inside one segment of the index, not an identifier. Do not store it as a key: it changes when the index is rebuilt.

What a refusal looks like

A blank q is refused with 400 — the only field the route requires. A nearthat does not parse is a 400 naming the problem. A limit that is not a number is refused by the framework before the route runs, as plain text rather than JSON; seeerrors.

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

{
  "error": "q is required"
}

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

A query that finds nothing is not an error: it is 200 with an empty results, because "nothing here" is an answer.

Endpoints

GET/v1/geocodeaddress

Resolve a name, or a number and street, with optional context.