This article talks about 5 free Geocoding APIs.
With the help of these Geocoding APIs, you can easily geocode an address to its geographic coordinates (Latitude & Longitude). Four of these APIs require an API Key to work which you can easily obtain from their respective websites. Whereas, one (DSTK) is designed to work without an API Key.
Each of these APIs has a syntax for geocoding. The syntax involves the API Key along with the address/location you want to geocode. Using a precise location in the syntax gives more accurate results. Here, I will cover the API Key, syntax, response and limitations of these geocoding APIs.
Related: How To Geocode Address To Lat Long in Excel
Here Are 5 Free Geocoding APIs:
Location IQ
LocationIQ provides enterprise-grade location services and operated by Unwired Labs. You can use LocationIQ API to geocode address to coordinates. A token is required to use the LocationIQ API which can be easily obtained from here. When you generate a token, an API key is also provided to you. This key will be needed when you’ll use the LocationIQ API for geocoding.
After obtaining the token and API, you can use the LocationIQ API for geocoding. Here are the syntax for that:
Region 1: US
https://us1.locationiq.org/v1/search.php?key=YOUR_API_KEY&q=SEARCH_STRING&format=xml
Region 2: Europe
https://eu1.locationiq.org/v1/search.php?key=YOUR_API_KEY&q=SEARCH_STRING&format=json
Example:
https://us1.locationiq.org/v1/search.php?key=123abc456def78&q=empire+state+building&format=xml
You can use any of the above-mentioned syntax for geocoding. Just replace the “YOUR_API_KEY” text with your API key and “SEARCH_STRING” text with the address/location. Replace the space with ‘+’ in your address string or use URL encoding accordingly. LocationIQ API supports two formats for the output, XML, and JSON. You can use any of them by mentioning that in the format field of the URL. Below is an example output of the query in XML.
LocationIQ API has usage limitations. As a free user, you can only generate 10,000 requests per day and 60 requests per minutes for non-commercial use. You can extend your limits by purchasing their paid plans which also lets you use the API for commercial purposes.
Google Maps Geocoding API
Google Maps provides a Geocoding API that you can use to geocode address to coordinates. To use this API, you can obtain an API key from here.
After getting the API key, you can use the following syntax for geocoding:
https://maps.googleapis.com/maps/api/geocode/json?address=SEARCH_STRING&key=YOUR_API_KEY
Example:
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=123abc456def78
This syntax will give you the output in JSON. To get the output in XML, simply replace the json with xml in the syntax. The attached screenshot shows the output in JSON format.
You can use Google Maps Geocoding API to generate 2,500 free requests per day with 50 requests per second limit. These requests are calculated as the sum of client-side and server-side queries.
DataScienceToolkit
DataScienceToolkit (DSTK) provides easy to use APIs backed by a collection of open source tools and data-sets. You can use it’s Street Address to Coordinates API to geocode address to lat-long coordinates. The main advantage of this API is that you do not need any sort of token or key to use it.
With the following simple syntax, DSTK made the geocoding address to coordinates very easy:
http://www.datasciencetoolkit.org/street2coordinates/SEARCH_STRING
Example:
http://www.datasciencetoolkit.org/street2coordinates/2543+Graystone+Place+Simi+Valley+CA+93065
DSTK gives the output in JSON format. Here is a screenshot of the output of the above query:
DSTK does not have any sort of limitation. You can generate as many requests as you want. And, DSTK made it really easy to switch to DSTK from Google Maps Geocoding API. All you have to do is change the Google Maps server with DSTK server in the URL. You can read more about that here.
MapQuest Geocoding API
MapQuest provides location-enabled Geospatial solutions for businesses. It provides a Geocoding API to geocode address to lat-long. To use this API, you have to get an API Key first. Follow this link to obtain a MapsQuest API Key.
After getting the API Key, you can geocode address to coordinate using the following syntax:
https://www.mapquestapi.com/geocoding/v1/address?key=API_KEY&inFormat=kvp&outFormat=json&location=SEARCH_STRING&thumbMaps=false
Example:
https://www.mapquestapi.com/geocoding/v1/address?key=123abc456def78&inFormat=kvp&outFormat=json&location=Denver+CO&thumbMaps=false
As you can see in the screenshot attached below, MapQuest gives the output in the JSON format
MapQuest Geocoding API has a monthly limit of 15000 requests. You can only raise that many requests in a month here. You can extend this limit by subscribing to their paid plan.
Bing Maps
Bing Maps also provides API to geocode address to coordinates. To use Bing Maps API for geocoding, first, you need a Bing Maps Key. You can get a Bing Maps Key from Bing Maps Dev Center. Here is a link to that.
After getting the Bing Maps Key, you can use the following syntax to geocode an address to coordinates.
http://dev.virtualearth.net/REST/v1/Locations/SEARCH_STRING?o=xml&key=BING_MAPS_KEY
Note: For best practice, encode the URL before making the request. Encoding replaces spaces with “%20” and replaces other special characters with similar encoded values.
For example:
http:http://dev.virtualearth.net/REST/v1/Locations/1%20Microsoft%20Way%20Redmond%20WA%2098052?o=xml&key=123abc456def78
In the above example, the URL is encoded. As a result, the spaces between the address “1 Microsoft Way Redmond WA 98052” is replaced with “%20”.
Bing Maps Location API uses XML format for the output. A screenshot of the same is attached below.
With Bing Maps Key, you can perform only 2 jobs simultaneously with a limit of total 50 jobs in a 24 hour period. For more information on Bing Maps API and its other uses, you can visit Microsoft Developer Network page here.
Wrap Up:
All these Geocoding APIs are easy to use. The DSTK API is most simple and easy to use as it does not require any key or token and you can generate as many requests as you can. Bing Maps API is least simple due to its limitation and fairly complex process to obtain the key. Give them all a try and lets us know which one you find suitable.