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 ',-46.8374628&pretty=1&key=YOUR-API-KEY'

curl - forward geocoding example

$ curl ',+30165+Hanover,+Germany&pretty=1&key=YOUR-API-KEY'


$ http GET q==-23.5373732,-46.8374628 pretty==1 key==YOUR-API-KEY


$ wget ',-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.