Skip to main content

Batch Geocoding

Problem: I have four million addresses. Nothing is waiting for the result.
Deduplicate first. Four million rows containing nine hundred thousand distinct addresses bills for four million.This is one SELECT DISTINCT on a normalized column, it is free, and it is skipped constantly.

Prerequisites

  • A HERE API key with Batch entitlement
  • export HERE_API_KEY="..."
Batch API v7 is at batch.search.hereapi.com/v7/batch/jobs. It is driven by a serviceHrn parameter that selects which service processes the job.If you are reading a tutorial using batch.geocoder.ls.hereapi.com/6.2/jobs with action=run and outcols=, that is the legacy Batch Geocoder API 6.2. Different host, different parameters, different response format (XML). Prefer v7 for new work.

The code

Response walkthrough

Submission:
status progresses submittedqueuedrunningsuccess | failed | cancelled. billingTags let you attribute cost per tenant or per customer. Set them if you run a multi-tenant platform. You cannot price a feature whose cost you cannot attribute.

The three status codes that are not errors

Code that treats any non-200 as failure will log a perfectly successful job as broken, every night, until someone reads the specification.

Idempotency

The pipeline must survive a worker restart without resubmitting. chunk created → Pending POST /jobs → Submitted ← persist job_id HERE, before polling │ ├─ crash → resume: job_id exists, DO NOT resubmit ▼ GET /jobs/ → Running (poll with backoff) ▼ Succeeded → fetch errors → fetch results → DELETE Persist the chunk-to-job mapping. On resume, retrieve results for jobs already submitted; submit only chunks with no job. Make chunking deterministic. Stable ordering plus fixed size means a restarted process reconstructs the same chunks. A random shuffle does not.

Common mistakes

Not deduplicating. Paying for repetition. Not normalizing before deduplicating. Catches only exact string matches. Treating this as a bulk endpoint. It is a job lifecycle. Losing the job ID on restart. Full rebill. Retrying 204. Zero errors. Aggressively retrying 404. The job has not finished. Hammering after 429. Concurrency limit. Queue. Assuming all-or-nothing. Read /errors. Handle partial success. Never deleting jobs. They accumulate. Loading four million results into memory. Stream. Not writing results into a durable cache. You will do this again next quarter, and pay again. Onboarding jobs starving nightly enrichment. Batch concurrency is per-contract.

Production considerations

Order of operations, before any API call:
  1. Normalize (trim, case-fold, expand abbreviations)
  2. Deduplicate
  3. WHERE geocoded_at IS NULL
  4. Count what remains — and report that number before you report a timeline
The remaining count is usually a fifth of what you were handed. It changes the conversation with whoever asked.
Persist the job ID before the first poll. Poll with exponential backoff. A forty-minute job does not need checking every two seconds. Queue against the concurrency limit. Read Batch API limits and performance before designing the pipeline; the limits determine your parallelism, not the reverse. Use gzip on large inputs. Supported, and it materially reduces upload time. Handle partial success. Successes merge into the cache; failures go to an exception queue with an owner. Persist the confidence score. A record that “succeeded” with a city-centroid fallback is a different outcome from a rooftop match. Webhooks exist in beta. If your pipeline’s correctness depends on a webhook arriving, build the polling fallback anyway. Write results into a durable cache. The point of batch geocoding is that you never geocode that address again.

Batch Geocoding

The lifecycle, the limits, and the status codes in detail.

High-Volume Geocoding

Queues, retries, monitoring, and what to alert on.

Caching Geocoding Results

Where the output of this pipeline must land.

Geocode an Address

The real-time path, for the trickle of new addresses.

HERE documentation


Need production HERE API keys or implementation support? Placematic is an official HERE Technologies reseller and implementation partner. Talk to us.