Prefect 3 integration for UniRateAPI — real-time currency exchange rates, conversion, currency lists, and VAT rates as first-class Prefect tasks, wired up through a reusable credentials block.
pip install prefect-unirateRequires prefect >= 3.0.0 and Python 3.10+. Get a free API key at
https://unirateapi.com.
UniRateCredentials is a Prefect Block
that stores your API key (as a SecretStr) and builds a client.
Register the block type once, then save an instance you can reuse across flows:
prefect block register -m prefect_uniratefrom prefect_unirate import UniRateCredentials
UniRateCredentials(api_key="your-key").save("unirate")Load it anywhere with UniRateCredentials.load("unirate").
from prefect import flow
from prefect_unirate import (
UniRateCredentials,
get_exchange_rate,
convert_currency,
list_currencies,
get_vat_rates,
)
@flow
def fx() -> None:
creds = UniRateCredentials.load("unirate")
rate = get_exchange_rate(creds, "USD", "EUR") # 0.92
amount = convert_currency(creds, "EUR", 100, "USD") # 92.5
codes = list_currencies(creds) # ['USD', 'EUR', ...]
vat = get_vat_rates(creds, "DE") # {'country': 'DE', ...}| Task | Endpoint | Returns |
|---|---|---|
get_exchange_rate(creds, from_currency="USD", to_currency=None) |
/api/rates |
float, or {code: rate} when to_currency is omitted |
convert_currency(creds, to_currency, amount=1, from_currency="USD") |
/api/convert |
float, or {code: amount} |
list_currencies(creds) |
/api/currencies |
list[str] |
get_vat_rates(creds, country=None) |
/api/vat/rates |
dict |
Currency and country codes are uppercased automatically before being sent.
Every task raises a typed exception on failure (all subclass UnirateError):
| Status | Exception |
|---|---|
| 400 | InvalidDateError |
| 401 | AuthenticationError |
| 403 | APIError (status_code=403) — endpoint requires a Pro subscription |
| 404 | InvalidCurrencyError |
| 429 | RateLimitError |
| 503 | APIError (status_code=503) |
| network/transport | UnirateError |
Historical endpoints are Pro-gated and return 403 on the free tier.
A complete runnable flow lives at
examples/example_flow.py. It reads
UNIRATE_API_KEY from the environment.
pip install -e ".[test]"
pytestTests run against a temporary Prefect database via prefect_test_harness, with
the HTTP layer mocked by respx — no network access and no real Prefect server.
v0.1.0 — initial release. Credentials block + 4 tasks. 30+ mock tests.
UniRate ships official client libraries and framework integrations across the ecosystem. The repos below are all maintained under the UniRate-API org.
- Languages: Python · Node.js / TypeScript · Go · Rust · Java · Ruby · PHP · .NET · Swift
- Data / orchestration: Airflow · dbt · LangChain
- Web frameworks: FastAPI · Flask · Django / Wagtail · NestJS
- Workflow / no-code: n8n · Google Sheets · MCP server
Get a free API key at unirateapi.com.
MIT.
- UniRate API docs: https://unirateapi.com/docs
- Prefect integrations: https://docs.prefect.io/latest/integrations/
- Issues: https://github.com/UniRate-API/prefect-unirate/issues