API Guide

The API to the energidataservice.dk platform enables users free of charge to download data for further processing. The platform does not have unlimited resources and do have limitations as described below. It is not meant as the source for all units for vendor applications. In this situation the vendor must download data and then be the source of all possible units for the application.

Jump to content:

Request methods

The restful API is a synchronous interface with Http Get. Parameters are a part of the URI string.

To get data:

or to get metadata:

followed by Parameter Name = Parameter Value, where each pair of parameter name and value are separated by &.

Build your request URL

To get a graphical guide to the API, you can access our swagger documentation.

Query the API

The Energi Data Service platform web API can be accessed via web browser using the Get method. The following example returns data for Price area = DK1 for May, 2022 for the DeclarationProduction dataset:

Below the description of Parameters and Limits you can see more examples of requests and their output using the different parameters.

Parameters

Only equal operator is available for all parameters.

Both ASCII characters and URL-encoding forms may be used.

start

Specifies the start point of the period for the data request. The period is selected based on the column given by the Time range column, which is specific to the dataset. The start point is included in the output. Example: "start=2022-07-01".

Datetime formats which may be used: "yyyy", "yyyy-MM", "yyyy-MM-dd", "yyyy-MM-ddTHH:mm"

The date and time refer to the Danish timezone.

You can also provide a dynamic timestamp that is relative to the current point in time. To do so the value should follow this format: {now | utcnow}{+ | -}{ISO_8601 duration}. For instance "start=now-P1D" will set the starting point to 1 day before now Danish time. "start=utcnow" wil set the starting point to now UTC time.

end

Specifies the end point of the period for the data request. The period is selected based on the column given by the Time range column. The end point is excluded from the output. Example: "end=2022-08-01".

columns

Optional - comma separated list of columns. If left blank all columns are included. Example: "columns=HourUTC,PriceArea,CO2Emis".

filter

Json list of column and value pairs. Example: "filter={"DK36Code":"QB","DK19Code":"Q"}" will return data where both conditions are met. It is also possible to specify multiple values for a column. Example: "filter={"PriceArea":"DK1,DK2"}" will return data where "PriceArea" is either "DK1" or "DK2".

sort

Comma separated list of columns to sort by. Example: "sort=HourUTC desc,PriceArea" or "sort=HourUTC%20desc,PriceArea" if space is not accepted. If left blank the output is sorted descending according to the unique key (e.g. HourUTC or Minutes5UTC) by default. If the sort parameter is set, the default sort order is ASC (ascending). E.g. "sort=CO2Emission" will sort ascending and "sort=CO2Emission desc" will sort descending.

offset

Number of records to skip. Example: "offset=30".

limit

Maximum number of records to return. Example: "limit=30".

"limit=0" returns all records. If neither "start" nor "limit" is provided a default value of 100 is used.

timezone

Specifies the chosen timezone. DK (default) or UTC. Used for interpretation of fixed time values. Example: “timezone=UTC”.

Limits on Requests

A maximum of 400 requests are accepted per user per minute. The count of requests is performed based on per IP address. Reaching the 400 query/minute limit through a unique IP address will result in a temporary ban of 5 minutes.

When a user reaches the limit, requests coming from the user will return HTTP Status 429 - TOO MANY REQUESTS with message text Max allowed requests per minute from each unique IP is max up to 400 only.

Examples

Below you can see examples of requests and their output using the different parameters.

Note that limit is added in all requests to limit the outputs of the examples. To use the request URL without limitations remove "&limit=4".

Also note that the outputs are displayed in descending order according to the unique key (e.g. HourUTC or Minutes5UTC) by default.


start and end

To get the first hour of January 1st 2022 from the dataset CO2 Emission:


Dynamic start and end

To get the last year from the dataset CO2 Emission:


columns

To only get the columns Minutes5DK, PriceArea and CO2Emission from the dataset CO2 Emission:


filter

To get data from either DK1 or DK2 from the dataset CO2 Emission:


sort

If set default sort order is ascending.

To sort by CO2 emission value in descending order:

or (the space between the value and sort order may be replaced with %20 as Both ASCII characters and URL-encoding forms may be used):


Combination of parameters start, end, columns, filter, sort and limit

To get only the first 4 rows of data from the first hour of January 1st 2022, only the columns Minutes5DK, PriceArea and CO2Emission and only PriceArea DK1, sorted by CO2Emission value in descending order:


offset

To not include the first 10 rows of the dataset CO2 Emission:


timezone

To get the first hour of January 1st 2022 from the dataset CO2 Emission using UTC time zone:


Download URL

It is possible to download data directly in the formats xlxs, json or csv by adding download?format=filetype after the name of the dataset and before the chosen parameters.


To download Excel: download?format=XL


To download json: download?format=json or download? (as json is default)


To download csv: download?format=csv