Skip to main content

English · Español

Cotizave Python SDK

Official, fully-typed Python client for the Cotizave API v2 — multi-country exchange-rate references, currency conversion, historical series, bank rates and calendars, behind a single API key.

PyPI Python License: MIT

API & docs hub · Documentation · API reference · Get an API key


Install

pip install cotizave

Requires Python 3.10+. The only runtime dependency is httpx.

Quick start

from cotizave import Cotizave

# Reads COTIZAVE_API_KEY from the environment; or pass api_key="..."
client = Cotizave()

# Every rate published for a country
response = client.rates.list("AR")
for rate in response["rates"]:
    print(rate["id"], rate.get("mid"))

# A single rate by its canonical id
trm = client.rates.get("CO", "co-trm")
print(trm["mid"])

# A currency conversion (resolved on Cotizave, never computed client-side)
result = client.convert(from_="USD", to="BRL", amount=100)
print(result["to"]["amount"])

client.close()

Use it as a context manager to close the connection pool automatically:

with Cotizave() as client:
    feed = client.rates.global_(symbols=["BRL", "EUR"])

Keep your API key server-side. It is sent only as the X-API-Key header. Never ship it in a browser bundle, a mobile app or any public client.

Authentication

Pass the key explicitly or let the client read it from the environment:

client = Cotizave(api_key="ctz_live_...")  # explicit
client = Cotizave()  # from COTIZAVE_API_KEY

What you can do

Area Call
Rates of a country client.rates.list("CO")
One rate by id client.rates.get("CO", "co-trm")
Past board of a country client.rates.snapshot("AR", "2026-10-01")
Official rate of every country client.rates.global_(symbols=["BRL", "EUR"])
Convert one amount client.convert(from_="USD", to="BRL", amount=100)
Convert up to 50 amounts client.convert_bulk([...])
Point-in-time history client.history.get("CO", "co-trm", "2026-10-01")
Daily history series client.history.daily("AR", "ar-official", from_="2026-09-01", to="2026-09-30")
Period statistics client.history.stats("AR", "ar-official", from_="...", to="...", moving_average=7)
Raw captures (paginated) client.history.raw(...) / client.history.iterate(...)
History coverage client.history.limits()
Rate catalog client.markets("VE")
Spread vs another market client.spread("VE", against="ve-paralelo")
Best executable route client.route("VE", from_="USD", to="VES", amount=100)
Bank-published rates client.bank_rates("VE")
Countries / currencies client.countries.list() · client.currencies.list()
Banks / issuers client.banks.list("VE") · client.issuers.list()
Holidays & business days client.holidays.list("AR") · client.holidays.business_days("VE", from_="2026-10-01", days=5)
Stablecoins (USD) client.crypto.list() · client.crypto.get("usdt-usd")

Responses are plain dicts, typed with TypedDict for editor completion. The fields present depend on your plan, the country and the market — read them with .get(...) and check the API reference.

Iterating raw history safely

for point in client.history.iterate("VE", "ve-bcv", max_pages=10):
    print(point["date"], point.get("mid"))

iterate follows the server's cursors for you and stops at max_pages (default 50) so it never silently downloads an entire history.

Errors

Every failure raises a subclass of CotizaveError. Catch the base class for any API error, or a specific subclass for a family:

from cotizave import Cotizave, RateLimitError, NotFoundError, CotizaveError

client = Cotizave()
try:
    rate = client.rates.get("CO", "co-trm")
except RateLimitError as err:
    if err.is_quota_exhausted:
        print("Monthly quota exhausted")
    else:
        print(f"Slow down; retry after {err.retry_after}s")
except NotFoundError:
    print("No such rate")
except CotizaveError as err:
    print(err.status, err.code, err.message)
Exception HTTP
BadRequestError 400
AuthenticationError 401
FeatureNotInPlanError 402
ForbiddenError 403
NotFoundError 404
NotAcceptableError 406
UnprocessableError 422
RateLimitError 429
ServerError 5xx
APIConnectionError / APITimeoutError no response (network/timeout)

Each error carries status, code, message, optional field/details, and rate_limit / headers / request_id from the response.

Configuration

Everything has a production-safe default; override only what you need:

from cotizave import Cotizave, RetryOptions

client = Cotizave(
    api_key="ctz_live_...",
    timeout=5.0,  # per-request timeout, seconds
    history_timeout=10.0,  # longer timeout for history reads
    max_retries=2,  # extra retries for eligible requests
    max_retry_delay=10.0,  # total backoff budget per call, seconds
    max_response_bytes=25_000_000,
    language="es",  # Accept-Language for localized names
    headers={"X-Trace-Id": "..."},
    retry=RetryOptions(
        base_delay=0.25,
        max_delay=2.0,
        retry_rate_limited=True,
        on_retry=lambda e: print("retrying", e.path, "in", e.delay, "s"),
    ),
    on_response=lambda e: print(e.meta.status, e.meta.rate_limit.remaining),
)

Per-call overrides are accepted on every method (timeout, max_retries, headers, language):

client.rates.list("AR", timeout=2.0, max_retries=0)

Retry policy

Only idempotent (GET) requests are retried. A 429 is retried only when it is a burst (per-minute) limit, honoring the server's Retry-After; a 429 from an exhausted monthly quota is never retried. Connection and timeout errors, and the configured 5xx statuses, are retried with exponential backoff and full jitter, bounded by max_retries and the max_retry_delay budget.

Exporting CSV / XML

csv = client.export("/v2/fx/ar/rates", format="csv")

Low-level requests

For anything the typed resources don't cover, including conditional GETs and response metadata:

result = client.request(method="GET", path="/v2/fx/co/rates/co-trm", if_none_match='"abc"')
print(result.not_modified, result.meta.status, result.data)

Security

  • The API key is sent only as the X-API-Key header and is never exposed on client.config, in repr() or when logging the client.
  • Every request is pinned to the configured origin; a path that resolves to a different host is refused, and redirects are never followed — so the key cannot leak to another origin.
  • Response bodies are capped at max_response_bytes to guard against an oversized or decompression-bomb response.

Found a security issue? See SECURITY.md.

License

MIT

Metadata

Release files for cotizave 0.1.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 cotizave 0.1.0
File Size Uploaded Provenance Actions
cotizave-0.1.0.tar.gz 27.9 kB With provenance Details for cotizave-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cotizave 0.1.0
File Interpreter ABI Platform Actions
cotizave-0.1.0-py3-none-any.whl Python 3 none any Details for cotizave-0.1.0-py3-none-any.whl

Total release size: 60.5 kB

Release files / cotizave-0.1.0.tar.gz

Download URL cotizave-0.1.0.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
922a3b866c90fe249c523e7e4d5e4393d995b72dfaa5e8084f80d43060bf8a7a
BLAKE2b-256 checksum
How to use checksums
7777ff9da843af4aab51d9a206cbb8336a2d856626d80590e877d15cd947b283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 7, 2026.

Transparency log

Release files / cotizave-0.1.0-py3-none-any.whl

Download URL cotizave-0.1.0-py3-none-any.whl
Size 32.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c144677657620b85a41536158febb9a959b09bf5cc9cb8b5b21a25b10e72381
BLAKE2b-256 checksum
How to use checksums
fe463a96fa966f4cd238d9c308489fa6fa358a851d29383d86062e896760f052
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 7, 2026.

Transparency log

Security for cotizave 0.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cotizave-0.1.0.tar.gz

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 Nov 7, 2026.

Transparency log

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.1.0 This release

2 release files Full 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