Please see the general user guide: PxWebApi 2 User Guide - PxTools.
Also see specifications at GitHub PxApiSpecs and OpenAPI Specification.

API limitations at Statistics Norway

You can retrieve entire tables or parts of tables. The limits per extract are 800,000 data cells, and the number of queries is currently 30 per minute. The limit is per IP address, and can therefore apply to many colleagues at the same workplace.

On some days there will be a high load in the first few minutes after new figures are published at 08:00. Unless you need it, avoid the time period 07:55 – 08:15. Existing figures that are to be revised at 08:00 will be shown as 0 or dot in the time period 05:00 – 08.00. Metadata is updated at 05:00 and 11:30, and during these updates the tables are unavailable. 

The API use the license Creative Commons Attribution 4.0 International (CC BY 4.0). 

How to use StatBank 

Via the Statbank Norway interface PxWeb: https://www.ssb.no/en/statbank/ you can look up all our tables.

Before using the API users should be used to the StatBank: How to use StatBank Norway.

It is useful to keep track of the page that provides structural changes and tables that are being terminated and replaced by new ones.

It happens that more values ​​are added to existing code lists. Therefore, you will get a more robust query by using * (asterisk) after valueCode instead of listing all the values.

Special characters in URL

Some special characters are recoded in the URL:

 (space)

%20

+

%2B

"

%22

(

%28

)

%29

[

%5B

]

%5D

If you use Postman to create the query, the characters are changed automatically.

Special characters in tables 

The API can display special characters instead of figures: 

Category not applicable 
Figures do not exist at this time, because the category was not in use when the figures were collected. 

.. 

Data not available 
Figures have not been entered into our databases or are too unreliable to be published. 

Confidential 
Figures are not published so as to avoid identifying persons or companies. 

In json-stat2, the special characters are displayed under status, while the data is shown as null

Saved query vs API query

Some have used saved query created in PxWeb version 1 as a source in Power Query (Excel and Power BI). PxWeb version 2 does not support formats such as csv or xlsx from saved queries, only display on screen. In PxWeb v2 saved query is called “Link to updated table”.

For example, the saved query https://www.ssb.no/statbank/sq/10119120 will no longer produce a csv file in the new interface. And you will get an error message in Power Query.

You can see how the query is defined by typing: 
https://data.ssb.no/api/pxwebapi/v2/savedqueries/10119120

So in the form: data.ssb.no/api/pxwebapi/v2/savedqueries/(number of saved query)

And you can get the file itself with: https://data.ssb.no/api/pxwebapi/v2/savedqueries/10119120/data

So in the form: data.ssb.no/api/pxwebapi/v2/savedqueries/(number of saved query)/data

However, we recommend using API queries instead of saved queries when automating. An API query is more flexible, and you can later change it if necessary.

The API query can e.g. look like this:
https://data.ssb.no/api/pxwebapi/v2/tables/08655/data?lang=en&valueCodes[Arbeidstype]=20&valueCodes[Tid]=from(2020M01)&valueCodes[ContentsCode]=*&outputFormat=csv&outputFormatParams=separatorsemicolon,usecodes&stub=Arbeidstype, Tid&heading=ContentsCode

So in the form: data.ssb.no/api/pxwebapi/v2/tables/(table number)/data (query parameters)

Examples of code for using the API 

Contact 

Contact statistikkbanken@ssb.no if you have questions about the tables or the API.

It is also possible to provide feedback on GitHub: 
https://github.com/PxTools/PxApiSpecs and ttps://github.com/PxTools/PxWebApi