New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

statfin-sdk

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

statfin-sdk

Minimal StatFin (Tilastokeskus) SDK for PxWeb json-stat2 queries with Cache API support.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

statfin-sdk

Unofficial StatFin (Tilastokeskus) SDK for querying the Statistics Finland PxWeb API.

ESM only. Requires Node 18+ (built-in fetch).

Goals

  • Developer friendly API for StatFin PxWeb data
  • Simple, typed query building for JSON-stat2
  • Return a flat row array with labels so developers can programmatically work with the data more easily

Installation

npm install statfin-sdk
# or
pnpm add statfin-sdk
# or
yarn add statfin-sdk

Usage

import { buildJsonQuery, queryStatFin } from "statfin-sdk";

const url =
  "https://pxdata.stat.fi:443/PxWeb/api/v1/fi/StatFin/vaerak/statfin_vaerak_pxt_11re.px";

const jsonQuery = buildJsonQuery([
  { code: "Vuosi", selection: { filter: "item", values: ["2023"] } },
  { code: "Alue", selection: { filter: "item", values: ["SSS"] } },
  { code: "Tiedot", selection: { filter: "item", values: ["vaesto"] } },
]);

const rows = await queryStatFin(url, jsonQuery);
console.log(rows[0]);

Row format

queryStatFin returns an array of rows. Each row contains:

  • One key per dimension (e.g. Vuosi, Tiedot)
  • A label field for each dimension (e.g. Vuosi_label)
  • value for the numeric value

Use a raw JSON query

If you copied the JSON query from the PxWeb UI, pass it directly:

const rows = await queryStatFin(url, jsonQueryStringFromUi);

Caching (Cache API)

When the Cache API is available (browsers, service workers), queryStatFin caches successful responses in a cache named statfin-sdk. The cache key is derived from the request URL and JSON body so repeated queries return the cached data.

To clear the cache:

await caches.delete("statfin-sdk");

Node.js does not expose the Cache API, so caching is skipped in Node runtimes.

How to get the URL and JSON query

Use the StatFin PxWeb UI and copy the URL + JSON query from "Make this table available in your application".

INSTRUCTION URLS:

UI URLS:

Keywords

statfin

FAQs

Package last updated on 21 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts