Logo

An API to encode and decode coordinates using the Geohash geocode system.

Geohash is a public domain algorithm used to encode geographic locations
into short strings of variable precision, using Z-order curves.

Check out this video for an awesome, intuitive explanation.

API

https://geohash.world/v1/encode/[latitude],[longitude]?pre=[optional_precision]
https://geohash.world/v1/decode/[geohash]


Encoding Example

http://geohash.world/v1/encode/37.983810,23.727539?pre=6

Result

{
  "query": "/v1/encode/37.983810,23.727539?pre=6",
  "lat": 37.98381,
  "lon": 23.727539,
  "precision": 6,
  "geohash": "swbb5f"
}

Decoding Example

http://geohash.world/v1/decode/swbb5f

Result

{
  "inputGeohash": "swbb5f",
  "lat": 37.98248291015625,
  "lon": 23.7249755859375,
  "boundingBox": {
      "LatMin": 37.979736328125,
      "LatMax": 37.9852294921875,
      "LonMin": 23.719482421875,
      "LonMax": 23.73046875
}

Bulk Encoding Example

curl -X POST \
  -H "Content-Type: application/json" \
  -d '[{"lat":23.8,"lon":66.3, "precision":4},
  {"lat":34.9,"lon":77.4, "precision":5}]' \
  http://geohash.world/v1/batchEncode

Result

{
  "query": "[{\"lat\":23.8,\"lon\":66.3, \"precision\":4},\n  {\"lat\":34.9,\"lon\":77.4, \"precision\":5}]",
  "results": [
      {
        "query": "23.800000,66.300000,4",
        "lat": 23.8,
        "lon": 66.3,
        "precision": 4,
        "geohash": "tkpp"
      },
      {
        "query": "34.900000,77.400000,5",
        "lat": 34.9,
        "lon": 77.4,
        "precision": 5,
        "geohash": "twpn9"
      }
  ]
}

Bulk Decoding Example

curl -X POST \
  -H "Content-Type: application/json"   \
  -d '[{"geohash":"bcd1"}, 
  {"geohash":"ddf2"}]' \
  http://geohash.world/v1/batchDecode

Result

{
  "query": "[{\"geohash\":\"bcd1\"},\n  {\"geohash\":\"ddf2\"}]",
  "results": [
      {
        "inputGeohash": "bcd1",
        "lat": 53.701171875,
        "lon": -143.26171875,
        "boundingBox": {
            "LatMin": 53.61328125,
            "LatMax": 53.7890625,
            "LonMin": -143.4375,
            "LonMax": -143.0859375
        }
      },
      {
        "inputGeohash": "ddf2",
        "lat": 15.556640625,
        "lon": -64.16015625,
        "boundingBox": {
            "LatMin": 15.46875,
            "LatMax": 15.64453125,
            "LonMin": -64.3359375,
            "LonMax": -63.984375
        }
      }
  ]
}

About

Check out the about page for more information!


2019 - tpaschalis