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
Stocks, metals and key status (Pro plan and up)
client.stocks(["AAPL", "MSFT"]) # latest closes, USD
client.metals(["XAU", "XAG"]) # per troy ounce, USD
client.status() # is this key still good?
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.1.0.tar.gz
(5.6 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.1.0.tar.gz.
File metadata
- Download URL: rate_api_python-1.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d54d9f065a1f48ef0de71eccc0bf81d486bcbfea45dd80fb88a58dea060fb44
|
|
| MD5 |
2b711138e6a9e4c49e5c13543d0327f2
|
|
| BLAKE2b-256 |
3bb83ae5dbba0037e38c504304cba8511081463d5da0acc196fac05a0609a138
|
File details
Details for the file rate_api_python-1.1.0-py3-none-any.whl.
File metadata
- Download URL: rate_api_python-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
515c18415e47f4c20cbba8dcb771e087a7358621510a80f49375bbda4fafd53e
|
|
| MD5 |
7000bd66f5cd874c0e4c4faa2a8f9ac1
|
|
| BLAKE2b-256 |
3cfd81a0881b20d61403e46a49d3557cc44ba48a0fd2423988cc9a04f4797da3
|