Skip to main content
Glama
README.md
# vintaj

vintaj keeps dated copies (vintages) of Malaysian official open data, so you can see what a published number was on any past date
and which numbers were later revised.

[Bahasa Melayu](#bahasa-melayu) di bawah.

## Why

Official statistics change after they are first published: figures are revised, tables are restructured and some datasets stop
being served. A data portal shows the latest version only. Research on forecasting, nowcasting or policy decisions needs the data
as it was known at the time (real-time data), which ALFRED provides for United States series. No public record of this kind
existed for Malaysia, and it cannot be rebuilt later: a version that nobody saved is gone.

vintaj starts that record with the open data portal of Bank Negara Malaysia ([data.bnm.gov.my](https://data.bnm.gov.my), 215
datasets on monetary, financial and economic statistics). The first capture was taken on 2026-11-28 at 21:47 UTC, and the portal
is checked every 3 hours since. The archive is published as the dataset
[Vintaj MY](https://huggingface.co/datasets/sasateguh/vintaj-my), with a short data descriptor (English and Malay PDF) in the
`kertas/` folder of the dataset.

## What is recorded

| Table | One row per | Use |
|---|---|---|
| `sejarah/<dataset>.parquet` | row of the dataset, with `vintaj_dari` (first seen) and `vintaj_hingga` (replaced or removed; empty = still current) | the dataset as it stood at any time |
| `revisi/<dataset>.parquet` | value that changed for the same key between two vintages: column, old value, new value | revision analysis |
| `versi.parquet` | version of a dataset file: SHA-256, capture time, server `Last-Modified`, rows added, removed and revised | update timing |
| `catatan/katalog.jsonl` | change to the portal catalogue: datasets added or removed | dataset births and discontinuations |
| `meta/<dataset>/*.json.gz` | version of the dataset definition: fields, glossary, methodology, status | definition changes |

Times are capture times in UTC (our evidence that the version existed), so a version is placed within 3 hours of its release.

### The data as it was on a date

```sql
-- DuckDB
SELECT * EXCLUDE (vintaj_dari, vintaj_hingga)
FROM 'sejarah/opr_decisions.parquet'
WHERE vintaj_dari <= TIMESTAMP '2026-12-01 00:00:00'
  AND (vintaj_hingga IS NULL OR vintaj_hingga > TIMESTAMP '2026-12-01 00:00:00');
```

## Install and run

```bash
pip install 'vintaj[sejarah] @ git+https://github.com/sasateguh/vintaj'
vintaj tangkap      # capture: catalogue, every dataset file (conditional GET), metadata once a day
vintaj sejarah      # build the history and revision tables from the captures
vintaj sahkan       # rebuild every stored version from the history and compare it with the original file
vintaj status
vintaj pakej --keluar out/ --templat terbit/kad-set-data.md --statik terbit/set-data   # build a release of the dataset
```

The numbers in the dataset card and in the data descriptor are generated from the release files (`kertas/ukur.py`,
`kertas/bina.py`).

`tangkap` uses the Python standard library only, so captures continue even when other packages are missing. Defaults (sources,
URLs, delay between requests, retry codes, disk guard, MCP limits) live in `vintaj/lalai.json`; override any of them with a JSON
file named by `VINTAJ_KONFIG` (or `config/vintaj.json` in a checkout). The host that runs the public archive calls `tangkap` every
3 hours.

## Ask the data from an AI assistant (MCP)

```bash
pip install 'vintaj[mcp] @ git+https://github.com/sasateguh/vintaj'
vintaj mcp            # stdio server: current data from the portal, vintage history from the published dataset
```

Claude Desktop or any MCP client:

```json
{"mcpServers": {"vintaj": {"command": "uvx",
  "args": ["--from", "vintaj[mcp] @ git+https://github.com/sasateguh/vintaj", "vintaj", "mcp"]}}}
```

| Tool | What it does |
|---|---|
| `search_datasets` | finds datasets from English or Malay keywords (`kadar pertukaran`, `pinjaman perumahan`, `OPR`) |
| `describe_dataset` | fields with units, glossary, methodology, last update, sample rows |
| `query` | one read-only DuckDB query; table name = dataset id; `as_of` answers with the data as published at that time |
| `list_versions` | when a dataset changed: rows added, removed and revised |
| `get_revisions` | values that changed for the same key, with old and new value |

Queries run in a fresh in-memory DuckDB with file and network access switched off after the tables are loaded.

## Source, terms and limits

- Source: Bank Negara Malaysia. Data and information are subject to the
  [Terms of Use for BNM Datasets](https://data.bnm.gov.my/terms-of-use).
- This project is not affiliated with or endorsed by Bank Negara Malaysia. Values are stored exactly as served; check the portal
  for the authoritative figures.
- Revision keys are detected from the data (non-numeric columns that are unique in a version). A dataset without such a key gets
  added and removed rows but no revision rows.
- Temporary errors (HTTP 403, 429, 5xx) are retried and are not recorded as versions. A dataset that answers 404 or 410 is
  recorded as removed.

## Licence

Code: MIT. Dataset values: Terms of Use for BNM Datasets. Tables derived by this project (vintage index, revision tables):
CC BY 4.0.

## AI use

This software was written with the help of Claude (Anthropic). The author reviewed the code, ran the tests and checked every
stored version against the original files.

## Bahasa Melayu

vintaj menyimpan salinan bertarikh (vintaj) data terbuka rasmi Malaysia, supaya anda boleh melihat nilai yang diterbitkan pada
mana-mana tarikh lepas dan nilai mana yang kemudiannya disemak semula.

**Kenapa.** Statistik rasmi berubah selepas kali pertama diterbitkan: angka disemak semula, jadual disusun semula dan sesetengah
dataset berhenti disediakan. Portal data hanya menunjukkan versi terkini. Kajian ramalan, nowcasting atau keputusan dasar
memerlukan data seperti yang diketahui pada masa itu (data masa nyata), seperti yang disediakan ALFRED untuk siri Amerika
Syarikat. Rekod sebegini belum wujud untuk Malaysia, dan ia tidak boleh dibina semula kemudian: versi yang tiada siapa simpan
sudah hilang.

vintaj memulakan rekod itu dengan portal data terbuka Bank Negara Malaysia (data.bnm.gov.my, 215 dataset statistik monetari,
kewangan dan ekonomi). Tangkapan pertama diambil pada 2026-11-28 jam 21:47 UTC, dan portal disemak setiap 3 jam sejak itu. Arkib diterbitkan
sebagai set data Vintaj MY (huggingface.co/datasets/sasateguh/vintaj-my) berserta deskriptor data ringkas (PDF Inggeris dan
Melayu).

**Apa yang direkod.** Setiap versi setiap fail dataset, definisi dataset (medan, glosari, metodologi, status) dan perubahan
katalog. Jadual `sejarah` memberi setiap baris masa mula dilihat (`vintaj_dari`) dan masa digantikan atau dibuang
(`vintaj_hingga`); jadual `revisi` menyenaraikan nilai yang berubah bagi kunci yang sama; `versi` merekod masa setiap kemas kini.
Masa ialah masa tangkapan dalam UTC.

**Tanya data melalui pembantu AI (MCP).** `vintaj mcp` ialah pelayan MCP: cari dataset dengan kata kunci BM atau Inggeris,
lihat medan dan unit, jalankan SQL baca sahaja, dan tanya data seperti yang diterbitkan pada tarikh lepas (`as_of`).

**Sumber dan terma.** Sumber: Bank Negara Malaysia. Data dan maklumat tertakluk kepada Terms of Use for BNM Datasets. Projek ini
tidak bergabung dengan, dan tidak disokong oleh, Bank Negara Malaysia.

**Lesen.** Kod: MIT. Nilai dataset: Terms of Use for BNM Datasets. Jadual yang diterbitkan projek ini (indeks vintaj, jadual
revisi): CC BY 4.0.

**Penggunaan AI.** Perisian ini ditulis dengan bantuan Claude (Anthropic). Penulis menyemak kod, menjalankan ujian dan
membandingkan setiap versi yang disimpan dengan fail asal.