Boundaries API: Countries and Cities Polygon Data
The API provides extensive polygon data for countries, states, counties and cities, covering administrative, political, postal code, and other boundaries. Ideal for developers and data analysts, this API supports precise geographic data needs, enabling detailed analysis and application development.
Explore lower-level subdivisions using our interactive Playground, or get an API key to start integrating today! With our Freemium pricing model, you can begin for free and upgrade as your needs grow. Start now and unlock detailed geographic insights!
Features And Options
Discover the extensive features and options available with the Boundaries API. Explore various endpoints and parameters to access detailed geographic and polygons data tailored to your specific needs. Unlock the full potential of our API for precise administrative, political, and postal code boundaries.
Part Of - Boundaries and Polygons the Location Belongs To
The API endpoint allows you to query all the boundaries associated with a specified location. For instance, retrieve the county, state, and country for a given city or set of coordinates.
Boundary Types
The API supports multiple boundary types, including administrative, political, postal code, low emission zones, and other boundaries, presented as polygons.
Precise Country and City Polygon Data
Optimize response size by selecting the desired accuracy of returned geometry. Additionally, query boundary details to obtain original geometry, population data, and more with the Place Details API.
GeoJSON Output
The API returns results as GeoJSON objects - Polygons and MultiPolygons, which can be natively visualized using client map libraries such as MapLibre GL, Leaflet, and OpenLayers.
Contact us if the functionality required for your business case is missing from the current APIs! We are happy to discuss and extend the API to meet your needs.
Getting Started
Works via HTTP and returns a GeoJSON Polygon or MultiPolygon object. Follow these simple steps to begin using the Boundaries API:
Step 1. Register and Get an API Key
To use the API, you need an API key. Register on MyProject Geoapify to obtain your key.
Step 2. Generate and Call an HTTP GET Request
Create an HTTP GET request with the required input data and make the call. Use our Playground and Documentation to learn about the Boundaries API request/response structure.
The API works via HTTP and returns a GeoJSON object. You can call the Boundaries API using latitude and longitude coordinates or a place ID parameter returned by the Geocoding API or Places API.
Here is an example of a "consists of" API request:
- JavaScript
- Angular
- Node.js-fetch
- cURL
fetch("https://api.geoapify.com/v1/boundaries/consists-of?id=51ecbccfa440182740598d7dd2e49a134840f00101f901dcf3000000000000&geometry=geometry_1000&apiKey=YOUR_API_KEY")
.then(resp => resp.json())
.then((boundariesGeoJSON) => {
console.log(boundariesGeoJSON);
});
FAQ
How to Get Country, State, and City Polygons with the API?
The Boundaries API provides detailed polygon data for countries, states, and cities. It allows you to retrieve precise geographic boundaries for various administrative levels.
What types of boundaries can I retrieve with these APIs?
These APIs support multiple boundary types, including administrative, political, postal code, and other boundaries for countries, states, and cities.
Can I store boundaries I received?
Yes, we allow storing data on your side. But please do not forget about the required OpenStreetMap attribution.
By default, the attribution is provided as a part of the result object.
If you are on a Free plan, please also provide a "follow" link on your website to attribute Geoapify as data provider:
Powered by Geoapify
.
How much does the Boundaries API cost? Which volumes are included to the Free plan?
The API is counted as a "geocoding & places" request. Depending on geometry type and the number of results 1 API call can be counted as multiple requests. You can find more details in the Boundaries API documentation. The Free plan includes 100.000 requests.
The API does not provide Postcode boundaries for my country. Can you add them?
As Postcodes(ZIP-codes) are not boundaries in nature, they are not present as boundaries for some countries. However, we have the postcode data. Contact us and we will find a solution for your business case!
Which data source do you use for the Boundaries API?
The OpenStreetMap database is the main source for the API. We enrich the data with other Open data sources when it's required.
How can I get original geometry for a boundary?
The Boundaries API provides simplified geometry for the boundaries to optimize response time and size. You can get original geometry for a boundary with the Place Details API by requesting the "details.full_geometry" feature.