How to read data from a REST API To Power BI – using Swedish central bank data as example
Blog
How to read data from a REST API to Power BI – using Swedish central bank data as example
In this blog post, we are going to go behind the scenes of the development of two reports available in our Portfolio. These reports read data from the Swedish central bank – the Riksbank – directly to Power BI. We do so by utilising the REST APIs provided by the Riksbank. REST API stands for REpresentational State Transfer API, and it is a common way of structuring and accessing data in a programmatic way.
Background on REST APIs
Some REST APIs have security measures in place, so that only authorised users can access the data. The user then has to send credentials by using the API, and if they are verified correctly, data can be read. With the Riksbank’s API it is not required with credentials. Hence, this guide is going to skip that part, and we are only reading, not writing, data when using the API. We are going to access interest rates for the SWESTR which is a reference rate with short duration (overnight rate). For more information about SWESTR, please see the Riksbank’s website.
How to read data from a REST API to Power BI
The user starts by going to Get data in Power BI. It is going to look like this, and then the user selects “Web” in the list.
From the Riksbank’s website, we see that the request to get all the interest rate values is:
https://api.riksbank.se/swestr/v1/all/{interestRateId}?fromDate={fromDate}[&toDate]
We also read that interestRateId = SWESTR shall be used and we set fromDate = 2023-01-01. The toDate is optional, as indicated by [], and we skip it. It will then read all the data up until today. The request will look like:
https://api.riksbank.se/swestr/v1/all/SWESTR?fromDate=2023-01-01
We simply add that to the URL requested in Power BI.
The user gets the data from 1st January 2023 in return. Each row of the data is the data for that day, for example the interest rate and the volume during that day.
The data connection is now established, and it is now easy to refresh by a single click in Power BI.
For more information about the APIs provided by the Riksbank, please see their documentation.