rate-api-python
Official Python client for Rate-API.com. Standard library only — no dependencies. Python 3.8+.
Install
pip install rate-api-python
Usage
from rate_api import RateApiClient, RateApiError
client = RateApiClient("YOUR_API_KEY")
rates = client.latest("USD", ["EUR", "GBP"])
print(rates["rates"]["EUR"])
client.convert("USD", "EUR", 100) # Pro+
client.historical("2026-01-15", "USD", ["EUR"]) # Pro+
client.pair("USD", "EUR") # single pair
client.crypto(["BTC", "ETH"]) # Pro+
client.currencies() # supported currencies
client.usage() # current-month usage vs quota
client.health() # public
try:
client.convert("USD", "ZZZ", 100)
except RateApiError as e:
print(e, e.status) # "Invalid target currency" 400
Methods
latest · convert · pair · historical · crypto · currencies · usage · quota · health
Errors
Every failure raises RateApiError (or a subclass), so a single except RateApiError catches everything:
import time
from rate_api import RateApiClient, RateApiError, RateLimitError, RateApiTimeoutError
try:
client.latest("USD", ["EUR"])
except RateLimitError as e:
time.sleep(e.retry_after) # honour the server's backoff
except RateApiTimeoutError:
... # request exceeded `timeout`
except RateApiError as e:
print(e, e.status, e.type, e.request_id)
| Class | When | Extra attributes |
|---|---|---|
RateApiError |
any API/HTTP error | status (HTTP code; None on network/timeout), type (stable error.type slug), request_id (X-Request-Id — quote it when contacting support) |
RateLimitError |
HTTP 429 | retry_after (seconds to wait) |
RateApiTimeoutError |
request exceeded timeout |
— |
Configuration
RateApiClient(api_key, base_url="https://rate-api.com/api/v1", timeout=15, max_retries=2)
| Argument | Default | Notes |
|---|---|---|
base_url |
https://rate-api.com/api/v1 |
pass …/api/v2 to target v2 directly |
timeout |
15 |
per-request socket timeout in seconds (covers headers and body) |
max_retries |
2 |
automatically retries 429/503/network/timeout with exponential backoff, honouring the server's Retry-After header |
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rate_api_python-1.0.4.tar.gz
(5.4 kB
view details)
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 rate_api_python-1.0.4.tar.gz.
File metadata
- Download URL: rate_api_python-1.0.4.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6d396df297918932c202d324a37b8d1e5f26b72c0d06bcfc3eb81b946c24906
|
|
| MD5 |
51a60381c7ff05fc3d28f08030095754
|
|
| BLAKE2b-256 |
47e0b06db0b237bf3f1fc98c39c4e68b536bb2e3a61dcbf88ef90383402b564f
|
File details
Details for the file rate_api_python-1.0.4-py3-none-any.whl.
File metadata
- Download URL: rate_api_python-1.0.4-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a535d7ad5d397b2734aa2e8506d08925d99febcaf2089862f0edb9c82c58584c
|
|
| MD5 |
92a37abe56ef8ea80098b4dece217c57
|
|
| BLAKE2b-256 |
1619915da013674dc60b3f1b54055a3742748a6cc14a0ee8a6236b658c74ff86
|