SCB Statistics API Without Cell Limits

Published · 4 min read

SCB has the statistics most Swedish dashboards eventually need: population, industries, municipal KPIs, prices, migration, and more. The data is valuable. The raw API takes patience.

You have to find the right table, build a POST body, choose dimensions, and stay under the 100,000-cell limit.

The Problem with SCB's Raw API

With SCB's PxWeb API, the work starts before the request:

  1. Find the table — browse nested folders until you reach the right table ID
  2. Build POST bodies — choose exact dimensions, filter values, and response format in JSON
  3. Stay under the cell limit — queries exceeding 100,000 cells are rejected. You need to split large requests manually.
  4. Parse px-web responses — the response uses SCB's own key/value structure

Raw SCB API call

Request (POST with query body)
curl -X POST "https://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0101/BE0101A/BesijpSNpunktAr" \
  -H "Content-Type: application/json" \
  -d '{
    "query": [
      {
        "code": "Region",
        "selection": { "filter": "item", "values": ["00"] }
      },
      {
        "code": "ContentsCode",
        "selection": { "filter": "item", "values": ["BE0101N1"] }
      }
    ],
    "response": { "format": "json" }
  }'

The table ID is not something you guess. You browse SCB's site or docs to find it, then hope your region, year, and variable selection stays below the limit.

The Apiverket Way

SCB Direct (POST)

// 1. Find the right table ID
// 2. Build POST body with dimensions
const res = await fetch(
  "https://api.scb.se/OV0104" +
  "/v1/doris/en/ssd/BE/BE0101" +
  "/BE0101A/BefolkningNy",
  {
    method: "POST",
    headers: { "Content-Type":
      "application/json" },
    body: JSON.stringify({
      query: [{ code: "Region",
        selection: { filter: "item",
          values: ["00"] }}],
      response: { format: "json" }
    })
  }
);

Apiverket (GET)

const res = await fetch(
  "https://apiverket.se" +
  "/v1/population",
  {
    headers: {
      Authorization:
        "Bearer sk_live_YOUR_KEY"
    }
  }
);

const { data } = await res.json();
// data.population = 10_551_707
// data.year = 2025
// data.by_region = [...]

GET instead of POST. Apiverket maps useful SCB tables to REST endpoints and handles pagination for larger datasets. You do not need to ship table IDs in your app.

Find the SCB Table Behind an Endpoint

You should not have to guess which PxWeb table, filter, or period an endpoint uses. The SCB table registry lists the curated tables Apiverket wraps, including table IDs, dimensions, default filters, and runnable examples.

# List curated SCB/PxWeb tables
curl -H "Authorization: Bearer sk_test_demo" \
  https://apiverket.se/v1/open-data/scb/tables

# Inspect one table, including dimensions and examples
curl -H "Authorization: Bearer sk_test_demo" \
  https://apiverket.se/v1/open-data/scb/tables/TAB638

SCB-backed responses can include source metadata in meta.sources, such as table_id, table_title, and period. That makes it easier to trace the clean REST response back to the underlying official table.

Available Statistics Endpoints

Endpoint Description
/v1/open-data/scb/tablesCurated SCB/PxWeb table registry
/v1/populationPopulation data by region and year
/v1/statistics/industry/{sniCode}Industry and business statistics by SNI code
/v1/prices/cpiConsumer price index
/v1/gdpGDP data
/v1/wagesNational wage statistics

Try It Now

curl -H "Authorization: Bearer sk_test_demo" \
  https://apiverket.se/v1/population

Add Swedish statistics to your app

Use clean JSON and paginated results. Start with the test key.

Open the API docs

View pricing plans — free tier includes 200 requests/day