Skip to main content

Official Python client for the Rate-API.com exchange-rate & crypto API

Project description

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

Project details


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.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rate_api_python-1.0.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file rate_api_python-1.0.3.tar.gz.

File metadata

  • Download URL: rate_api_python-1.0.3.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for rate_api_python-1.0.3.tar.gz
Algorithm Hash digest
SHA256 c6ce2d7485b171a3ee6e13b32be732ad256d3f0cc725d49e75988387fee2c6c1
MD5 44765b2828814b4a297e0c1c09b252e1
BLAKE2b-256 b29ac7f49e27555b70d751a09d8fc2644221e5c5216bc350ac92b62bcb4cbd41

See more details on using hashes here.

File details

Details for the file rate_api_python-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for rate_api_python-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 568d2a0874cba76d068a46eee6f79ecd7d1513da47b23de0dc053090928c651e
MD5 440733fff3b6883d786d033837401a84
BLAKE2b-256 3c02ff66c7a3d80fbd649f6eaea8dd042e8d9bf124ae840764969aab583e51f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page