Geocode an Address
Problem: I have an address string. I need coordinates, and I need to know whether to trust them.Prerequisites
- A HERE API key with Geocoding & Search entitlement
export HERE_API_KEY="..."
Geocoding & Search v7 uses per-endpoint hosts. Forward geocoding is
geocode.search.hereapi.com, not a shared base URL. This surprises teams building a single HTTP client.The code
Response walkthrough
Abbreviated. Full schema: HERE geocode documentation.position vs access. position is the address. access is the point on the road network where a vehicle arrives. Route to access. Routing to position may target the geometric centre of a building, or a point separated from the road by a car park.
houseNumberType. PA is a surveyed point address. interpolated means the position was estimated along a street segment and may be tens of metres off. For last-mile delivery that is the neighbour’s door.
queryScore. Overall match quality, 0–1.
fieldScore. Which component was uncertain. queryScore: 0.95 with fieldScore.houseNumber: 0.4 matched the street confidently and the house number badly. That is a different operational risk from fieldScore.postalCode: 0.8.
Common mistakes
Sendingq and qq together. HERE’s own guidance notes this produces inconsistent queryScore. Pick one.
Using /geocode for place search. “Find restaurants near me” is /discover.
Routing to position instead of access.
Discarding fieldScore. The most damaging thing you can do with a geocoding result.
Porting a confidence threshold from another platform. queryScore: 0.9 does not mean what Google’s partial_match: false means. Recalibrate against your own ground truth.
Treating an empty items array as an error. No match is a valid outcome. Route it to an exception queue.
Not normalizing before the call. 123 Main St and 123 Main Street are the same address and two cache misses.
Production considerations
Cache permanently. Buildings are stationary. Key on the normalized address. Store coordinates,access, queryScore, fieldScore, houseNumberType, and geocoded_at.
This is the single largest cost lever available. See Caching Geocoding Results.
Do not use a TTL. A thirty-day expiry invalidates a stable rooftop match for a building that has stood since 1904, and does nothing about the subdivision that opened yesterday. Invalidate on map release, low confidence, correction, or failed delivery.
Threshold and queue. Results below your calibrated confidence go to a human, not to the database.
Batch anything latency-tolerant. If the result is written to a database rather than rendered to a screen, use Batch Geocoding.
Check your contract’s storage terms. Retention of geocoded coordinates is a contract term, not an engineering decision.
Related
Geocoding and Search
Endpoint selection, autocomplete vs autosuggest, confidence scores.
Caching Geocoding Results
Normalization, invalidation, and the privacy question.
Address Validation
Why a geocoder and a validation service answer different questions.
Batch Geocoding
Four million addresses, once.
HERE documentation
Need production HERE API keys or implementation support? Placematic is an official HERE Technologies reseller and implementation partner. Talk to us.