Geolocation Utilities

Geohash Encode

Converts latitude/longitude coordinates into compact geohash strings for spatial indexing and proximity searches. Access via MCP in Cursor or Windsurf, or REST at `/v1/geo/geohash-encode`. Pass lat/lng coordinates and optional precision level to get a base32-encoded string like "9q8yyk8yuzvz". Higher precision values create longer, more accurate geohashes perfect for location-based applications.

API Endpoint

GET /v1/geo/geohash-encode

Code Examples

curl "https://tinyfn.io/v1/geo/geohash-encode" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/geo/geohash-encode', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/geo/geohash-encode',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's geolocation tools:

{
  "mcpServers": {
    "tinyfn-geo": {
      "url": "https://tinyfn.io/mcp/geo",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

What is a geohash and why use it over regular coordinates?

A geohash is a base32-encoded string that represents a geographic area as a hierarchical spatial index. Strings with common prefixes are geographically close, making proximity searches and spatial clustering much faster than coordinate comparisons.

How do I encode coordinates to geohash using MCP in Cursor?

Use the geohash-encode tool with latitude, longitude, and optional precision parameters. For example, encoding (37.7749, -122.4194) with precision 12 returns a geohash string you can use for spatial queries.

What precision level should I use for geohash encoding?

Higher precision creates longer, more accurate geohashes. Use 5-7 for city-level accuracy, 8-10 for neighborhood-level, and 11-12 for building-level precision. Each additional character roughly halves the geographic area.

Can I use geohashes for finding nearby locations efficiently?

Yes, geohashes with shared prefixes are geographically close. You can find nearby locations by truncating the geohash to reduce precision, then searching for all geohashes with that prefix.

What's the maximum precision and coordinate range for geohash encoding?

Geohashes support up to 12 characters of precision and handle the full coordinate range: latitude -90 to 90, longitude -180 to 180. Maximum precision gives roughly 3.7cm × 1.9cm accuracy.

Try Geohash Encode Now

Get your free API key and start using Geohash Encode in seconds.

Get Free API Key