The page for the API: Ready-made datasets can still be used but will be removed during 2025.
Via PxWebApi 2.0, you can retrieve data from all tables in SSB's statistical database with HTTP GET. The query can thus be defined in the URL itself.
Read more about PxWebApi 2.0 beta in StatBank PxWebApi user guide.
How to replace a ready-made dataset with a new query in PxWebApi 2.0
The most commonly used datasets have been translated into new queries (in json-stat2 and CSV format) (XLSX)
If you need to translate other queries, follow this recipe:
- Follow the link to the Statbank table that is the source of the numbers in the finished dataset (see e.g. https://data.ssb.no/api/v0/dataset/760065?lang=en)
- Select the variables that you want to include, and show table
- Copy the link that appears at the bottom under "API query for this table"
- Paste the link as a new http query (GET) in Postman or similar application
- We recommend replacing the lists of value codes with * or from(start value)
- "Send" now gives you a new query in the JSON-stat2 format
- If you want csv format, add outformat=csv, as well as outputformatparams to specify the separator and code/text. List up the variables in stub, with Tid and ContentsCode at the end.
Please note that in the old API, the datasets may have some variables that show code and text, while other variables only show text in the csv format. In PxWebApi 2.0, you choose this for the entire dataset, i.e. for all variables: UseCodesAndTexts or UseTexts. However, the codes are always included for some variables that are set to show code together with text in PxWeb (especially industry and region).
Please note that PxWebApi 2.0 only supports version 2 of the json-stat format, while the API with ready-made datasets supports version 1 of json-stat.
Contact statistikkbanken@ssb.no if you have questions about the tables or the API.