Skip to main content

boj-ts-api

Generic Python client for the Bank of Japan Time-Series Statistics API.

PyPI License: MIT Python 3.10+

Low-level, typed wrapper around the three BOJ API endpoints. For a beginner-friendly interface with domain wrappers and enum-driven filtering, see pyboj.

Installation

pip install boj-ts-api

Usage

Fetch Data by Series Code

from boj_ts_api import Client, Lang

with Client(lang=Lang.EN) as client:
    resp = client.get_data_code(
        db="CO",
        code="TK99F1000601GCQ01000",
        start_date="202401",
        end_date="202404",
    )
    for series in resp.RESULTSET:
        print(series.SERIES_CODE, series.VALUES.VALUES)

Auto-Pagination

with Client(lang=Lang.EN) as client:
    for series in client.iter_data_code(db="CO", code="TK99F1000601GCQ01000"):
        print(series.SERIES_CODE, len(series.VALUES.SURVEY_DATES), "data points")

Fetch Data by Layer

from boj_ts_api import Client, Frequency, Lang

with Client(lang=Lang.EN) as client:
    resp = client.get_data_layer(db="FM08", frequency=Frequency.D, layer="1,1")
    for series in resp.RESULTSET:
        print(series.SERIES_CODE, series.VALUES.VALUES[:5])

Metadata

with Client(lang=Lang.EN) as client:
    meta = client.get_metadata(db="FM08")
    for rec in meta.RESULTSET[:3]:
        print(rec.SERIES_CODE, rec.FREQUENCY, rec.NAME_OF_TIME_SERIES)

Async Client

import asyncio
from boj_ts_api import AsyncClient, Lang

async def main():
    async with AsyncClient(lang=Lang.EN) as client:
        resp = await client.get_data_code(db="CO", code="TK99F1000601GCQ01000")
        print(resp.RESULTSET[0].SERIES_CODE)

asyncio.run(main())

CSV Output

with Client(lang=Lang.EN) as client:
    csv_text = client.get_data_code_csv(db="CO", code="TK99F1000601GCQ01000")
    print(csv_text)

API Surface

Method Description
get_data_code() Fetch time-series data by series code(s)
iter_data_code() Auto-paginating iterator over series results
get_data_code_csv() Fetch data as raw CSV text
get_data_layer() Fetch data by hierarchy layer
iter_data_layer() Auto-paginating iterator for layer data
get_data_layer_csv() Fetch layer data as raw CSV text
get_metadata() Fetch series metadata for a database
get_metadata_csv() Fetch metadata as raw CSV text

Both Client (sync) and AsyncClient (async) expose the same methods.

License

MIT

Metadata

Release files for boj-ts-api 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boj-ts-api 0.2.0
File Size Uploaded Provenance
boj_ts_api-0.2.0.tar.gz 9.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for boj-ts-api 0.2.0
File Interpreter ABI Platform
boj_ts_api-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.9 kB

Release files / boj_ts_api-0.2.0.tar.gz

Download URL boj_ts_api-0.2.0.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ee1665d8cd53ac8ae690e7f4e986b9a0ae043ecc1f4b4da8c94ce39e210208cd
BLAKE2b-256 checksum
How to use checksums
a2aef659760476b91756c70ddd145fc212619087ea81ae52827ec00c58eb4ca3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release files / boj_ts_api-0.2.0-py3-none-any.whl

Download URL boj_ts_api-0.2.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6efc36725467daa4b855fd464397618e551bf472c86443fa8cbb18e14746dc4e
BLAKE2b-256 checksum
How to use checksums
cd9cfaf2f0de56a6242a0321099ba0f9499eaa1ba2944183173ac10e9910c5e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Security for boj-ts-api 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page