Geocoding API / Address to lat long api

Geocoding API

Geocoding API (or Forward Geocoding) lets you convert addresses to latitude/longitude programmatically. The API gives you well-formed addresses and their geographical coordinates (long and lat). So you can display them on a map, plan a delivery or estimate the distance between different locations.

For example, when you search "14 Grange Rd., London" with Geocode API, it will take you to "14 Grange Road, London, N6 4DG, United Kingdom" with longitude: -0.1537649, latitude: 51.576525, and offer other helpful information.

Try Geocoding API

Enter an address to search and press the "Geocode" button to convert the address to lat long with API. Then, switch to the "Result JSON" tab to get the result object or view the request URL via the "URL" tab:

You can try out other geocoding options on the Geocoding API Playground >>

Features and capabilities

Forward Geocoding and other Geocode APIs

When looking to work with Geocoding APIs, you might be confused by the differences between forward and reverse geocoding or address autocomplete.

  • Forward Geocoding is the process of converting a street address into geographic coordinates.
  • Reverse Geocoding is finding the street address for a given latitude and longitude.
  • Address Autocomplete helps you fill out your address more quickly by giving address suggestions based on the first few letters of the entered address.

On this page, we'll be exploring Geocoding API and Forward Geocoding. For more details on other Geocode APIs, visit Reverse Geocoding API page and the Address Autocomplete API page.

Free-form and structured addresses

The Geocoding API accepts a free-form address as well as a structured address as inputs. So you can geocode a string address as well as address components. For example, here are URLs for a free-form string and structured address:

A free-form address URL example:

https://api.geoapify.com/v1/geocode/search?text=11%20Rue%20Grenette%2C%2069002%20Lyon%2C%20France&apiKey=YOUR_API_KEY

A structured address URL example:

https://api.geoapify.com/v1/geocode/search?housenumber=11&street=Rue%20Grenette&postcode=69002&city=Lyon&country=France&apiKey=YOUR_API_KEY

International addresses and multilanguage support

The Geocoding API returns international addresses in any language, using several datasets worldwide. We utilize multiple datasets, including OpenStreetMap, OpenAddresses, Who's on First, Geonames, Wikipedia, and more. The custom datasets can be imported on request.

Address search with confidence

The Geocoding API tries to find the most relevant and meticulous results for each request. The Geoapify Address to Lat/Long API can find corresponding addresses for ambiguous formatted address strings, addresses with mistakes, and addresses with insufficient information.

We parse and clean up the user's request to us and perform several rounds of searches with different address strings. Finally, we choose the ones that fit the best.

The API's confidence level and match type parameters help you decide the location's accuracy. The confidence level contains three confidence values that help to validate and verify the address:

  • confidence - the whole address confidence rate
  • confidence_city_level - confidence rate for the city, it tells if the city is correct
  • confidence_street_level - confidence rate for the street it tells if the street is correct

Learn more about Geocode API result objects >>

Filters and bias for an accurate and narrow search

The Geoapify Geocoding API accepts additional parameters that let you set a preferred area for address search or filter places by type or region:

  • Set type to search locations of a specific type: country, state, city, postcode, street, amenity;
  • Set filters to limit the search to countries, view box or by radius;
  • Set biases to add priority to locations.
Search a street near a location example:
https://api.geoapify.com/v1/geocode/search?text=Avenue%20Francois-Besson&bias=proximity:6.137464,46.197757&apiKey=YOUR_API_KEY
Search a city in the country example:
https://api.geoapify.com/v1/geocode/search?text=Paris&filter=countrycode:us&apiKey=YOUR_API_KEY
Search within a bounding box example:
https://api.geoapify.com/v1/geocode/search?text=Disneyland&limit=10&filter=rect:1.860012,48.624200,2.847246,49.1148054&apiKey=YOUR_API_KEY

Why the Geoapify Geocoding API?

Afforrdable for every business requests api to get gps coordinates from address

Affordable and safe

Up to 3000 requests/day (or 90,000 requests/month) as a Free Tier even for commercial projects.

We offer affordable pricing plans and soft limits. So you can choose a pricing plan corresponding to your usage and be sure that the API will continue to provide results even if your use accidentally goes over the plan limits.

International and multilanguage Geocode API

Extensive and smart

We use multiple data sources for address search, which are extended and updated by thousands of addresses daily.

Geoapify Geocode API parses and analyzes addresses to find the most relevant results, even for malformed or misspelled addresses.

Based on Open-data

Permissive

Geoapify Geocoding is based on open data. Therefore, you can safely store and reuse found addresses and locations.

However, consider keeping the required attribution to a data source together with result objects.

Can be used with any programming language

Cross-platform

Our Geocoding API is accessible via an easy-to-use HTTP REST endpoint. So you can use it on any platform and with any programming language.

Geocoding API returns a GeoJSON FeatureCollection object that is both human and machine-readable and well supported by the client-side libraries (Mapbox GL, Leaflet, OpenLayers), SDKs, GIS systems, and other software.

Results can also be returned in JSON or XML formats, with the "format=" parameter.

Quickstart

Step 1. Register and get an API Key

You will require an API Key to use the API:

  • register on MyProject Geoapify page
  • create a new project
  • go to the "API keys" page and get an API key
Step 2. Generate and call HTTP GET API request

The API responds to HTTP Get requests. The typical geocoding request URL looks like:

https://api.geoapify.com/v1/geocode/search?text=Frohmestra%C3%9Fe%2087c%2C%2022459%20Hamburg%2C%20Germany&format=json&apiKey=YOUR_API_KEY

Note that you will need to use the encodeURIComponent() function or similar to generate the correct URL for the street address search.

Visit our documentation page for more information about the API parameters, or visit Geocoding API Playground to generate a URL.

Step 3. Get the API result object

The API returns result in GeoJSON format, which is a standard for representing geographical structures. The format is widely supported by GIS, online geographical tools, and map libraries. Here is an example of the API result object:

    • [] 1 item
      • {} 17 keys
        • {} 4 keys
          • "openstreetmap"
          • "© OpenStreetMap contributors"
          • "Open Database License"
          • "https://www.openstreetmap.org/copyright"
        • "87c"
        • "Frohmestraße"
        • "Schnelsen"
        • "Hamburg"
        • "22459"
        • "Germany"
        • "de"
        • 9.92705845
        • 53.63113345
        • "Frohmestraße 87c, 22459 Hamburg, Germany"
        • "Frohmestraße 87c"
        • "22459 Hamburg, Germany"
        • "building"
        • "building"
        • {} 6 keys
          • 0.42100000000000004
          • 6.554749906709501
          • 1
          • 1
          • 1
          • "full_match"
        • "51fe75b867a7da234059b1941bfbc8d04a40f00102f901c4afc51300000000c00203"
    • {} 2 keys
      • "Frohmestraße 87c, 22459 Hamburg, Germany"
      • {} 6 keys
        • "87c"
        • "frohmestraße"
        • "22459"
        • "hamburg"
        • "germany"
        • "building"

Geocoding API code samples

You can call the API with any programming language that allows sending HTTP requests. The following examples show how to make an API call:

Geocoding JavaScript

JavaScript fetch() function provides a convenient and straightforward mechanism for external APIs and resources. The fetch interface allows parsing a JSON object from the response:

const address = 'Baldersgade 3B, 2200 Copenhagen, Denmark';

fetch(`https://api.geoapify.com/v1/geocode/search?text=${encodeURIComponent(address)}&apiKey=YOUR_API_KEY`)
.then(resp => resp.json())
.then((geocodingResult) => {
	console.log(geocodingResult);
});

FAQ

Geocoding works well with addresses in the United States but doesn't always search correctly for locations in my country. Can you improve that?

Definitely! We always try to parse an address before the search and address formats of many countries are parsed correctly. However, some address formats, especially those that contain additional information, may make some difficulties. Please send us address samples that are not found, so we can improve the geocoding service.

Will the geocoding work if an address contains partially incorrect information? For example, a postcode consisting of the wrong numbers?

We try to search the address using different address components and close to the given postcode or city. Therefore, the geocoder should give correct results if the address is located nearby. Please contact us if you do not get the expected results.

We have high volumes. What can you offer us?

We have pricing plans corresponding to different loads and volumes. Moreover, we can offer unmetered Geocoding API access starting from 700€.

Can I use Free pricing plan for a commercial solution?

Yes, you can. But you have to provide a follow-link to Geoapify on your website. For example,

Powered by Geoapify"
near information about Geocoding service.

Is the geocoding service GDPR-compliant? Where are your servers located?

We are a German company and provide GDPR-compliant services only. Our default API endpoints always use European data centers only. Dedicated endpoints can utilize other server locations, even located in your intranet.

How are batch geocoding requests different from single requests?

The batch geocoding requests are asynchronous. That means you send a request to create a geocoding job and get the job ID. Then check the job status with separate requests, for example, every second. When job status is 200, the results are returned. Check our code samples of batch geocoding requests .

Why are batch geocoding requests cheaper?

Batch geocoding requests utilize free server capacity so allow us to optimize the server load. That enables us to offer a lower price.

Do your terms & conditions allow storing the received result?

Our services are based on Open Data. So we do not restrict you from storing results. However, you have to keep all the attributions to the data source with the stored object or make it visible in some other way when you reuse the data.

What is the rate limit for Geocoding requests?

The rate limit indicates the maximum amount of requests per second. Depending on the pricing plan, we offer up to 30 requests/sec for Geocoding API requests.

World map

Ready to get started?

Get an API key and try Geoapify Geocoding API!