Clean a customer CSV
A file of customer addresses, typed by customers over years: misspelt streets, missing postcodes, a museum where a street should be, a street that does not exist. You want coordinates you can trust for most rows, a short list a person should look at, and a list of rows that are not addresses at all — and you want the split made on evidence rather than on a single score.
Looping over /v1/geocode would mean pacing, retrying and resuming it yourself. Abatch job does all three: it is paced by the service at your key's address rate, it is durable before it is acknowledged, and a job whose pod dies is picked up by another. So the file goes up once, the answers come down once, and only the rows the geocoder's own evidence leaves in doubt get a second, slower look from validation.
The approach
- Build the upload yourself: two columns,
idand one address line. The line is the street and number, then a comma, then the postcode — or the city when there is no postcode. Only the text after the last comma is read as context, and the postcode is the best context there is: it takes the median error from 673 m to 93 m (see getting better accuracy). - Submit it to
POST /v1/batch?format=csv. A job id comes back at once. - Wait by polling
GET /v1/batch/{id}and sleeping for what itsremaining_ssays. - Collect
GET /v1/batch/{id}/results?format=csv: one row out for every row in, in order, carrying yourid. - Triage each row on four fields —
error,tied_at_top,precisionandconfidence— into accept, review or reject. - Re-check the review pile with
POST /v1/validate. A geocoder ranks candidates by how well they match the text; a validator compares the parts you gave — number, street, postcode — with the parts of what it found, and says which disagree. - Write
accepted.csv,review.csvandrejected.csv.
Submitting a CSV, and the job the service answers with:
curl -X POST "https://api.oslew.com/v1/batch?format=csv" \
-H "Authorization: Bearer $GEO_API_KEY" \
-H "Content-Type: text/csv" \
--data-binary @addresses.csvfrom oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.batch(
open("addresses.csv").read(),
format="csv",
content_type="text/csv",
)import { readFile } from "node:fs/promises";
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.batch(await readFile("addresses.csv", "utf8"), { format: "csv", contentType: "text/csv" });HTTP/1.1 202 Accepted
content-type: application/json
ratelimit-limit: 1
ratelimit-remaining: 1
ratelimit-reset: 1
{
"id": "KNBDU4TD1RrnARXRKn0jodCf",
"tenant": "docs-batch",
"state": "queued",
"rows": 5,
"done": 0,
"found": 0,
"rps": 1,
"format": "csv",
"created_at": 1795427402,
"updated_at": 1795427402,
"epoch": 1,
"owner": "docs-examples",
"heartbeat_at": 1795427402,
"parts": 0
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
The job is stored before the 202 is sent. rps is the rate it will be worked at — the submitting key's own address rate, 1 here — so five rows will take about five seconds, andremaining_s says so as soon as you poll.
The program
Both versions read customers.csv with id, street, city andpostcode columns — street carrying the house number, as people write it — and write three files beside it. The key is read from GEO_API_KEY. Run the TypeScript withnpx tsx clean-csv.ts customers.csv, or with Bun or Deno; see clients.
"""Clean a customer CSV: geocode it as one batch job, sort the answers into
accept, review and reject, re-check the review pile with validation, and
write three files.
python clean_csv.py customers.csv
customers.csv has a header row with id, street, city and postcode columns;
street carries the house number, as people write it.
"""
import csv
import io
import sys
import time
from oslew import Client, RateLimited, retry_on_rate_limit
client = Client(base_url="https://api.oslew.com") # the key is read from GEO_API_KEY
ACCEPT_AT = 0.7 # share of answers like this within 250 m; see the triage notes
DOOR = {"rooftop", "interpolated"} # precisions that locate a door, not a street
INTERPOLATED_MAX_M = 50 # an interpolated door less certain than this is reviewed
PARTS = ["house_number", "street", "locality", "region", "postcode", "country"]
def one_line(value):
"""The service reads one line per row: no newlines inside a field."""
return " ".join((value or "").split())
# 1. Read the customer file and build the upload: an id and one address per row.
customers, accepted, review, rejected = {}, [], [], []
upload = io.StringIO()
out = csv.writer(upload)
out.writerow(["id", "address"])
with open(sys.argv[1], encoding="utf-8-sig", newline="") as f: # -sig: Excel's BOM
for raw in csv.DictReader(f):
row = {k.strip().lower(): one_line(v) for k, v in raw.items() if k}
customers[row["id"]] = row
if not row.get("street"):
rejected.append({"id": row["id"], "reason": "no street given"})
continue
# Only the text after the last comma is context. The postcode is the
# best context there is; the city is second best.
context = row.get("postcode") or row.get("city")
out.writerow([row["id"], f"{row['street']}, {context}" if context else row["street"]])
# 2. Submit. `format` decides how the body is read; the content type does not.
job = retry_on_rate_limit(client.batch, upload.getvalue(), format="csv", content_type="text/csv")
print(f"job {job['id']}: {job['rows']} rows at {job['rps']} a second")
# 3. Wait as long as the job says it needs, checking at most once a minute.
while job["state"] not in ("done", "failed", "cancelled"):
time.sleep(min(max(job.get("remaining_s", 5), 5), 60))
try:
job = client.get_batch(job["id"])
except RateLimited:
continue # the job is spending this key's address rate; it is still running
print(f"{job['done']}/{job['rows']} rows, {job['found']} found, ~{job['remaining_s']} s left")
if job["state"] != "done":
sys.exit(f"job {job['state']}: {job.get('error')}")
# 4. Collect every answer, one per input row, and triage it.
answers = csv.DictReader(io.StringIO(client.batch_results(job["id"], format="csv")))
def triage(a):
if a["error"]:
return "reject", a["error"] # "no match"
if int(a["tied_at_top"]) > 1:
return "review", f"matches {a['tied_at_top']} places equally well"
if a["precision"] not in DOOR:
return "review", f"precision is {a['precision']}"
if a["precision"] == "interpolated" and float(a["precision_m"]) > INTERPOLATED_MAX_M:
return "review", f"interpolated to within {float(a['precision_m']):.0f} m"
confidence = float(a["confidence"])
if confidence == 0.5:
return "review", "too few answers like this one to calibrate"
if confidence < ACCEPT_AT:
return "review", f"confidence {confidence:.2f}"
return "accept", "geocoded"
for a in answers:
bucket, why = triage(a)
if bucket == "accept":
accepted.append({**a, "note": why})
elif bucket == "review":
review.append({**a, "reason": why})
else:
rejected.append({"id": a["id"], "input": a["q"], "reason": why})
# 5. Re-check the review pile with validation, which compares part by part.
# Paced at the key's address rate, which the job reported.
interval = 1 / job["rps"] if job["rps"] else 0.0
still = []
for a in review:
c = customers[a["id"]]
body = {"text": c.get("street"), "locality": c.get("city"),
"postcode": c.get("postcode"), "country": c.get("country")}
started = time.monotonic()
v = retry_on_rate_limit(client.post_validate, {k: x for k, x in body.items() if x}, attempts=5)
time.sleep(max(0.0, interval - (time.monotonic() - started)))
# A correction within two edits can be a different street; accept it
# only when it is as well calibrated as a first-time accept.
if v["verdict"] == "confirmed" or (v["verdict"] == "corrected" and v["confidence"] >= ACCEPT_AT):
matched = {p["name"]: p["matched"] for p in v["components"]}
accepted.append({"id": a["id"], "q": a["q"], "formatted": v["formatted"],
"lat": v["lat"], "lon": v["lon"], "precision": v["precision"],
"confidence": v["confidence"], **{p: matched.get(p) for p in PARTS},
"note": v["verdict"]})
elif v["verdict"] in ("corrected", "partial"):
still.append({"id": a["id"], "input": a["q"], "reason": a["reason"],
"suggestion": v["formatted"], "why": v["why"]})
else:
rejected.append({"id": a["id"], "input": a["q"], "reason": "validation: " + v["why"]})
# 6. Write the three files.
def write(name, rows, fields):
with open(name, "w", encoding="utf-8", newline="") as f:
w = csv.DictWriter(f, fieldnames=fields, extrasaction="ignore")
w.writeheader()
w.writerows(rows)
write("accepted.csv", accepted,
["id", "q", "formatted", "lat", "lon", "precision", "confidence", *PARTS, "note"])
write("review.csv", still, ["id", "input", "reason", "suggestion", "why"])
write("rejected.csv", rejected, ["id", "input", "reason"])
print(f"{len(accepted)} accepted, {len(still)} to review, {len(rejected)} rejected")// Clean a customer CSV: geocode it as one batch job, sort the answers into
// accept, review and reject, re-check the review pile with validation, and
// write three files.
//
// npx tsx clean-csv.ts customers.csv
//
// customers.csv has a header row with id, street, city and postcode columns;
// street carries the house number, as people write it.
import { readFile, writeFile } from "node:fs/promises";
import { Client, RateLimited, retryOnRateLimit } from "@oslew/client";
import type { BatchJob, PostValidateBody } from "@oslew/client";
const client = new Client({ baseUrl: "https://api.oslew.com" }); // the key is read from GEO_API_KEY
const ACCEPT_AT = 0.7; // share of answers like this within 250 m; see the triage notes
const DOOR = new Set(["rooftop", "interpolated"]); // precisions that locate a door, not a street
const INTERPOLATED_MAX_M = 50; // an interpolated door less certain than this is reviewed
const PARTS = ["house_number", "street", "locality", "region", "postcode", "country"];
type Row = Record<string, string | number | null | undefined>;
const sleep = (ms: number) => new Promise((done) => setTimeout(done, ms));
// RFC 4180: quoted fields, doubled quotes, commas and newlines inside quotes.
function parseCsv(text: string): string[][] {
const rows: string[][] = [];
let row: string[] = [];
let field = "";
let quoted = false;
for (let i = 0; i < text.length; i++) {
const c = text[i];
if (quoted) {
if (c === '"' && text[i + 1] === '"') (field += '"'), i++;
else if (c === '"') quoted = false;
else field += c;
} else if (c === '"') quoted = true;
else if (c === ",") row.push(field), (field = "");
else if (c === "\n" || c === "\r") {
if (c === "\r" && text[i + 1] === "\n") i++;
row.push(field), (field = "");
if (row.some((f) => f !== "")) rows.push(row);
row = [];
} else field += c;
}
row.push(field);
if (row.some((f) => f !== "")) rows.push(row);
return rows;
}
function records(text: string): Record<string, string>[] {
const [header, ...rows] = parseCsv(text.replace(/^/, "")); // Excel's BOM
const names = header.map((h) => h.trim().toLowerCase());
return rows.map((r) => Object.fromEntries(names.map((n, i) => [n, r[i] ?? ""])));
}
const cell = (v: unknown) => {
const s = v === null || v === undefined ? "" : String(v);
return /[",\n\r]/.test(s) ? `"${s.replaceAll('"', '""')}"` : s;
};
const csvLine = (values: unknown[]) => values.map(cell).join(",");
// The service reads one line per row: no newlines inside a field.
const oneLine = (s: string | undefined) => (s ?? "").split(/\s+/).filter(Boolean).join(" ");
// 1. Read the customer file and build the upload: an id and one address per row.
const customers = new Map<string, Record<string, string>>();
const accepted: Row[] = [];
const review: Row[] = [];
const rejected: Row[] = [];
const upload = [csvLine(["id", "address"])];
for (const raw of records(await readFile(process.argv[2], "utf8"))) {
const c = Object.fromEntries(Object.entries(raw).map(([k, v]) => [k, oneLine(v)]));
customers.set(c.id, c);
if (!c.street) {
rejected.push({ id: c.id, reason: "no street given" });
continue;
}
// Only the text after the last comma is context. The postcode is the
// best context there is; the city is second best.
const context = c.postcode || c.city;
upload.push(csvLine([c.id, context ? `${c.street}, ${context}` : c.street]));
}
// 2. Submit. `format` decides how the body is read; the content type does not.
let job: BatchJob = await retryOnRateLimit(() =>
client.batch(upload.join("\n") + "\n", { format: "csv", contentType: "text/csv" }),
);
console.log(`job ${job.id}: ${job.rows} rows at ${job.rps} a second`);
// 3. Wait as long as the job says it needs, checking at most once a minute.
while (!["done", "failed", "cancelled"].includes(job.state)) {
await sleep(Math.min(Math.max(job.remaining_s ?? 5, 5), 60) * 1000);
try {
job = await client.get_batch(job.id);
} catch (e) {
if (e instanceof RateLimited) continue; // the job is spending this key's address rate
throw e;
}
console.log(`${job.done}/${job.rows} rows, ${job.found} found, ~${job.remaining_s} s left`);
}
if (job.state !== "done") throw new Error(`job ${job.state}: ${job.error ?? ""}`);
// 4. Collect every answer, one per input row, and triage it.
const answers = records(await client.batch_results(job.id, { format: "csv" }));
function triage(a: Record<string, string>): ["accept" | "review" | "reject", string] {
if (a.error) return ["reject", a.error]; // "no match"
if (Number(a.tied_at_top) > 1) return ["review", `matches ${a.tied_at_top} places equally well`];
if (!DOOR.has(a.precision)) return ["review", `precision is ${a.precision}`];
if (a.precision === "interpolated" && Number(a.precision_m) > INTERPOLATED_MAX_M) {
return ["review", `interpolated to within ${Number(a.precision_m).toFixed(0)} m`];
}
const confidence = Number(a.confidence);
if (confidence === 0.5) return ["review", "too few answers like this one to calibrate"];
if (confidence < ACCEPT_AT) return ["review", `confidence ${confidence.toFixed(2)}`];
return ["accept", "geocoded"];
}
for (const a of answers) {
const [bucket, why] = triage(a);
if (bucket === "accept") accepted.push({ ...a, note: why });
else if (bucket === "review") review.push({ ...a, reason: why });
else rejected.push({ id: a.id, input: a.q, reason: why });
}
// 5. Re-check the review pile with validation, which compares part by part.
// Paced at the key's address rate, which the job reported.
const interval = job.rps ? 1000 / job.rps : 0;
const still: Row[] = [];
for (const a of review) {
const c = customers.get(String(a.id)) ?? {};
const body: PostValidateBody = {};
if (c.street) body.text = c.street;
if (c.city) body.locality = c.city;
if (c.postcode) body.postcode = c.postcode;
if (c.country) body.country = c.country;
const started = Date.now();
const v = await retryOnRateLimit(() => client.post_validate(body), { attempts: 5 });
await sleep(Math.max(0, interval - (Date.now() - started)));
// A correction within two edits can be a different street; accept it
// only when it is as well calibrated as a first-time accept.
if (v.verdict === "confirmed" || (v.verdict === "corrected" && v.confidence >= ACCEPT_AT)) {
const matched = Object.fromEntries(v.components.map((p) => [p.name, p.matched]));
accepted.push({
id: a.id, q: a.q, formatted: v.formatted, lat: v.lat, lon: v.lon,
precision: v.precision, confidence: v.confidence,
...Object.fromEntries(PARTS.map((p) => [p, matched[p]])),
note: v.verdict,
});
} else if (v.verdict === "corrected" || v.verdict === "partial") {
still.push({ id: a.id, input: a.q, reason: a.reason, suggestion: v.formatted, why: v.why });
} else {
rejected.push({ id: a.id, input: a.q, reason: `validation: ${v.why}` });
}
}
// 6. Write the three files.
async function write(name: string, rows: Row[], fields: string[]) {
const lines = [csvLine(fields), ...rows.map((r) => csvLine(fields.map((f) => r[f])))];
await writeFile(name, lines.join("\n") + "\n", "utf8");
}
await write("accepted.csv", accepted,
["id", "q", "formatted", "lat", "lon", "precision", "confidence", ...PARTS, "note"]);
await write("review.csv", still, ["id", "input", "reason", "suggestion", "why"]);
await write("rejected.csv", rejected, ["id", "input", "reason"]);
console.log(`${accepted.length} accepted, ${still.length} to review, ${rejected.length} rejected`);The decisions in it
Waiting: as long as the job says, and a 429 means "still running"
remaining_s is the rows left divided by the job's rate, rounded up. The loop sleeps for that, but never less than five seconds and never more than a minute, so a long job still reports progress. Polling faster buys nothing: progress is written every 500 rows, so done moves in steps.
A running job takes each token the key's address bucket refills, so a poll with the same key competes with it and can be refused with 429. That refusal is not an error here — the job is spending the rate exactly as it should — so the loop catches RateLimited and keeps waiting. For the same reason, live address traffic on the key slows while a job runs: bulk and interactive requests share one budget (see rate limits).
A poll while the job is still queued
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 20
ratelimit-remaining: 98
ratelimit-reset: 1
{
"created_at": 1795427402,
"done": 0,
"epoch": 1,
"error": null,
"found": 0,
"id": "KNBDU4TD1RrnARXRKn0jodCf",
"owner": "docs-examples",
"parts": 0,
"remaining_s": 5,
"rows": 5,
"rps": 1,
"state": "queued",
"updated_at": 1795427402
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Triage: four fields, in order
| Check | Goes to | Why |
|---|---|---|
error is set | reject | no match: nothing was found to review. |
tied_at_top > 1 | review | The address names several places equally well, and the one in the row was chosen among them by prominence. Asked before confidence, because a tied answer can still carry a high one. |
precision is not rooftop or interpolated | review | A street, an address row without the number, or a place — not a door. |
interpolated with precision_m over 50 | review | Placed between two recorded numbers far apart. The metres are the honest radius. |
confidence exactly 0.5 | review | The calibration's prior for answers too rare to measure: "not known", not "low". |
confidence below 0.7 | review | Calibrated: answers like this landed within 250 m of the true address less than seven times in ten on the hold-out. |
| none of the above | accept |
The thresholds are yours to set. For an address, confidence is the share of answers of the same shape that landed within 250 m of the true address on Mexico City hold-outs: a rooftop match with a postcode reaches about 0.73, and one with only a city is held to 0.45 at most, because a city alone leaves too many candidates. That is why 0.7 here, and why a file with postcodes cleans itself far better than one without. It is an upper bound for field data, not a promise, so check a sample of each bucket by hand and moveACCEPT_AT until the accepted pile is as clean as you need. Seereading a result for every field.
Here is a real answer to a five-row file, and what the triage makes of it:
id,q,name,lat,lon,precision,precision_m,confidence,tied_at_top,formatted,house_number,street,locality,region,postcode,country,source,release,license,error
cust-001,"Avenida Insurgentes Sur 1602, 03940",AVENIDA INSURGENTES SUR 1602,19.364069672979937,-99.18198831998704,rooftop,6.756173533775122,0.72772276,1,"AVENIDA INSURGENTES SUR 1602, Ciudad de México, 03940, MX",1602,AVENIDA INSURGENTES SUR,Ciudad de México,,03940,MX,overture-addresses,2026-08-19.0,"permissive (per-source, see record)",
cust-002,Museo Soumaya,Museo Soumaya,19.44062110346353,-99.2046595360656,poi,6.756173533775122,0.5,1,"Museo Soumaya, Miguel Hidalgo, CMX, MX",,,Miguel Hidalgo,CMX,,MX,overture-places,2026-08-19.0,CDLA-Permissive-2.0,
cust-003,"Paseo de la Reforma 222, Ciudad de México",AVENIDA PASEO DE LA REFORMA 222,19.42905748976803,-99.1621778772732,rooftop,6.756173533775122,0.352459,1,"AVENIDA PASEO DE LA REFORMA 222, Ciudad de México, 06600, MX",222,AVENIDA PASEO DE LA REFORMA,Ciudad de México,,06600,MX,overture-addresses,2026-08-19.0,"permissive (per-source, see record)",
cust-004,"Calle Madero 1, 06000",CALLE TACUBA 1,19.435964227232493,-99.1402969208942,rooftop,6.756173533775122,0.5,1,"CALLE TACUBA 1, Ciudad de México, 06000, MX",1,CALLE TACUBA,Ciudad de México,,06000,MX,overture-addresses,2026-08-19.0,"permissive (per-source, see record)",
cust-005,"Calle Que No Existe 99999, 03940",CALLE HERA,19.365038165737747,-99.17921975464016,street,6.756173533775122,0.5,13,"CALLE HERA, Ciudad de México, 03940, MX",,CALLE HERA,Ciudad de México,,03940,MX,overture-addresses,2026-08-19.0,"permissive (per-source, see record)",A real response, captured from the service at commit b8f4bde-dirty.
cust-001is accepted: rooftop, not tied, with a postcode, confidence 0.73.cust-002,Museo Soumaya, is a place (poi) at the 0.5 prior: review.cust-003is the right door, rooftop and not tied, but with only a city as context its confidence is 0.35: review. Validation finds the street only partly agrees (Paseo de la ReformaagainstAVENIDA PASEO DE LA REFORMA) and leaves it in review with the full address as a suggestion. With the postcode in the file it would have been accepted at the first pass.cust-004asked forCalle Madero 1and gotCALLE TACUBA 1, rooftop, not tied. The precision is true: that position is a door. It is not the door that was asked for, and the 0.5 prior is what sends it to review, where validation compares the streets and rejects it: the street contradicts the match.cust-005, a street that does not exist, is tied 13 ways at street precision: review, and validation rejects it.
Validation: a second opinion on the doubtful rows only
Each review row goes to POST /v1/validate as its parts: the street line as text(the number is found at either end of it), and the city, postcode and country as fields, which win over anything text parses to. The answer is a verdict and a quality for every part:
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"}'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",
},
)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",
});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.
| Verdict | The program |
|---|---|
confirmed | Accepts it, with the validated position and parts. Every part given was exact and the match is an address point. |
corrected | Accepts it only if its confidence also clears 0.7; otherwise review, with the correction as a suggestion. |
partial | Review, with why: the number or the street did not match, or a part contradicts the match. |
unconfirmed | Reject. |
A correction is every part exact or within two edits — and two edits can turn one real street into another: Hermes and Ceres are two edits apart. A correction the calibration cannot vouch for is a suggestion for a person, not a fact to write back. Even this plain misspelling, with the house number and postcode right, comes back at 0.60, so the program files it for review with AVENIDA INSURGENTES SUR 1602 as the suggestion rather than writing it back:
corrected, at 0.60
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 loop is paced at the job's rps — the key's address rate — and wrapped in the retry helper, so a burst of review rows waits rather than failing.
What to watch out for
- One empty address refuses the whole file:
400 row N: no address. Rows without a street go straight torejected.csvbefore the upload is built. - No newlines inside a field. Quoted fields and doubled quotes are read; an embedded newline is not, so the program collapses whitespace. A
nearcolumn oflat,lonmust be quoted. - 64 MiB and 2,000,000 rows per job. Split larger files into several jobs.
- Results before the job is done are a
409carryingdone,rowsandremaining_s. The clients raise it as a plainGeoErrorwith status 409; the program never asks early. - Nothing expires. The input and the results stay until the job is deleted with
DELETE /v1/batch/{id}, which removes both and cannot be undone. The clients leaveDELETEout on purpose; send it with curl once you have your files, if you do not want the addresses kept. - Two layouts of
formatted. The batch's follows the country — the number after the street in Mexico,AVENIDA INSURGENTES SUR 1602— while validation's always leads with it,1602 AVENIDA INSURGENTES SUR. If one layout matters, build it from the part columns, which agree. - The whole answer is one string.
batch_resultsreturns the file as text; for millions of rows, download it with curl to a file and stream it instead.
Endpoints
/v1/batchaddressGeocode a file. A job id comes back at once; the rows are worked through at the rate the key's plan sustains.