query_table
Retrieve data from PxWeb statistical tables by defining variable values, ranges, or wildcards. Choose output formats like JSON-stat2, CSV, XLSX, HTML, or PX.
Instructions
Query data from a table using the v2 API syntax.
Value selection syntax:
Specific values: valueCodes[Region]=0301,0402
All values: valueCodes[Region]=*
Wildcard: valueCodes[Konsumgrp]=?? (two-digit codes)
Latest N: valueCodes[Tid]=top(5)
From value: valueCodes[Tid]=from(2020M01)
Range: valueCodes[Region]=[range(01,05)]
Output formats: json-stat2, csv, xlsx, html, px, json-px
For csv/xlsx/html, use stub and heading to control layout.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| language | No | Language - 'no' for Norwegian (default), 'en' for English. | no |
| table_id | Yes | The table ID to query. | |
| code_list | No | Optional code lists to use. Example: { Region: 'agg_Fylker2024' } | |
| value_codes | Yes | Object mapping variable IDs to value selections. Example: { Region: '0301', Tid: 'top(5)', ContentsCode: '*' } | |
| output_format | No | Output format. | json-stat2 |
| output_values | No | For groupings: 'aggregated' for sums, 'single' for individual values. |