econchile
Chilean macroeconomic data (Banco Central de Chile) for Python.
econchile is a thin, practical client for the BCCh SIE REST web service. It downloads official series (UF, USD, TPM, IPC_VAR, IPC_INDEX, IMACEC, PIB), parses them into clean, typed data, and keeps a local SQLite cache so repeat queries are instant and your scripts survive API outages.
Install
Once v0.1 is on PyPI: pip install econchile. Until then, install from source:
git clone <repo-url> econchile
cd econchile
pip install -e .
Requires Python 3.10+.
Authentication
Request a free API token from the BCCh statistics database (SIE), see the official API documentation.
export BCCH_TOKEN="your-token-here"
The library reads BCCH_TOKEN from the environment — it does not load .env files itself. The token is required for v0.1.
Quickstart
from econchile import BcchClient, Series
client = BcchClient()
# Last 3 months of the UF (daily)
result = client.get(Series.UF, "2024-01-01", "2024-03-31")
for obs in result.observations:
print(obs.date, obs.value)
Dates are always YYYY-MM-DD. Missing observations have value=None.
The two clients
| Client | Strategy | Best for |
|---|---|---|
BcchClient |
Cache-first — serves from the local cache when fresh, hits the API only on a miss | Interactive use, repeated queries |
OfflineClient |
API-first — always tries the API, falls back to the cache when it fails | Cron jobs and scripts that must not crash |
from econchile.offline import OfflineClient
client = OfflineClient()
result = client.get(Series.USD, "2024-01-01", "2024-03-31") # survives API outages
Available series (v0.1)
| Series | BCCh code | Frequency | Meaning |
|---|---|---|---|
Series.UF |
F073.UFF.PRE.Z.D |
daily | Unidad de Fomento |
Series.USD |
F073.TCO.PRE.Z.D |
daily | Nominal exchange rate (CLP/USD) |
Series.TPM |
F022.TPM.TIN.D001.NO.Z.D |
daily | Monetary policy rate |
Series.IPC_VAR |
F074.IPC.VAR.Z.Z.C.M |
monthly | CPI, month-over-month change |
Series.IPC_INDEX |
F074.IPC.IND.Z.2023.C.M |
monthly | CPI general index (base 2023=100) |
Series.IMACEC |
F032.IMC.IND.Z.Z.EP18.Z.Z.0.M |
monthly | Economic activity index (base 2018=100) |
Series.PIB |
F032.PIB.FLU.R.CLP.EP18.Z.Z.0.T |
quarterly | GDP, chained volumes (base 2018) |
More series are planned. Use client.list_series() for the full catalog and client.search("ipc") to find series by keyword:
hits = client.search("ipc") # matches name, code, Spanish and English titles
for meta in hits:
print(meta.series_id, meta.spanish_title)
Gotchas
- Date format: pass
YYYY-MM-DDtoget(); the library converts the API's nativeDD-MM-YYYYfor you. - Missing data: the BCCh API marks gaps as "ND". These become
value=None, not zeros or exceptions, check forNonebefore using a value. - Representations:
IPC_VARis a monthly % change,IPC_INDEXis a base-2023 index. Same variable, different meaning. - Cache freshness: cached results are reused for 24 hours by default; configure via
ttl_secondsonBcchClient(...)orOfflineClient(...)(the cache lives at~/.econchile/cache.db). - Errors: unknown series raise
KeyError, malformed dates raiseValueError, API failures raiseBcchApiErrorandBcchOfflineErrorwhen the offline fallback is also exhausted.
API
BcchClient.get(series, desde, hasta, use_cache=True)— fetch a series over a date range; returns aSeriesResult.OfflineClient.get(series, desde, hasta)— same, but API-first with cache fallback.BcchClient.search(keyword)— case- and accent-insensitive catalog search →list[SeriesMeta].BcchClient.list_series()— all series metadata →list[SeriesMeta].BcchClient.clear_cache()— empty the local cache (returns the number of rows removed).
A SeriesResult has:
series— theSeriesmemberobservations— list ofObservation(date: str, value: float | None)fetched_at— timestamp (UTC)source—"api","cache", or"partial"metadata— series info (titles, frequency, representation)
Development
pip install -e . && pip install pytest
python -m pytest tests/
License
MIT
Release files for econchile 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| econchile-0.1.0.tar.gz | 37.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| econchile-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.0 kB
Release files / econchile-0.1.0.tar.gz
| Download URL | econchile-0.1.0.tar.gz |
|---|---|
| Size | 37.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61ae0f5ba66e61884529c2675f7871338c6e0cc7b86defd100e4a517a0bed0e4
|
|
BLAKE2b-256 checksum How to use checksums |
002c8591c25b38f730116fe9c0ec6b7f1c976efef17889010014604c534d71a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.
Transparency logRelease files / econchile-0.1.0-py3-none-any.whl
| Download URL | econchile-0.1.0-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c0a8b5e964ad663d7de052d65ccc7109cc1e9c9ff7f82f6e7e09f4a845187f2
|
|
BLAKE2b-256 checksum How to use checksums |
b23fddc9918291bb95543f0122c1efd79eaee816b892c1a37e2da1b7b62d5093
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.
Transparency log