Skip to main content

Examples

Ready-to-use code examples for integrating with the geocodeme.net API in your preferred language.

Before You Start​

All examples assume you have:

  1. A valid API key (get one here)
  2. Set the key in an environment variable:
export GEOCODEME_API_KEY="gm_YOUR_KEY"

Forward Geocoding​

Convert an address to coordinates.

curl -H "X-Api-Key: $GEOCODEME_API_KEY" \
"https://api.geocodeme.net/v1/geocode?q=1+rue+de+Rivoli+Paris&limit=1"

Reverse Geocoding​

Convert coordinates to an address.

curl -H "X-Api-Key: $GEOCODEME_API_KEY" \
"https://api.geocodeme.net/v1/reverse?lat=48.8566&lon=2.3522"
Optional Fields

The address field is optional and may be absent depending on the result. Always check for its presence before accessing it; for example, location.get("address") in Python or location.address?.city in JavaScript. Note that /v1/reverse returns a single result object (or null), while /v1/geocode returns a results array.

Language-Specific Pages​

  • JavaScript: using fetch in Node.js or the browser
  • Python: using the requests library
  • PHP: using curl_init() with PHP 7.4+
  • cURL: command-line examples for all endpoints