Skip to main content

Examples

Copy an example. Understand it in five minutes. Adapt it to production. Every code block here calls a verified official HERE endpoint with parameters checked against HERE’s current specification. Where we could not verify something, we omitted the example rather than inventing it.

How to use this section

These pages explain the code, not the concept. Why truck routing needs explicit dimensions belongs in Truck Routing. How to send the request belongs here. Parameter reference belongs to HERE. We link to it. We do not reproduce it, because it changes and a stale copy is worse than no copy. Nothing here is a starter template. Every example includes timeouts, error handling that distinguishes 403 from 429, and the validation that prevents a route no vehicle can drive. Toy code that omits these teaches the wrong lesson at the moment someone copies it.
Two things every example assumes, and you should verify before running any of them:Entitlement. A key valid for geocoding may return 403 on tour planning. That is a licensing boundary, not a bug. See Getting a HERE API Key.Units. HERE’s height is centimetres. grossWeight is kilograms. Pass 4.1 for a 4.1-metre vehicle and you have declared a four-centimetre truck. It will route under every bridge in North America and return 200.

Setup

Every example reads the key from the environment. Never hardcode it, never put it in a query string in production code — URLs are logged by proxies, load balancers, and CDNs.
HERE’s REST APIs accept the API key as an apiKey query parameter, and most also accept an OAuth 2.0 Bearer token. The examples use apiKey because it is what HERE’s own specification documents for these endpoints.For production, consider proxying through your own backend so the key is never exposed and you can enforce per-tenant quota. See Multi-Tenant Location Platform.

Error handling, once

Every example handles these the same way. We will not repeat the explanation on each page.
200 with "routes": [] and a notice containing routeCalculationFailed is a valid HERE response. Checking resp.ok swallows it.For truck and hazmat routing, “no legal route” is a real and correct outcome. A system that retries with relaxed constraints has just produced an illegal route.
Retrying 403 is patient, well-engineered, and permanently futile. It generates support tickets.

The examples

Geocode an address

Address → coordinates, with confidence scoring and the access point.

Reverse geocode

Coordinates → address. Single and batch, with the telematics pattern.

Autocomplete an address

Debounced type-ahead. The one that bills per keystroke if you get it wrong.

Search nearby POIs

/discover vs /browse — relevance ranking vs distance ranking.

Calculate a car route

The baseline. departureTime, return fields, and empty-routes handling.

Calculate a truck route

Constraints, units, and CI assertions against trap geometry.

Distance matrix

Async job lifecycle, and the flat array that transposes silently.

Batch geocoding

The job API. 204 is not an error.
More examples follow: EV routing, isolines, route matching, tour planning, traffic, map rendering, and two end-to-end recipes.

Guides

What the APIs do and when to use them.

Architecture

Cost, caching, and the decisions that matter more than the API call.

HERE documentation


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