This documentation for the GIA API is meant to give you, as a GIA user, a guiding hand into how to use the API against different providers of data that we support. In the first release (1.0) we have made Lantmäteriet available in the API. So this guide will mainly focus on how to get data from Lantmäteriet and other providers added in a later stage will be documented in this guide as well when available.
The API is built to be easy to setup and use.
Types of data
There is several types of data that you can get from Lantmäteriet in this first release (1.0). All of them are listed below with a short description.
MapLayers - Call this to get an up to date list of the different map layers available in the API. They are later used in calls to get MapData.
MapData - Use this to get different kinds of map data, meaning roads, lakes and other types of map data.
Properties - This is the call to get all properties available in the selected area.
Buildings - Use this to get all the buildings in the selected area.
Heights - This call is used to get all the heights in the selected area. They are provided in a 2x2m grid. So be careful with the size of the area you request heights from.
Basics and Authentication
The API is built around a single endpoint and it is sent as a POST-request in the REST-standard. In the body of the request you can define all the different settings you want applied to your request. The API will then process this and respond with a message with the GeoJSON-standard which is built on the normal JSON-standard but geared towards GEO-applications.
More about GeoJSON can be found here. (This guide will not explain how GeoJSON works in detail).
A basic body that can be sent to the API looks like this:
There is two different parts to this body. First there is the Provider, this is where you define what source you want to get the data from. Lantmäteriets providername is LM in the API. The second part is 'Properties', its in this JSON-object that you can set provider specific settings for the request. The example above has all the settings available for LM as a provider. These settings are different for each Provider, but as LM is the only provider right now we will focus on these settings.
Below is a short description of each setting for LM:
DataType: DataType is where you enter the datatype that you want to query. They are the ones listed in the "Types of data"-section above.
Area: This is where you define from what area you want to get data. It is sent with coordinates in SWEREF99-format and needs to be as a polygon. That means it needs to start and end on the same point and be at least 4 points.
MapLayer: This is only used in MapData queries and is the way Lantmäteriet has chosen to split the data into several different parts for easier and lighter use. The up to date list of the available map layer is found by sending a request with the datatype set to MapLayer.
CoordinateType: The API can convert between SWEREF99 and WGS84 so you can get the data in a way that fits your needs. All positions from Lantmäteriet is in SWEREF99 so that is the most accurate one. The WGS84-conversion is done with a library and its precision can not be guaranteed.
To use the API you need to authenticate each request sent to the API. This is done with the help of a Token that is sent as a header in the request. In a later stage the token will be bound to your GIA-account. But as a first release there is a generic token for everyone to use.
To apply this token to your request you need to add an Authorization-header with the key "Authorization" and value "Bearer [YourToken]", replace [YourToken] with the actual token.
You can get your token from "My page" -
We have gathered a series of Postman-examples that you can use to test the API. These are ready to use, just enter your token under the Headers tab in a request. The VALUE-field already has 'Bearer ' added, so just paste the token after that and you are ready.
In the examples you can find an example for each of the DataTypes available.
There is also a small feature in the API where you can see an empty answer for each DataType, these are handy to see the structure of each response in GeoJSON.