Command line Geocoding Tutorial

Using the OpenCage Geocoding API from the command line

The API is is accessed via an HTTP GET request with a few parameters. There is no need to set any headers or cookies. Note that you will need to URI encode the query for forward geocoding (address to coordinates) requests.

curl - reverse geocoding example

$ curl 'https://api.opencagedata.com/geocode/v1/json?q=-23.5373732,-46.8374628&pretty=1&key=YOUR-API-KEY'

curl - forward geocoding example

$ curl 'https://api.opencagedata.com/geocode/v1/json?q=Philipsbornstra%C3%9Fe+2,+30165+Hanover,+Germany&pretty=1&key=YOUR-API-KEY'

HTTPie

$ http GET https://api.opencagedata.com/geocode/v1/json q==-23.5373732,-46.8374628 pretty==1 key==YOUR-API-KEY

wget

$ wget 'https://api.opencagedata.com/geocode/v1/json?q=-23.5373732,-46.8374628&pretty=1&key=YOUR-API-KEY' -O results.json

Start your free trial

2,500 geocoding API requests per day.

No credit card required.