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.

  • client_key: Your authorisation key.

Query parameters

The request consists of the following GET parameters:

Parameter Description Possible values
search Postocode (seperate multiple values by comma) 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) 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:
  • isolate – each postcode area as a seperate object;
  • collect – all the postcode areas as a single object with a boundary between them;
  • union – all the queried postcode areas as a single object (no boundaries).

Response parameters

The response comnsists of following parameters:

Parameter Description
postal_code Returned postcodes.
geometry Postcode area geometry in either GeoJSON or WKT format.

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.211844076502 56.952328567687,24.2123111802785 56.953430682896,24.2112963433119 56.9545393542733, ...))"
  }
]

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.2469032114264 56.9567117634134,24.2456201489549 56.9568547474788,24.2415196809799 56.95731160475...))"
  },
  {
    "postal_code": [
      "LV-1082"
    ],
    "geometry": "POLYGON((24.211844076502 56.952328567687,24.2111411574187 56.9524309166326,24.210763974086 ...))"
  }
]

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": "MULTIPOLYGON(((24.2469032114264 56.9567117634134,24.2456201489549 56.9568547474788,24.2415196809799 56.95731160475,24.2414736991561 56.9573167270148,24.2387033682795 56.9576253024501 ...)))"
  }
]

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-2167",
      "LV-1009",
      "LV-1050",
      ...
      "LV-1053"
    ],
    "geometry": "POLYGON((24.0702378727879 56.8792032859641,24.0693149401602 56.8792182722479,24.0674807921115 56.8792676685704 ... ))"
  }
]