Client for Banxico API
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file banxicoapi-1.0.2.tar.gz.
File metadata
- Download URL: banxicoapi-1.0.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34999be81aaec3c67fe11d767ac92b5fc70490cd5430fc98594cce38c891aef2
|
|
| MD5 |
a5128ca55f835e9414b387d15cfd82f5
|
|
| BLAKE2b-256 |
8680b787f2fb22a63113de262cffd03f09cd12acbafb186760b0c6d86f896f44
|
File details
Details for the file banxicoapi-1.0.2-py3-none-any.whl.
File metadata
- Download URL: banxicoapi-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14a65b5629e691f0311015c9e848501498a8c675fccff9e7bc99cab038ad6329
|
|
| MD5 |
afae1c9045806b980af644937aea5590
|
|
| BLAKE2b-256 |
804107f97a88e7a090534fd7c8bce415f82509f58b81f78405bafc6412a1c0e2
|