Postcode area API
The Postcode area API gives the coordinates of all the Baltic states' postcode areas. The user can get the cordinates for single or multiple postcodes, as well as, postcode groups to get the coordinates of the postcode area polygon.
API URL
The request URL should match the following pattern:
https://api.kartes.lv/v3//postal_codes?
The response is given in JSON.
The HTTP GET request method is used.
Query parameters
The request consists of the following GET parameters:
Parameter | Description | Possible values |
---|---|---|
search | Postocode (seperate multiple values by comma) | Mandatory if not groups used Two-letter country code (LV for Latvia, EE for Estonia, LT for Lithuania) and postcode seperated by a hyphen. |
groups | Postcode area group (seperate multiple values by comma) | Mandatory if not search used E.g., "LV-10" |
wgs84 | Use it get coordinates in the WGS-84 projection (EPSG:4326), instead of the default CRS (TM Baltic93 CRS (EPSG:25884)) | |
wkt | Use it to get coordinates as the WKT geometry, instead of the default GeoJSON array. | |
union_mode | Polygon union mode. | 3 types are available:
|
Response parameters
The response comnsists of following parameters:
Parameter | Description |
---|---|
postal_code | Returned postcodes. |
geometry | Postcode area geometry in either GeoJSON or WKT format. |
Error codes
Status code | Description |
---|---|
200 | Wrong union mode. |
200 | Postal code index is missing. |
200 | Too many postal indexes were passed. |
404 | No location found. The URL is not recognized; the resource does not exist. |
5xx | Server error. |
Examples
Example #1
Input:
https://api.kartes.lv/v3//postal_codes?search=LV-1021,LV-1082&wgs84&wkt&union_mode=union
Response:
[
{
"postal_code": [
"LV-1021",
"LV-1082"
],
"geometry": "POLYGON((24.2123111802785 56.953430682896,24.2153246434572 56.952974283183,...))"
}
]
Example #2
Input:
https://api.kartes.lv/v3//postal_codes?search=LV-1021,LV-1082&wgs84&wkt&union_mode=isolate
Response:
[
{
"postal_code": [
"LV-1021"
],
"geometry": "POLYGON((24.2287944060861 56.9599540264562,24.2287074011031 56.9599767747401,24.2270271112969 56.9604160973327,24.2246066418339 56.9583737401,...))"
},
{
"postal_code": [
"LV-1082"
],
"geometry": "MULTIPOLYGON(((24.2145900344104 56.9517267143314,24.2145994285211 56.9518323289897,24.2144417916266 56.9519238258176,...)))"
}
]
Example #3
Input:
https://api.kartes.lv/v3//postal_codes?search=LV-1021,LV-1082&wgs84&wkt&union_mode=collect
Response:
[
{
"postal_code": [
"LV-1021",
"LV-1082"
],
"geometry": "GEOMETRYCOLLECTION(POLYGON((24.2287944060861 56.9599540264562,24.2287074011031 56.9599767747401,24.2270271112969 56.9604160973327,24.2246066418339 56.9583737401,...)))"
}
]
Example #4
Input:
https://api.kartes.lv/v3//postal_codes?search=LV-2167&groups=LV-10&wgs84&wkt&union_mode=union
Response:
[
{
"postal_code": [
"LV-1050",
"LV-2167",
...
"LV-1024"
],
"geometry": "POLYGON((24.0702378727879 56.8792032859641,24.0693149401602 56.8792182722479,24.0674807921115 56.8792676685704,24.0654289714374 56.8747037327839,...))"
}
]