xratesapi
Official Python SDK for the XRates exchange rate API.
Python 3.9+, built on httpx.
Install
pip install xratesapi
Quick start
from xratesapi import Client
client = Client("YOUR_API_KEY")
print(client.latest(base="USD", symbols=["EUR", "GBP"]))
print(client.convert("USD", "EUR", 100))
The client is also a context manager:
with Client("YOUR_API_KEY") as client:
rates = client.latest()
Methods
| Method | Endpoint |
|---|---|
latest(base="USD", symbols=None) |
GET /api/v1/latest |
historical(date, base="USD", symbols=None) |
GET /api/v1/{YYYY-MM-DD} |
convert(from_, to, amount, date=None) |
GET /api/v1/convert |
timeseries(start_date, end_date, base="USD", symbols=None) |
GET /api/v1/timeseries |
fluctuation(start_date, end_date, base="USD", symbols=None) |
GET /api/v1/fluctuation |
currencies() |
GET /api/v1/currencies |
status() |
GET /api/v1/status |
Error handling
from xratesapi import (
Client,
ApiError,
AuthenticationError,
RateLimitError,
ValidationError,
)
try:
client.latest(base="XXX")
except AuthenticationError:
... # 401 / 403
except RateLimitError:
... # 429 — back off
except ValidationError as e:
print(e.payload) # raw response body
except ApiError as e:
print(e.status, e)
Configuration
import httpx
from xratesapi import Client
# Custom timeout / base URL
client = Client("KEY", base_url="https://xratesapi.com", timeout=30.0)
# Or inject your own httpx.Client (retries, proxies, transport, ...)
http = httpx.Client(timeout=30.0, transport=httpx.HTTPTransport(retries=3))
client = Client("KEY", http_client=http)
License
MIT
Metadata
Release files for xratesapi 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 | Provenance | Actions |
|---|---|---|---|---|
| xratesapi-0.1.0.tar.gz | 5.6 kB | Without provenance | Details for xratesapi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xratesapi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for xratesapi-0.1.0-py3-none-any.whl |
Total release size: 11.3 kB
Release files / xratesapi-0.1.0.tar.gz
| Download URL | xratesapi-0.1.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd1e866ef7c9ef52fc0deb1a4601f52b150e0cd4bbd4d6e5d68b4ef9cfd9c872
|
|
BLAKE2b-256 checksum How to use checksums |
d44974c79ccab44acefbe24bd2819b68af9fd0832f8acbead2243c9da1c899f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / xratesapi-0.1.0-py3-none-any.whl
| Download URL | xratesapi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc376ff8d2f4bb716e5e93a5b295e69105fbaca9599ec968183fbf02d5cf3d88
|
|
BLAKE2b-256 checksum How to use checksums |
b32dac28fd3760e2d3caf483b239f66e88f8fb044e3adce99a0f10ef1339e757
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for xratesapi 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.
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.