Overview
BanxicoApi is a Python package designed to interact with the Banxico (Banco de México) API. It allows users to fetch economic and financial series data, including metadata, and provides methods to handle data ranges and specific series codes.
Usage
Initialization
You need to initialize the BanxicoApi class with your API token:
from banxicoapi.banxico_api import BanxicoApi
api_token = 'YOUR_API_TOKEN'
banxico_api = BanxicoApi(api_token)
Fetching Series Data
You can fetch series data using the get method. This method allows for various parameters to customize the data retrieval.
Basic Usage
Fetch data for a list of series:
series = ['SF43718', 'SF46410']
data = banxico_api.get(series)
print(data)
Fetching Data with Metadata
To include metadata in the response:
data_with_metadata = banxico_api.get(series, metadata=True)
print(data_with_metadata)
Fetching Opportuno Data
To fetch the most recent data available:
opportuno_data = banxico_api.get(series, oportuno=True)
print(opportuno_data)
Fetching Data for a Specific Date Range
You can specify a date range to fetch data:
start_date = '2022-01-01'
end_date = '2022-12-31'
data_in_range = banxico_api.get(series, start_date=start_date, end_date=end_date)
print(data_in_range)
To include metadata with date range data:
data_in_range_with_metadata = banxico_api.get(series, start_date=start_date, end_date=end_date, metadata=True)
print(data_in_range_with_metadata)
Fetching Metadata Only
If you only need the metadata for a list of series:
metadata = banxico_api.getMetadata(series)
print(metadata)
Fetching Data by Code instead of series ID
If you have predefined codes mapped to series, you can fetch data by code:
code = 'CF120'
data_by_code = banxico_api.getByCode(code)
print(data_by_code)
Methods Summary
get(series: List[str], start_date: str = None, end_date: str = None, oportuno: bool = False, metadata: bool = False)
Fetches data for the specified series, optionally within a date range, and with metadata.
getMetadata(series: List[str])
Fetches metadata for the specified series.
Metadata
Release files for banxicoapi 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| banxicoapi-1.0.2.tar.gz | 4.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| banxicoapi-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / banxicoapi-1.0.2.tar.gz
| Download URL | banxicoapi-1.0.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34999be81aaec3c67fe11d767ac92b5fc70490cd5430fc98594cce38c891aef2
|
|
BLAKE2b-256 checksum How to use checksums |
8680b787f2fb22a63113de262cffd03f09cd12acbafb186760b0c6d86f896f44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.7
|
Release files / banxicoapi-1.0.2-py3-none-any.whl
| Download URL | banxicoapi-1.0.2-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14a65b5629e691f0311015c9e848501498a8c675fccff9e7bc99cab038ad6329
|
|
BLAKE2b-256 checksum How to use checksums |
804107f97a88e7a090534fd7c8bce415f82509f58b81f78405bafc6412a1c0e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.7
|
Security for banxicoapi 1.0.2
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.