@varve/agency-sdks

@varve/eurostat-api

TypeScript client for Eurostat JSON-stat data, SDMX 3.0 metadata, SDMX CSV exports, and graph-friendly dataset metadata.

Eurostat publishes EU statistical datasets across population, economy, labour, trade, prices, regions, and more. @varve/eurostat-api wraps Eurostat's JSON-stat Statistics API and SDMX 3.0 endpoints in an isomorphic, Zod-validated TypeScript client.

npm install @varve/eurostat-api zod
import { EurostatClient, EurostatApiError } from '@varve/eurostat-api';
 
const client = new EurostatClient();

When to use this package

Use @varve/eurostat-api when you need official EU data and metadata from Eurostat, especially when your workflow needs one of these access paths:

  • JSON-stat data for convenient typed retrieval
  • SDMX 3.0 structure discovery
  • SDMX CSV exports for analytical pipelines
  • dataset, dimension, and member metadata for search or graph systems

Data model

Eurostat datasets are easiest to understand as dataset -> dimension -> member.

Dataset or dataflow is the statistical table or cube, such as demo_gind.

Dimension is a field that slices the dataset, such as frequency, indicator, geography, unit, or time.

Member is a valid value inside a dimension, such as DE, FR, A, or a specific indicator code.

The JSON-stat API is convenient for direct data retrieval. SDMX endpoints are useful when you need catalogue, structure, codelist, concept, or CSV access.

Quick start

const data = await client.getStatisticsData('demo_gind', {
  filters: {
    freq: 'A',
    indic_de: 'JAN',
    geo: ['DE', 'FR'],
    time: ['2022', '2023'],
  },
});
 
console.log(data.value);

Common workflows

Configuration

const client = new EurostatClient({
  baseUrl: 'https://ec.europa.eu/eurostat/api',
  maxRetries: 2,
  timeoutMs: 30_000,
});

The client retries 429 and 5xx responses.

Error handling

try {
  await client.getStatisticsData('missing');
} catch (err) {
  if (err instanceof EurostatApiError) {
    console.error(err.status);
    console.error(err.url);
    console.error(err.body);
  }
}

Official references

On this page