Choose the Right Location Identifier
The business problem
Every AfriHex endpoint asks for "a location," but the platform actually has five distinct kinds of location identifier, and picking the wrong one for the job is the single most common early integration mistake — storing a hex code where you needed a stable per-visit pin, or showing a customer a raw coordinate where they expected something they could read back to you over the phone.
They aren't interchangeable, and they aren't a precision ladder from "rough" to "exact" — each one answers a different question:
| Identifier | Answers | Example |
|---|---|---|
| Coordinate | Where, exactly, right now? | 5.6221843, -0.1729361 |
| Digital address (GhanaPostGPS) | What's the shareable, human-readable address here? | GA-142-7281 |
| AfriHex code | What grid cell is this in, at a given zoom level? | AF-GH-7-0GXTQD5VJZZZZ |
| Landmark | What do people actually call this place? | "Kwame Nkrumah Circle" |
| Structure point | Where's the actual door/gate for this cell? | { lat, lng, label: "main gate" }, tied to a hex code |
:::note No place_id or building_id today
If you're coming from Google Places or Mapbox, you might expect a generic
place_id or a building_id. AfriHex doesn't have either as a standalone,
stable identifier — a landmark is the closest analogue to a place ID (see
Search Informal Landmarks and Local Aliases), and a
building is handled as
footprint-snapping evidence (building_edge precision), not an addressable ID
— see Hex Addressing's five things that aren't the
same. Don't design a schema around a
field that doesn't exist; use the hex code or digital address as your primary
key instead.
:::
What AfriHex returns
| Identifier | Stability | Precision | Source | Resolve it back via |
|---|---|---|---|---|
| Coordinate | Not stable — depends on GPS/device, can drift | A point, as exact as the fix | Device GPS, a geocoder, a field survey | GET /v2/reverse?lat=&lng= |
| Digital address | Stable — assigned once by GhanaPostGPS | ~small block/precinct | GhanaPostGPS's registry | GET /v2/lookup?address= |
| AfriHex code | Stable — deterministic from a coordinate + resolution | A cell, area scales with resolution (see Cell size by resolution) | Pure H3 math, always available in-country | GET /v2/hexcode/{code} |
| Landmark | Semi-stable — can be renamed, merged, or reported wrong | A point (best-known) | AfriHex's landmark database | GET /v2/landmarks/geocode?q= |
| Structure point | Stable once surveyed, tied to one hex | A point, survey-confirmed | Field survey, promoted via POST /v2/admin/structure-points/promote | GET /v2/address/resolve?hex= |
Before you begin
- An API key (see Quickstart).
- Decide what your system of record actually needs to store long-term. A hex code and a digital address are both stable primary keys; a raw coordinate is not — don't key a database row on a coordinate that will never repeat.
- Know which direction you're converting: coordinate → identifiers (forward), or identifier → coordinate (reverse). Every row below has a reverse-geocode counterpart.
Copyable request
The most common conversion — a coordinate to everything else at once:
curl "https://api.afrihex.com/v2/reverse?lat=5.6221843&lng=-0.1729361" \
-H "X-API-Key: $AFRIHEX_API_KEY"
Full example response
{
"success": true,
"data": {
"gps_name": "GL1524944",
"address": "GL1524944",
"region": "Greater Accra",
"district": "La Dade Kotopon",
"area": "Shiashie",
"postcode": "GL152",
"center_latitude": 5.6221843,
"center_longitude": -0.1729361,
"quality_score": 1,
"quality_tier": "high",
"provenance": { "source": "third_party_match", "provider": "ghanapostgps", "confidence": 0.95 }
}
}
Note what's not in this response: no hex code. Reverse geocoding and hex
encoding are separate calls on purpose (see Choosing a resolution before you
encode) — chain in GET /v2/hexcode?lat=…&lng=…&res=7 yourself, exactly as the
Quickstart does.
Field-by-field explanation
| Field | Identifier it belongs to | Notes |
|---|---|---|
gps_name / address | Digital address | The canonical GhanaPostGPS code — use this as your shareable, typeable identifier |
center_latitude / center_longitude | Coordinate | The point AfriHex actually matched, not necessarily where you queried from |
region / district / area / postcode | Digital address | Administrative context, not identifiers themselves — don't use area as a dedup key, it's not unique |
quality_score / quality_tier | — | How complete the record is, not which identifier is "better" — see Understanding confidence and verification |
Error and edge cases
- A coordinate resolves to a cell but no digital address.
GET /v2/hexcodenever fails inside Ghana (see the hex-code contract), butGET /v2/reversecan return404 NOT_FOUNDfor a point GhanaPostGPS hasn't indexed. Treat that as normal — you still have a valid hex code, just no digital address yet. - Two different coordinates produce the same digital address. GhanaPostGPS cells aren't points; a small GPS jitter near a cell edge can also flip which cell you land in — see Behaviour near a cell boundary, which applies to both grid systems.
- A landmark match isn't the coordinate you expected. Landmark names
aren't unique (multiple "Shell" fuel stations exist) — always check
alternate_landmarks/confidence in the geocoder response before trusting a single match; see Routing & Navigation. - A structure point doesn't exist for a hex. Most hex cells have no
surveyed structure point —
GET /v2/address/resolve?hex=…falls back tobuilding_edgeorhex_centroidprecision instead of erroring. Readprecisionbefore you trust the point (see Hex Addressing's precision tiers).
Production checklist
- Store a stable identifier (hex code and/or digital address) as your primary key — never a raw coordinate.
- Decide up front which resolution you'll use for hex codes, and keep it consistent (see Best practices).
- Don't parse structure out of a digital address string client-side (region/district codes can be reassigned) — always read it from the API response fields.
- For anything user-facing ("where is this?"), check
precisionviaGET /v2/address/resolve?hex=…rather than assuming the hex centroid is a real point.
Related endpoints / next guide
- Your First AfriHex Request — the full request lifecycle: auth, calling the API, and handling errors.
- Hex Addressing — the full contract behind AfriHex codes.
- Addresses & Geocoding — every endpoint referenced above.