---
title: "Geohash encoder and decoder with neighbour cells"
method: GET
path: "/v1/geo/geohash"
tags: ["deterministic", "no-api-key", "geo", "geohash"]
---

# Geohash encoder and decoder with neighbour cells

`GET /v1/geo/geohash`

## Request

- Base URL: `https://api.duoleads.com`
- URL: `https://api.duoleads.com/v1/geo/geohash`
- Auth: none declared

Geohash encoder and decoder: encode a WGS-84 latitude and longitude to a geohash at a chosen precision, or decode a geohash back to its bounding box, centre point and error bounds in metres. Encoding also returns the eight neighbouring cells, which is what a caller needs to do proximity search over a geohash-indexed store without a spatial database.

**Output (`data`):** encode: geohash, precision, bbox {min_lat, min_lon, max_lat, max_lon}, center {lat, lon}, error_m {lat, lon}, neighbours {n, ne, e, se, s, sw, w, nw} (each string|null: null where the cell would lie beyond a pole). decode: the same without neighbours, plus cell_width_m, cell_height_m (metres on WGS-84). Neighbour cells that would lie beyond a pole are null; longitude wraps at the antimeridian.

Deterministic: identical input returns identical output, so the response is served with `Cache-Control: private, max-age=31536000, immutable` (the paying client may cache it indefinitely; shared caches must not, because the response is paid).

Price: $0.05 USDC per call (x402, Base). Route contract version 1.0.0. Docs: https://api.duoleads.com/docs#geo-geohash

## Query parameters

- `op` 'encode' | 'decode'
- `lat` number
- `lon` number
- `precision` integer
- `geohash` string

## Response `200`

Paid and settled. `data` is route-specific; a route that judges its input returns 200 with `data.valid: false` for a bad value.

- object
  - `ok` unknown, required
  - `route` '/v1/geo/geohash', required
  - `version` '1.0.0', required
  - `data` object, required: encode: geohash, precision, bbox {min_lat, min_lon, max_lat, max_lon}, center {lat, lon}, error_m {lat, lon}, neighbours {n, ne, e, se, s, sw, w, nw} (each string|null: null where the cell would lie beyond a pole). decode: the same without neighbours, plus cell_width_m, cell_height_m (metres on WGS-84). Neighbour cells that would lie beyond a pole are null; longitude wraps at the antimeridian.
    - `geohash` string, required
    - `precision` integer, required
    - `bbox` object, required
      - `min_lat` number, required
      - `min_lon` number, required
      - `max_lat` number, required
      - `max_lon` number, required
    - `center` object, required
      - `lat` number, required
      - `lon` number, required
    - `error_m` object, required
      - `lat` number, required
      - `lon` number, required
    - `neighbours` object
      - `n` string, nullable, required
      - `ne` string, nullable, required
      - `e` string, nullable, required
      - `se` string, nullable, required
      - `s` string, nullable, required
      - `sw` string, nullable, required
      - `w` string, nullable, required
      - `nw` string, nullable, required
    - `cell_width_m` number
    - `cell_height_m` number
  - `meta` Meta, required
    - `disclaimer` string, required: Legal short disclaimer, identical on every response.
    - `request_id` string, required: ULID.
    - `computed_at` string, date-time, required: RFC 3339 UTC with milliseconds.
    - `price_usd` string, required: Decimal string, "0.05".
    - `deterministic` boolean, required
    - `sources` object[]: Present only on routes that read a vendored dataset: the exact edition that answered.
      - `id` string, required
      - `version` string, required
      - `published` string, required
      - `attribution` string
      - `licence` string

## Other responses

- `400`: MISSING_PARAM, INVALID_PARAM or UNSUPPORTED_VALUE. Not charged: validation runs before the paywall.
- `402`: Payment required. No valid PAYMENT-SIGNATURE was supplied: read the base64 PAYMENT-REQUIRED header (or this body) for the price ($0.05 = 50000 atomic USDC on eip155:8453), sign an EIP-3009 authorization and retry. Also returned when settlement is declined (PAYMENT_FAILED). Nothing is charged on a 402.
- `404`: NOT_FOUND: unknown path. Not charged.
- `405`: METHOD_NOT_ALLOWED: only GET and HEAD are served. Not charged.
- `413`: INPUT_TOO_LARGE: a parameter exceeded its documented maximum length. Not charged.
- `500`: INTERNAL: a server bug. Not charged.

---

[API](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo.md) · [All operations](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo/llms.txt) · [OpenAPI document](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo/revisions/18790d59615e?raw)
