Geocode.xyz API: Geocoding, Reverse Geocoding & Geoparsing

A simple HTTP/HTTPS API that accepts a location (or text containing locations) and returns results as JSON, GeoJSON, XML, JSONP, or CSV. Keep your API key on the server whenever possible.

Quick start (curl)

Replace YOUR_API_KEY. JSON uses json=1. XML/CSV uses geoit=xml or geoit=csv.

CLI
Reverse (lat,lon → nearest address)
Forward (address → lat,lon)
Geoparse (text → many places)
Tip: for long input strings, use the parameterized form with locate (GET or POST) to avoid “file name too long”.

Core request shapes

Two common URL patterns for geocoding, plus scantext for geoparsing.

Reference
1) “Path” style

Forward: address/city/landmark. Reverse: lat,lon.

2) Parameter style (recommended for long strings)
3) Geoparsing
Output: json=1, geojson=1, geoit=xml/geoit=csv, JSONP via callback=fn.

Forward geocoding (address → lat,lon)

Pass an address-like string as the “location”. Use locate= to avoid path-length issues.

Many languages
HTTPie
wget
PowerShell
Bash + jq
Python (requests)
Node.js (fetch)
PHP (cURL)
Perl (HTTP::Tiny)
Ruby (Net::HTTP)
Go (net/http)
R (httr)
Java (HttpClient)
C# (.NET HttpClient)

Reverse geocoding (lat,lon → nearest address)

Pass coordinates as lat,lon in that order.

Examples
curl (JSON)
Python
Node.js
CSV output
If you only want core reverse-geocode components, try strictmode=1. If you want more data like timezone/elevation, try moreinfo=1.

Geoparsing (text → multiple matched places)

Use scantext. POST is recommended for long text.

POST
curl (GeoJSON)
curl (JSON + sentiment)
Python (POST)
Node.js (POST)
Disambiguation tip: if your data is known to be in a region/country, add region=XX (ISO code) to reduce collisions.

Output format cheatsheet

Omit output params and the default is HTML. Otherwise choose one.

Formats
json=1 → JSON geojson=1 → GeoJSON geoit=xml → XML geoit=csv → CSV callback=fn → JSONP
Example: https://geocode.xyz/41.3189957000,2.0746469000?json=1&auth=YOUR_API_KEY

Usage notes (practical)

Production integration patterns you’ll typically want.

Ops
  • Cache results (Redis/memory) to save cost and reduce latency.
  • Rate-limit outbound calls and use retries with exponential backoff on transient failures.
  • Normalize provider output into your own schema so you can swap providers later.
  • Use workers for large batches (queue + concurrency) rather than geocoding inside web requests.

Server-side patterns (proxy, worker, serverless)

Keep keys private; put your app in front of the API.

Architecture
Nginx reverse proxy (hide auth)

Append &auth=YOUR_API_KEY server-side before proxying (don’t do it in browser JS).

Serverless (Cloudflare Worker style)
Batch worker (bash)
Docker “one-off” test