Skip to main content

dlt (dltHub) source for the UniRate currency-exchange API — load live exchange rates, supported currencies, and VAT rates into any dlt destination.

Project description

dlt-unirate

PyPI License: MIT

A dlt source for the UniRate API — load live currency exchange rates, the supported-currency list, and per-country VAT rates into any dlt destination (DuckDB, BigQuery, Snowflake, Postgres, filesystem, …).

UniRate provides 593+ fiat, crypto, and commodity exchange rates. Latest rates, currencies, and VAT rates are available on the free tier; historical rates require a Pro plan.

Why this package

dlt has no built-in FX source, so people hand-roll a requests loop or a rest_api config every time they need exchange rates in a warehouse. This package gives you a typed, tested @dlt.source with three resources you can drop straight into a pipeline.

Install

pip install dlt-unirate

This pulls in dlt and requests. Add a destination extra for your target, e.g. pip install "dlt[duckdb]".

Quick start

import dlt
from dlt_unirate import unirate_source

pipeline = dlt.pipeline(
    pipeline_name="unirate",
    destination="duckdb",
    dataset_name="unirate_data",
)

# api_key resolves from dlt secrets / the UNIRATE_API_KEY env var,
# or pass it explicitly: unirate_source(api_key="...").
load_info = pipeline.run(unirate_source(base_currency="USD"))
print(load_info)

That loads three tables: exchange_rates, currencies, and vat_rates.

Configuring the API key

unirate_source follows dlt's config/secrets convention. Any of these work:

  • Env var: export UNIRATE_API_KEY="..."

  • dlt secrets.dlt/secrets.toml:

    [sources.unirate]
    api_key = "..."
    
  • Explicit argument: unirate_source(api_key="...")

Get a free key at unirateapi.com.

Resources

Resource Table columns Notes
exchange_rates base_currency, target_currency, rate Every current rate for base_currency. write_disposition="replace".
currencies currency_code All supported currency codes. replace.
vat_rates country_code, country_name, vat_rate Per-country VAT rates. replace.
historical_exchange_rates date, base_currency, target_currency, rate Pro-gated — off by default. merge on (date, base, target).

Source parameters

Parameter Default Description
api_key dlt secret / UNIRATE_API_KEY UniRate API key.
base_currency "USD" Base for exchange_rates (and historical).
base_url https://api.unirateapi.com API base URL.
request_timeout 30 Per-request timeout, seconds.
include_historical False Also yield the Pro-gated historical resource.
historical_dates None YYYY-MM-DD dates to pull historical rates for.

Historical rates (Pro)

source = unirate_source(
    base_currency="EUR",
    include_historical=True,
    historical_dates=["2024-01-01", "2024-02-01"],
)
pipeline.run(source)

Historical endpoints return HTTP 403 on the free tier (surfaced as ProSubscriptionError); a UniRate Pro plan is required.

Selecting a subset of resources

# Only load exchange rates and currencies.
pipeline.run(unirate_source().with_resources("exchange_rates", "currencies"))

Error handling

Errors raised by the underlying client all inherit from UniRateError:

HTTP Exception
401 AuthenticationError
403 ProSubscriptionError
404 InvalidCurrencyError
429 RateLimitError
other non-2xx APIError (carries status_code)
network / transport UniRateError

Related UniRate clients

If you want to call the API directly, there are official clients in Python, Node.js, Go, Rust, Java, Ruby, PHP, .NET, and Swift, plus data-stack integrations for dbt, Airflow, and LangChain.

License

MIT — see LICENSE.

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

dlt_unirate-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

dlt_unirate-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file dlt_unirate-0.1.0.tar.gz.

File metadata

  • Download URL: dlt_unirate-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for dlt_unirate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 98474e64567be6364f83b215765a72cd0dccaa3c89d9225147056ae203db95ea
MD5 78bdad7211cab03249d608d2f3fbb2ea
BLAKE2b-256 d64c8620b839090cd57b7802faf220708a58d513741c3108f997aa5acb59d792

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlt_unirate-0.1.0.tar.gz:

Publisher: release.yml on UniRate-API/dlt-unirate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dlt_unirate-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dlt_unirate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for dlt_unirate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cafbbdaca94191c6234e03d7ea2767bf6c6a4c01b9611310648ff39ef9394081
MD5 5971ee0bfdd3315b5dde386040e879b9
BLAKE2b-256 4ba0dd21dbbafbb1f5836398ef64bfbb7a8eb96b0e3ec2ae193f08c35c9cd7fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlt_unirate-0.1.0-py3-none-any.whl:

Publisher: release.yml on UniRate-API/dlt-unirate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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