Geocoding & Reverse Geocoding API
The Geocoding API converts between place names and geographic coordinates in both directions. It resolves cities, towns, and US ZIP codes — not street addresses.
Every lookup returns the administrative hierarchy with ISO 3166-2 codes, IANA timezone, population and elevation, and country context such as currency, calling code, languages and EU/EEA membership — plus alternative coordinate formats including Plus Codes and geohash. Premium subscribers additionally receive climate zone, degree of urbanisation and the nearest airport.
Available endpoints:
- /v1/geocoding - Convert a city, state, or US ZIP code to latitude and longitude coordinates
- /v1/reversegeocoding - Convert latitude and longitude coordinates to the nearest city, state, and country
From 2,473 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 194ms | 239ms | 287ms | 671ms | 873ms |
Didn't find what you were looking for? Suggest an improvement
https://api.api-ninjas.com/v1/geocoding
Get current city coordinates by city and country name.
Parameters
At least one of the following parameters must be set:
cityrequiredCity name.
stateoptionalUS state (for United States cities only).
countryoptionalCountry name, 2-letter ISO country code, or 3-letter ISO country code.
zipcodeoptional5-digit zipcode (for United States cities only).
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/geocoding endpoint returns a JSON array of objects, each with the following fields, or an error if the request is unsuccessful.
Core
nameThe name of the matched place.
latitudeLatitude coordinate in WGS 84 decimal degrees.
longitudeLongitude coordinate in WGS 84 decimal degrees.
country2-letter ISO 3166-1 alpha-2 country code.
stateState, province or region of the place.
Place
admin1_nameFirst-level administrative division — state, province or region (e.g.
England).admin1_isoISO 3166-2 code for that division (e.g.
GB-ENG).admin2_nameSecond-level division — county or equivalent.
timezoneIANA timezone name (e.g.
Europe/London).populationPopulation of the matched place.
elevation_mElevation of the matched place in metres.
Country
country_nameFull country name.
iso3ISO 3166-1 alpha-3 country code.
iso_numericISO 3166-1 numeric country code.
capitalCapital city.
continentTwo-letter continent code.
regionUN M49 region name.
subregionUN M49 sub-region name.
currencyISO 4217 currency code.
currency_nameCurrency name.
calling_codeInternational dialling prefix (e.g.
+44).languagesComma-separated BCP-47 language tags.
tldCountry-code top-level domain.
driving_sideleftorright.is_euWhether the country is an EU member state.
is_eeaWhether the country is in the European Economic Area.
Coordinate formats
plus_codeOpen Location Code (Plus Code) for the coordinate.
geohash9-character geohash.
dmsDegrees/minutes/seconds strings for latitude and longitude.
mercatorWeb Mercator (EPSG:3857)
xandyin metres.antipodeThe point diametrically opposite on the globe.
hemisphereNorth/south and east/west indicators.
qibla_degreesBearing to the Kaaba in Mecca, degrees clockwise from true north.
sunSunrise, sunset, solar noon and twilight times for today (UTC).
Environment
climate_zonePremium onlyKöppen-Geiger climate code (e.g.
Cfb).climate_zone_namePremium onlyHuman-readable climate classification.
urbanisationPremium onlyGHSL degree-of-urbanisation class, from
URBAN_CENTREthroughVERY_LOW_DENSITY_RURALtoWATER.urbanisation_namePremium onlyHuman-readable urbanisation class.
is_landPremium onlyWhether the coordinate is on land. Inland water counts as not land.
nearest_airportPremium onlyNearest IATA-coded airport, with distance and bearing.
United States only
countyPremium onlyUS county.
zip_codePremium onlyUS ZIP code of the matched place. See
zip_code_accuracy; this is not a point-in-polygon result.zip_code_accuracyPremium onlyHow
zip_codewas derived:exact,place_centroidornearest.area_codesPremium onlyUS telephone area codes serving the location.
Live Demo
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/geocoding?city=London&country=GB" \
-H "X-Api-Key: YOUR_API_KEY"If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.
https://api.api-ninjas.com/v1/reversegeocoding
Returns a list of cities that contain a given latitude and longitude.
Parameters
latrequiredLatitude coordinate.
lonrequiredLongitude coordinate.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/reversegeocoding endpoint returns a JSON array of location objects, each with the following fields, or an error if the request is unsuccessful.
Core
nameThe name of the nearest matched place.
country2-letter ISO 3166-1 alpha-2 country code.
stateState, province or region.
Place
admin1_nameFirst-level administrative division — state, province or region (e.g.
England).admin1_isoISO 3166-2 code for that division (e.g.
GB-ENG).admin2_nameSecond-level division — county or equivalent.
timezoneIANA timezone name (e.g.
Europe/London).populationPopulation of the matched place.
elevation_mElevation of the matched place in metres.
Country
country_nameFull country name.
iso3ISO 3166-1 alpha-3 country code.
iso_numericISO 3166-1 numeric country code.
capitalCapital city.
continentTwo-letter continent code.
regionUN M49 region name.
subregionUN M49 sub-region name.
currencyISO 4217 currency code.
currency_nameCurrency name.
calling_codeInternational dialling prefix (e.g.
+44).languagesComma-separated BCP-47 language tags.
tldCountry-code top-level domain.
driving_sideleftorright.is_euWhether the country is an EU member state.
is_eeaWhether the country is in the European Economic Area.
Coordinate formats
plus_codeOpen Location Code (Plus Code) for the coordinate.
geohash9-character geohash.
dmsDegrees/minutes/seconds strings for latitude and longitude.
mercatorWeb Mercator (EPSG:3857)
xandyin metres.antipodeThe point diametrically opposite on the globe.
hemisphereNorth/south and east/west indicators.
qibla_degreesBearing to the Kaaba in Mecca, degrees clockwise from true north.
sunSunrise, sunset, solar noon and twilight times for today (UTC).
Environment
climate_zonePremium onlyKöppen-Geiger climate code (e.g.
Cfb).climate_zone_namePremium onlyHuman-readable climate classification.
urbanisationPremium onlyGHSL degree-of-urbanisation class, from
URBAN_CENTREthroughVERY_LOW_DENSITY_RURALtoWATER.urbanisation_namePremium onlyHuman-readable urbanisation class.
is_landPremium onlyWhether the coordinate is on land. Inland water counts as not land.
nearest_airportPremium onlyNearest IATA-coded airport, with distance and bearing.
United States only
countyPremium onlyUS county.
zip_codePremium onlyUS ZIP code of the matched place. See
zip_code_accuracy; this is not a point-in-polygon result.zip_code_accuracyPremium onlyHow
zip_codewas derived:exact,place_centroidornearest.area_codesPremium onlyUS telephone area codes serving the location.
Live Demo
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/reversegeocoding?lat=40.7128&lon=-74.0060" \
-H "X-Api-Key: YOUR_API_KEY"If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.
Frequently Asked Questions
Can I use the Geocoding API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Geocoding API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Geocoding API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Geocoding API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.What are some use cases for the Reverse Geocoding API?
It is ideal for translating raw GPS or devicelat/loncoordinates into human-readable place names for ride-sharing apps, delivery tracking, store locators, and analytics dashboards. For the opposite direction (turning a place name into coordinates), use the Geocoding API.How do I query a location by coordinates?
Send a GET request to the/v1/reversegeocodingendpoint with the requiredlatandlonquery parameters, for example?lat=40.7128&lon=-74.0060. See the pricing page for request limits per plan.What does the Reverse Geocoding API response include?
It returns the nearest place to your coordinates: itsname, administrative regions, country details, timezone, population, elevation and more, all in one response. See the Response section above for the full field list.Can I get coordinates from an IP address or find the time zone for a location?
Every Geocoding and Reverse Geocoding result already includes the location'stimezone. To start from a visitor's IP address instead of coordinates, use the IP Lookup API.How do I disambiguate a city when the same name exists in multiple countries?
Pass thecountryparameter alongsidecity— it accepts a country name, a 2-letter ISO code, or a 3-letter ISO code (for examplecountry=GBfor London). For United States cities you can further narrow results with thestateparameter or a 5-digitzipcode. Browse related location tools in the API catalog.What fields does the Geocoding response include?
Each result includes the placename,latitudeandlongitude, enriched with administrative regions, country details, timezone, population and more. See the Response section above for the full field list; failed requests return an error as described in our error codes documentation.How do I convert coordinates back into a city name?
Use the /v1/reversegeocoding endpoint withlatandlon; it returns the nearest place with the same enriched fields as forward geocoding.Can I get more detail about a city beyond its coordinates?
Yes. Every result is enriched with administrative regions, country details, timezone, population, elevation and more, so you usually don't need a second lookup. See the Response section above for the full field list.
Explore API integration use cases for recommended APIs and workflow examples.