Hagstofan (Statistics Iceland)

SkillDev tools

Hagstofan / Statistics Iceland PX-Web API. Use for Icelandic national statistics — GDP, CPI, population, foreign trade by tariff code, wages, education, health.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Hagstofan (Statistics Iceland) skill

What this skill tells your AI

The instructions your AI receives, as published by jokull/icelandic-data in .agents/skills/hagstofan/SKILL.md and read by ahel’s review.

Official statistics for Iceland via PX-Web API.

API

Base URL: https://px.hagstofa.is/pxis/api/v1/is/

No authentication required. Returns JSON metadata (GET) or CSV/JSON data (POST).

Fetching Data

Browse categories

curl -s "https://px.hagstofa.is/pxis/api/v1/is/" | jq
curl -s "https://px.hagstofa.is/pxis/api/v1/is/Efnahagur/" | jq

Get table metadata

curl -s "https://px.hagstofa.is/pxis/api/v1/is/{path}/{TABLE}.px" | jq

Fetch all data as CSV

curl -X POST "https://px.hagstofa.is/pxis/api/v1/is/{path}/{TABLE}.px" \
  -H "Content-Type: application/json" \
  -d '{"query": [], "response": {"format": "csv"}}'

Fetch filtered data

curl -X POST "https://px.hagstofa.is/pxis/api/v1/is/{path}/{TABLE}.px" \
  -H "Content-Type: application/json" \
  -d '{
    "query": [
      {"code": "Tollskrárnúmer", "selection": {"filter": "item", "values": ["87116011", "87120000"]}}
    ],
    "response": {"format": "csv"}
  }'

API Categories

CategoryPathDescription
PopulationIbuar/Demographics, migration, families
EconomyEfnahagur/GDP, national accounts, trade
PricesVerdlag/CPI, price indices
IndustriesAtvinnuvegir/Fishing, agriculture, tourism
SocietySamfelag/Education, health, crime
EnvironmentUmhverfi/Climate, waste, energy
HistoricalSogulegar/Long-term historical series

Key Datasets

Foreign Trade (Tollskrá)

Path: Efnahagur/utanrikisverslun/1_voruvidskipti/

TablePeriodDescription
03_inntollskra/UTA03803.px2023-2025Imports by tariff, chapters 84-99 (monthly)
06_tollskrarnumereldra/UTA13813.px2017-2022Imports by tariff, chapters 84-99 (annual)
06_tollskrarnumereldra/UTA13823.px2012-2016Imports by tariff, chapters 84-99 (annual)

Units available: kg (weight), cif (value ISK), vEin (units)

GDP / National Accounts

Path: Efnahagur/thjodhagsreikningar/landsframl/1_landsframleidsla/

TableDescription
THJ01103.pxGDP at constant prices 1980-2024
THJ01000.pxKey GDP figures 1945-2024
THJ01401.pxGDP per capita 1980-2024

Population

Path: Ibuar/mannfjoldi/

TableDescription
1_yfirlit/Yfirlit_mannfjolda/MAN00000.pxKey population figures 1703-2025
1_yfirlit/Yfirlit_mannfjolda/MAN00101.pxPopulation by sex and age

State treasury — ríkissjóður fiscal aggregates

Path: Efnahagur/fjaropinber/fjarmal_rikissjods/

TablePeriodDescription
THJ05211.px1980-2025One-stop state budget balance: tekjur, gjöld, tekjuafgangur/-halli (m.kr), % af VLF, real-2025 prices
THJ05221.px1998-2025Full ESA income statement: rekstrartekjur, rekstrarútgjöld, tekjuafgangur, capital rows
THJ05222.px1998-2025Rekstrarreikningur ríkissjóðs
THJ95200.px2004-2014Cash-basis (greiðslugrunnur) monthly state accounts — month code 0 = annual total
THJ05281.px1998-2025Monetary assets and debt incl. almannatryggingar

The ríkisreikningur (Fjársýsla) API only goes back to 2015 — pre-2015 state budget balance (e.g. the 2008–2011 crisis deficits) comes from these tables. scripts/hagstofan_rikissjod.py fetch builds data/processed/rikissjod_balance.csv (all years, wide, m.kr).

Tariff Codes (Bikes/E-bikes)

Classification changed in 2020:

CodeCategoryDescription
87116010ebikes*Pre-2020: E-bikes + e-scooters combined
87116011ebikesE-bikes (pedal-assist ≤25 km/h)
87116012escootersE-scooters (kick scooters with motor)
87116015ebikesOther small EVs ≤25 km/h
87116090ebikesOther electric motorcycles
87120000bikesRegular bicycles (no motor)

*Discontinued 2020, split into 87116011/12/15

Data Caveats

  1. Encoding: CSV output uses UTF-8 with BOM. DuckDB may need ignore_errors=true

  2. Archive vs Current:

    • Archive tables (eldra efni) have annual aggregates
    • Current tables have monthly data by country
  3. Classification changes: Tariff codes change over time. Always check when series definitions shifted.

  4. Wide format: PX tables return time periods as columns. Unpivot to tidy format:

    # Polars unpivot
    df.unpivot(index="Category", variable_name="month", value_name="value")
    
    -- DuckDB UNPIVOT
    UNPIVOT table ON * EXCLUDE (category) INTO NAME month VALUE passengers
    
  5. Icelandic headers: Column names are in Icelandic. Common terms:

    • Ár = Year
    • Mánuður = Month
    • Tollskrárnúmer = Tariff code
    • Cif verð krónur = CIF value in ISK
    • Viðbótar magneining = Additional unit (count)
  6. PX-Web query gotchas:

    • "filter": "all" returns HTTP 400 Bad Request — always enumerate values explicitly ("filter": "item").
    • json-stat2 responses keep id / size at the top level, not under dimension (dimension keys are plain dimension names).
    • The response's category label may echo the requested selection codes rather than the human labels — when you need row labels, read the metadata valueTexts in the same order as its values.
    • Some tables use a "total" code: THJ95200 has month code 0 = annual total (months are 112).

Generic labelled query CLI

uv run python scripts/hagstofan_query.py fetch <relative-table-path> --filters '{"dimension-code":["value-code"]}' --since 2015 --out /path/result.json

list <path> returns metadata/catalogue. Fetch outputs long-form JSON records with original dimension codes and metadata labels; preserves nulls and archives raw JSON by SHA-256. Useful as a CLI dependency for external projects. Do not trust JSON-stat updated as publication time: hotel tables have returned 2015 or year 9999 with current observations.

Current VIS01300 uses CP01–CP13. CP12 is insurance/financial services, CP13 personal care/social protection/other services. hagstofan_cpi.py keeps CP12/CP13 current-only because old IS12 is not comparable. It preserves previous output and exits nonzero if any fetch fails. Other historical category concordances still need care.

Signals

GitHub stars
53
Forks
4
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
hagstofan
Source
github.com/jokull/icelandic-data