Skip to main content

Quickstart

This guide gets you from zero to your first API call in under five minutes.

1. Get an API key

Sign up for a free-tier key with one request. No password needed — the key is returned once and emailed to you, so keep it safe.

curl -X POST "https://api.afrihex.com/v2/self/signup" \
-H "Content-Type: application/json" \
-d '{
"email": "you@example.com",
"name": "Your App",
"organization": "Your Company"
}'

You'll receive a key in the response, or visit the developer dashboard to create additional keys.

2. Set the key as an environment variable

export AFRIHEX_API_KEY="your-api-key"

3. Make your first request

Every /v2/* endpoint authenticates with the X-API-Key header. Try encoding a coordinate into a hex code (the coordinates below are Kotoka International Airport, Accra):

curl "https://api.afrihex.com/v2/hexcode?lat=5.6037&lng=-0.1870&res=7" \
-H "X-API-Key: $AFRIHEX_API_KEY"
{
"success": true,
"data": {
"code": "AF-GH-7-0GXTQD5RFZZZZ",
"h3_index": "877576970ffffff",
"resolution": 7,
"country": "Ghana",
"country_code": "GH",
"center": { "lat": 5.604078493411575, "lng": -0.19529195005881006 },
"boundary": [
{ "lat": 5.609495946766828, "lng": -0.20575170258746575 },
{ "lat": 5.598573458939036, "lng": -0.20393981349281015 }
],
"area_km2": 3.86
},
"meta": { "request_id": "…", "latency": "2.1ms" }
}

That's it — you've resolved a location to a stable, shareable identifier.

4. Do something useful

Here are three common first integrations, each with a link to its full guide:

Using the TypeScript SDK

If you use Node.js, the official SDK (@afrihex/sdk) is coming soon — see the SDK guide for its full surface. Once published, you'd use it like this:

npm install @afrihex/sdk # available soon
import { AfriHex } from '@afrihex/sdk'

const afrihex = new AfriHex({
apiKey: process.env.AFRIHEX_API_KEY!,
})

const hex = await afrihex.hex.encode(5.6037, -0.1870, 7)
console.log(hex.code) // "AF-GH-7-0GXTQD5RFZZZZ"

See the SDK guide for the full API surface.

Next steps