API for the Statistical Database
You can use the API without registering.
Obs! We introduced mandatory https for the API as of 26 October 2022. If you get metadata instead of data in the table it depends on that http changes the call to GET. You solve this by change your calls to https instead of http.
Guide
Examples
Show all subject area in English in the Statistical Database:
https://api.scb.se/OV0104/v1/doris/en/ssd/
Show all sub-levels for the subject area Population:
https://api.scb.se/OV0104/v1/doris/en/ssd/BE
Show the metadata for the table:
https://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0101/BE0101A/BefolkningNy
Download Sweden's population for the years 2011 and 2012. Make an http POST request to:
https://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0101/BE0101A/BefolkningNy
and as data, the JSON request is used below
{ |
You can now get help to formulate questions to the Statistical Database API. Make your data retrieval in the Statistical Database user interface. On the page that shows the table, click on the API link for this table. This will give you information about the URL and the query that you need to send to retrieve the same data with the API.
For Python developers
One of the users of the Statistical Database has developed a module with an example code for Python Developers. The code is available on GitHub.
How to use Python for data from the Statistical Database (Github)
For R developers
One of the users of the Statistical Database has developed a module with an example code for Python Developers. The code is available on GitHub.
How to fetch data from the Statistical Database in R
Contact
- Telephone
- +46 10 479 50 00
- Opening hours
Weekdays
9:00–12:00, 13:00–16:00