{"uid":"cap_dw31EnkLLdmVtIKNTB4mt","slug":"duo-data-utilities-geohash-encode-decode-7197e4f7","name":"Duo Data Utilities – Geohash Encode/Decode","description":"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.","url":"https://api.duoleads.com/v1/geo/geohash?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":[],"properties":{"op":{"enum":["encode","decode"],"type":"string","default":"encode","maxLength":64,"description":"encode (default): lat/lon to geohash. decode: geohash to bounding box."},"lat":{"type":"string","pattern":"^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$","maxLength":64,"description":"WGS-84 latitude, -90 to 90. Required when op=encode."},"lon":{"type":"string","pattern":"^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$","maxLength":64,"description":"WGS-84 longitude, -180 to 180. Required when op=encode."},"geohash":{"type":"string","pattern":"^[0-9bcdefghjkmnpqrstuvwxyz]{1,12}$","maxLength":64,"description":"Geohash to decode, 1-12 characters. Required when op=decode."},"precision":{"type":"string","default":"9","pattern":"^[+-]?\\d+$","maxLength":64,"description":"Geohash length 1-12, default 9 (about 4.8 m)."}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","required":["ok","route","version","data","meta"],"properties":{"ok":{"const":true},"data":{"type":"object","required":["geohash","precision","bbox","center","error_m"],"properties":{"bbox":{"type":"object","required":["min_lat","min_lon","max_lat","max_lon"],"properties":{"max_lat":{"type":"number"},"max_lon":{"type":"number"},"min_lat":{"type":"number"},"min_lon":{"type":"number"}}},"center":{"type":"object","required":["lat","lon"],"properties":{"lat":{"type":"number"},"lon":{"type":"number"}}},"error_m":{"type":"object","required":["lat","lon"],"properties":{"lat":{"type":"number"},"lon":{"type":"number"}}},"geohash":{"type":"string"},"precision":{"type":"integer"},"neighbours":{"type":"object","required":["n","ne","e","se","s","sw","w","nw"],"properties":{"e":{"type":["string","null"]},"n":{"type":["string","null"]},"s":{"type":["string","null"]},"w":{"type":["string","null"]},"ne":{"type":["string","null"]},"nw":{"type":["string","null"]},"se":{"type":["string","null"]},"sw":{"type":["string","null"]}}},"cell_width_m":{"type":"number"},"cell_height_m":{"type":"number"}}},"meta":{"type":"object","required":["request_id","computed_at","price_usd","deterministic","disclaimer"],"properties":{"sources":{"type":"array","items":{"type":"object","required":["id","version","published"]}},"price_usd":{"type":"string"},"disclaimer":{"type":"string"},"request_id":{"type":"string"},"computed_at":{"type":"string","description":"RFC 3339 UTC with milliseconds"},"deterministic":{"type":"boolean"}}},"route":{"const":"/v1/geo/geohash"},"version":{"type":"string"}}}}}}},"responseSchema":{"type":"json","example":{"ok":true,"data":{"bbox":{"max_lat":52.37281322479248,"max_lon":4.893636703491211,"min_lat":52.37277030944824,"min_lon":4.893593788146973},"center":{"lat":52.37279176712036,"lon":4.893615245819092},"error_m":{"lat":2.39,"lon":1.46},"geohash":"u173zq5mt","precision":9,"neighbours":{"e":"u173zq5mw","n":"u173zq5mv","s":"u173zq5mm","w":"u173zq5ms","ne":"u173zq5my","nw":"u173zq5mu","se":"u173zq5mq","sw":"u173zq5mk"}},"meta":{"price_usd":"0.05","disclaimer":"Factual output of a deterministic computation over public data. Provided as is, with no warranty of accuracy, completeness or availability. Not investment, financial, legal, tax, medical or any other professional advice, and not a recommendation. Verify before relying on it. Terms: https://api.duoleads.com/terms","request_id":"01K6B7Q4ZC8H3F2M9WXR5TYN0D","computed_at":"2026-09-28T12:00:00.000Z","deterministic":true},"route":"/v1/geo/geohash","version":"1.0.0"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.05","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_985N8y2bwcp-J_aAapf4i","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Encodes WGS-84 lat/lon to a geohash string (with neighbours) or decodes a geohash to its bounding box, centre point, and error bounds in metres","exampleAgentPrompt":"Encode latitude 52.37279 and longitude 4.89362 to a geohash at precision 9, and give me the 8 neighbouring cells so I can do a proximity search against my geohash-indexed store.","exampleUseCases":[{"title":"Proximity search without spatial database","prompt":"I have a store of POIs indexed by geohash. Convert latitude 40.7484 and longitude -73.9967 to a precision-7 geohash and give me all 8 neighbouring cells so I can query the surrounding tiles."},{"title":"Decoding a stored geohash to coordinates","prompt":"I've got the geohash 'u173zq5mt' stored in my database — decode it and tell me the centre lat/lon, bounding box corners, and how many metres of error to expect."},{"title":"Building a geofence at coarse granularity","prompt":"Encode coordinates 35.6895 latitude and 139.6917 longitude as a geohash at precision 5 so I can cluster nearby locations into neighbourhood-level buckets."}],"resultDescription":"For encode: the geohash string at the requested precision, plus an object with the 8 cardinal and diagonal neighbour geohash strings. For decode: the bounding box (min/max lat and lon), the centre lat/lon, precision length, and positional error in metres for both axes. All responses include a request ID, timestamp, determinism flag, and price metadata.","failureModes":["Missing required lat/lon when op=encode returns a validation error","Missing geohash parameter when op=decode returns a validation error","Latitude out of -90 to 90 range causes a bad-request error","Longitude out of -180 to 180 range causes a bad-request error","Precision outside 1-12 range causes a validation error","Geohash containing invalid characters (not in base-32 alphabet) returns a pattern-mismatch error","Payment failure (x402) if USDC funds are insufficient or wallet is not configured"],"whenToPreferThis":"Choose this endpoint when you need deterministic, serverless geohash encoding or decoding without standing up a spatial database or importing a geohash library. It is especially useful when you need the 8 neighbours of a cell in the same call, which is the standard pattern for radius queries over geohash-indexed data. Prefer it over full spatial databases when the only operation needed is index-key computation at a known precision.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-02T00:45:47.598Z","isFirstParty":false,"canonicalSlug":"duo-data-utilities-geohash-encode-decode-7197e4f7"}