prefect-unirate
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.
Install
pip install prefect-unirate
Requires prefect >= 3.0.0 and Python 3.10+. Get a free API key at
https://unirateapi.com.
Credentials
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_unirate
from prefect_unirate import UniRateCredentials
UniRateCredentials(api_key="your-key").save("unirate")
Load it anywhere with UniRateCredentials.load("unirate").
Tasks
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.
Error handling
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.
Example flow
A complete runnable flow lives at
examples/example_flow.py. It reads
UNIRATE_API_KEY from the environment.
Testing
pip install -e ".[test]"
pytest
Tests 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.
Status
v0.1.0 — initial release. Credentials block + 4 tasks. 30+ mock tests.
Other UniRate clients
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.
License
MIT.
Links
- UniRate API docs: https://unirateapi.com/docs
- Prefect integrations: https://docs.prefect.io/latest/integrations/
- Issues: https://github.com/UniRate-API/prefect-unirate/issues
Release files for prefect-unirate 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 | |
|---|---|---|---|
| prefect_unirate-0.1.0.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prefect_unirate-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.4 kB
Release files / prefect_unirate-0.1.0.tar.gz
| Download URL | prefect_unirate-0.1.0.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
988eb4888c8dfa92450fb284390a95cc6e4ca8528cffb646a68c7aa7393f109e
|
|
BLAKE2b-256 checksum How to use checksums |
df38bbff71a9b58b6312dd8541cd2c982526d4ba1574e590fcb4ff5dc0004168
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency logRelease files / prefect_unirate-0.1.0-py3-none-any.whl
| Download URL | prefect_unirate-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c159076af4eed3c23c3cb1053004a1a7e453b16e93a94bd43a5550ba8580fd6c
|
|
BLAKE2b-256 checksum How to use checksums |
4a0ef27f566a07f3a7337d8e5a7481df86fe101076ace81727a78721363571a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.
Transparency log