Retrieve All Geographies and Related Attribute Values
Get all areas of a map with their postcodes and their attribute values, for example to sync your sales areas into another system. The steps below work on two levels: per area (container) and per geography (polygon).
Before you start
You need an API key with access to Geposit Atlas. If you don't have one, contact us at [email protected]. How to send the key and other basics: ATLAS API Support. You also need the Map ID.
Area level
1. Get the postcodes of every area
curl 'https://app-api.geposit.se/v2.0/container/postcodes?map_id={map_id}' \
--header 'x-api-key: {API_KEY}'[
{
"container_id": "CONTAINER_ID_1",
"name": "Arvidsjaur",
"postcodes": [
{ "country_code": "se", "postcode": "93327", "locality": "Arvidsjaur" },
{ "country_code": "se", "postcode": "93391", "locality": "Arvidsjaur" }
]
},
{
"container_id": "CONTAINER_ID_2",
"name": "West",
"postcodes": [
{ "country_code": "se", "postcode": "41116", "locality": "Göteborg" }
]
}
]- Areas without postcodes (for example areas built from municipalities) are left out. If no area has postcodes, the response is
null. - Add
include_adm=trueto include administrative postcodes as well.
2. Get the attribute values of the areas
Post the container IDs from step 1 (reference):
curl https://app-api.geposit.se/v2.0/attribute/map/{map_id}/object-type/container/get \
--header 'x-api-key: {API_KEY}' \
--header 'content-type: application/json' \
--data '["{container_id_1}", "{container_id_2}"]'[
{
"attribute_id": "ATTRIBUTE_ID_1",
"type": "numeric",
"name": "Revenue",
"object_id": "CONTAINER_ID_1",
"object_type": "container",
"value": 12345,
"object_value_inherited": false,
"updated_at": "2024-04-04T05:09:27.24938Z",
"feature_id": null
},
{
"attribute_id": "ATTRIBUTE_ID_2",
"type": "string",
"name": "Sales rep",
"object_id": "CONTAINER_ID_1",
"object_type": "container",
"value": null,
"object_value_inherited": true,
"updated_at": "2024-04-04T05:09:27.254423Z",
"feature_id": null
}
]There is one row per attribute per area, also for attributes without a value:
valueis the area's value, ornullwhen the area has none.object_value_inherited: truemeans the values are set on the area's geographies instead, which can differ from each other. Read them at the geography level below.
The response already has each attribute's name and type. If you also need its default_value or position, read the map's attribute list: polygon_attribute_id in the map, then its items.
Geography level
1. Get the geographies of every area
curl 'https://app-api.geposit.se/v2.0/layer/map/{map_id}/area?with_geo_names=true' \
--header 'x-api-key: {API_KEY}'Each area in layers[].container[] lists its geographies in geo_ids_ref_groups[].geo_ids[], with polygon_id, feature_id, geo_name and geo_code. See Layer ID for the response shape. You can also use POST /v2.0/container/all?with_geo_names=true with {"map_id": "{map_id}"}, which returns the same areas as one list (see Container ID).
2. Get the attribute values of the geographies
Post the polygon IDs from step 1:
curl https://app-api.geposit.se/v2.0/attribute/map/{map_id}/object-type/polygon/get \
--header 'x-api-key: {API_KEY}' \
--header 'content-type: application/json' \
--data '["{polygon_id_1}", "{polygon_id_2}"]'[
{
"attribute_id": "ATTRIBUTE_ID_2",
"type": "string",
"name": "Sales rep",
"object_id": "POLYGON_ID_1",
"object_type": "polygon",
"value": "Anna",
"object_value_inherited": false,
"updated_at": "2024-04-04T04:31:21.053279Z",
"feature_id": "FEATURE_ID_1"
}
]The rows have the same fields as at the area level. feature_id connects the value to the geography's reference data (see Feature ID); object_value_inherited: true means the value comes from the area.
Updated 15 days ago