Address API
The address API provides read-only access to the seeded country and administrative-area catalog. The Philippines source JSON is included in this repository under src/seed/address/json and is prepared from isaacdarcilla/philippine-addresses. You do not need to separately download or locate a dataset. The examples use http://localhost:8000 and the Philippines country code PH.
Start with the Philippines catalog
The API and picker need the country and administrative-area rows in PostgreSQL. Configure the repository’s existing database settings, start the Geo Engine, then seed the Philippines address catalog. The seed target runs the migration before inserting the address data.
From the repository root:
make seed_address
Or from the web-app directory:
make seed-address
The picker uses the Philippines (PH) and its top-level region as the initial area. To try the authenticated API examples and live picker, set NODE_ENV=development and create local Postman app credentials from the repository root with make app_seed_dev, or from web-app with make seed-dev-apps. Copy the printed app ID and API key into web-app/.env.local:
GEO_ENGINE_BASE_URL=http://localhost:8000
GEO_ENGINE_APP_ID=postman
GEO_ENGINE_API_KEY=<credential-id>.<secret>
Restart the web app after updating the environment file. The browser calls the same-origin proxy, which sends these credentials to Geo Engine from the server.
Postman setup
Create a Postman environment with these variables:
| Variable | Initial value |
|---|---|
baseUrl |
http://localhost:8000 |
countryCode |
PH |
areaCode |
PH-000001 |
appId |
Your registered app slug |
apiKey |
The credential printed by the app provisioning command |
For each request, add x-app-id: {{appId}} and x-api-key: {{apiKey}}. Use the credential belonging to that app. If Postman has not imported the sample values, replace areaCode with a code returned by the country or browse request.
Endpoints
| Method and path | Purpose |
|---|---|
GET /address/countries |
List countries that have address data. |
GET /address/countries/:countryCode/area-types |
List the area’s keys configured for a country. |
GET /address/countries/:countryCode/areas |
Browse top-level areas, children of a parent, or areas filtered by key and hierarchy. |
GET /address/countries/:countryCode/areas/:code |
Get one area and its ancestors. |
GET /address/countries/:countryCode/autocomplete?q=:query |
Find areas whose names start with the query. |
Country codes are ISO alpha-2 codes. code in API responses is the service-issued area code. Source dataset codes are retained separately.
The Address API default rate limit is 200 requests per consuming app per rolling minute. See the rate-limiting guide for response headers, optional overrides, and deployment limits.
cURL examples
List available countries:
curl --get 'http://localhost:8000/address/countries' \
--header 'x-app-id: postman' \
--header 'x-api-key: <credential-id>.<secret>'
List the administrative keys for the Philippines:
curl --get 'http://localhost:8000/address/countries/PH/area-types' \
--header 'x-app-id: postman' \
--header 'x-api-key: <credential-id>.<secret>'
Browse top-level areas. Pagination defaults to 25 results and offset 0. limit can be from 1 to 100.
curl --get 'http://localhost:8000/address/countries/PH/areas' \
--header 'x-app-id: postman' \
--header 'x-api-key: <credential-id>.<secret>' \
--data-urlencode 'limit=25' \
--data-urlencode 'offset=0'
Browse areas under a parent code returned by an earlier request:
curl --get 'http://localhost:8000/address/countries/PH/areas' \
--header 'x-app-id: postman' \
--header 'x-api-key: <credential-id>.<secret>' \
--data-urlencode 'parentCode=PH-000001' \
--data-urlencode 'limit=25' \
--data-urlencode 'offset=0'
Filter across the country by area key or hierarchy depth. Filters can be combined.
curl --get 'http://localhost:8000/address/countries/PH/areas' \
--header 'x-app-id: postman' \
--header 'x-api-key: <credential-id>.<secret>' \
--data-urlencode 'key=barangay' \
--data-urlencode 'hierarchy=4' \
--data-urlencode 'limit=25' \
--data-urlencode 'offset=0'
Look up one area and its ancestry:
curl --get 'http://localhost:8000/address/countries/PH/areas/PH-000001' \
--header 'x-app-id: postman' \
--header 'x-api-key: <credential-id>.<secret>'
Search area names by case-insensitive prefix. The query must contain 2 to 100 characters. Results default to 10 and the limit can be from 1 to 50.
curl --get 'http://localhost:8000/address/countries/PH/autocomplete' \
--header 'x-app-id: postman' \
--header 'x-api-key: <credential-id>.<secret>' \
--data-urlencode 'q=ad' \
--data-urlencode 'key=barangay' \
--data-urlencode 'limit=10' \
--data-urlencode 'offset=0'
Autocomplete can also be restricted to a parent area with parentCode.
Response examples
Country list:
[
{
"countryCode": "PH",
"country": "Philippines"
}
]
Area-type list:
[
{ "key": "barangay" },
{ "key": "city" },
{ "key": "district" },
{ "key": "province" },
{ "key": "region" }
]
Browse and autocomplete responses include items and nextOffset. Follow nextOffset as the next request’s offset until it is null.
{
"items": [
{
"id": "uuid",
"code": "PH-000001",
"key": "region",
"hierarchy": 1,
"value": "Region I (Ilocos Region)",
"country": "Philippines",
"countryCode": "PH",
"parentCode": null
}
],
"nextOffset": null
}
An area lookup returns the selected area and its ancestors from the root down to its parent:
{
"id": "uuid",
"code": "PH-000001",
"key": "region",
"hierarchy": 1,
"value": "Region I (Ilocos Region)",
"country": "Philippines",
"countryCode": "PH",
"parentCode": null,
"ancestors": []
}
Errors
Missing, duplicate, invalid, expired, or revoked authentication headers return HTTP 401. Invalid query parameters return HTTP 400. An unknown country or area code returns HTTP 404. Error responses include statusCode, message, error, timestamp, and path.