Skip to main content
The Geographic API provides read-only access to EarthCoop’s location hierarchy. Use it to populate cascading dropdown menus on forms — for example, letting a user select their province, then county, then district, and so on. All geographic endpoints are public and require no authentication. The hierarchy from broadest to most specific is:

GET /api/provinces

Returns all active provinces. Authentication: None Request: No parameters.

Response Fields

array
Array of active province objects.
integer
Province ID.
string
Province name.

Example Request

Example Response


GET /api/counties/

Returns all active counties within the given province. Authentication: None

Path Parameters

integer
required
The province ID whose counties you want to retrieve.

Example Request

Example Response


GET /api/districts/

Returns all active districts within the given county. Authentication: None

Path Parameters

integer
required
The county ID whose districts you want to retrieve.

Example Request

Example Response


GET /api/cities/

Returns all active cities within the given district. Authentication: None

Path Parameters

integer
required
The district ID whose cities you want to retrieve.

Example Request

Example Response


GET /api/villages/

Returns all active villages within the given district. Authentication: None

Path Parameters

integer
required
The district ID whose villages you want to retrieve.

Example Request

Example Response


GET /api/geographic/continents

Returns all continents. This is the entry point for the full hierarchical children traversal described below. Authentication: None Request: No parameters.

Response Fields

array
Flat JSON array (not wrapped in a data key) of continent objects, each with id and name.

Example Request

Example Response

The /api/geographic/continents response is a bare JSON array, not an object with a data key — unlike the /api/provinces family of endpoints.

GET /api/geographic///children

Returns the direct children of a given geographic entity at any level of the hierarchy. This is the recommended endpoint for building cascading location selectors because it covers the full hierarchy in a single consistent shape. Authentication: None

Path Parameters

string
required
The level of the parent entity. Accepted values (case-insensitive):
string
required
The ID of the parent entity. For the section level, city results use the prefixed format city_{id} and rural results use rural_{id} — pass these prefixed strings as parentId when fetching the next level down (e.g. city_30 to get regions of city 30).

Response Fields

array
A flat JSON array of child objects. Each item has at minimum id and name.
For the section (district) level, each city item has a prefixed id and each rural item has a rural_ prefix:

Example Requests

Example Response — province/1/children

Example Response — section/20/children (mixed cities and rurals)

When drilling down from the section level, the id values are prefixed strings (city_30, rural_5), not plain integers. You must pass these prefixed strings as-is in the next parentId segment. Passing a plain integer at the city level will not match.

Building a Cascading Location Selector

Here is the recommended sequence for a complete location picker starting at continent level:
  1. GET /api/geographic/continents — populate the continent dropdown
  2. GET /api/geographic/continent/{continentId}/children — populate countries
  3. GET /api/geographic/country/{countryId}/children — populate provinces
  4. GET /api/geographic/province/{provinceId}/children — populate counties
  5. GET /api/geographic/county/{countyId}/children — populate districts
  6. GET /api/geographic/section/{districtId}/children — populate cities and rurals (note prefixed IDs)
  7. GET /api/geographic/city/{city_N}/children — populate regions within a city
If you only need provincial-level data (common for Iran-specific forms), use the simpler /api/provinces, /api/counties/{id}, /api/districts/{id}, and /api/cities/{id} endpoints instead.