@varve/agency-sdks

@varve/bis-stats-api

TypeScript client for BIS Stats SDMX data, availability, and structure metadata.

The Bank for International Settlements publishes cross-country financial and monetary statistics through the BIS Stats SDMX REST API. @varve/bis-stats-api wraps the SDMX REST v1.4 data, data availability, and structure endpoints in an isomorphic TypeScript client.

npm install @varve/bis-stats-api zod
import { BisStatsClient, BisStatsApiError } from '@varve/bis-stats-api';
 
const client = new BisStatsClient();

When to use this package

Use @varve/bis-stats-api when your workflow needs BIS statistical data or metadata through SDMX:

  • SDMX CSV or JSON data queries
  • valid dimension values through availability constraints
  • dataflows, data structures, codelists, concepts, categories, and agency schemes
  • direct access to XML or EDI SDMX payloads for downstream SDMX tooling

Data queries

BIS data queries use the SDMX v1.4 path shape /data/{flow}/{key}/all.

const csv = await client.getDataCsv('WS_EER', {
  key: 'M.N.B.CH',
  lastNObservations: 12,
  detail: 'dataonly',
});
 
const json = await client.getDataJson('BIS,WS_EER,1.0', {
  key: 'M.N+R.B.CH',
  startPeriod: '2020-01',
  endPeriod: '2020-12',
});

Availability

Use availability constraints to discover valid values for a partial key.

const availability = await client.getAvailabilityJson('WS_EER', {
  key: 'M.N.B.',
  componentId: 'all',
  mode: 'available',
});

Structure metadata

const dataflows = await client.listDataflows({ detail: 'allstubs' });
const eer = await client.getDataflow('WS_EER', { references: 'children' });
const codelists = await client.getCodelists({ resourceId: 'all' });

For less common structure endpoints, use the generic helper:

const categories = await client.getStructureResourceJson('categoryscheme', {
  agencyId: 'all',
  resourceId: 'all',
  version: 'latest',
});

Configuration

const client = new BisStatsClient({
  baseUrl: 'https://stats.bis.org/api/v1',
  timeoutMs: 30_000,
});

Error handling

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

Official references

On this page