SCB Statistics API Without Cell Limits

Published · 4 min read

Statistiska centralbyrån (SCB) is Sweden's official statistics agency. Their API gives access to population data, industry statistics, municipal KPIs, and much more. But the API has a significant limitation: a 100,000-cell maximum per query, and queries require complex POST bodies with dimension selections.

The Problem with SCB's Raw API

SCB's PxWeb API requires you to:

  1. Navigate a table hierarchy — browse through nested folders to find the right table ID
  2. Build POST query bodies — specify exact dimension values, filter criteria, 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 response format — the response uses SCB's custom format with separate key/value arrays

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 (BefolkningNy) isn't discoverable — you need to browse SCB's website or documentation to find it. And if your query spans too many regions × years × variables, it silently fails.

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/statistics/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. No cell limits. No table IDs. Apiverket pre-maps the most useful SCB tables to intuitive REST endpoints and handles pagination for large datasets.

Available Statistics Endpoints

Endpoint Description
/v1/statistics/populationPopulation data by region and year
/v1/statistics/industryIndustry and business statistics
/v1/demographics/...Age distribution, migration, births/deaths
/v1/municipalities/{code}Municipal KPIs and statistics

Try It Now

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

Need Swedish statistics in your app?

Clean JSON, paginated results, no cell limits. Start with the test key.

Explore the API Docs

View pricing plans — free tier includes 200 requests/day