Streamlit integration for the UniRate currency-exchange API — cached helpers with st.cache_resource and st.cache_data support.
Project description
streamlit-unirate
Streamlit integration for the UniRate API — live exchange rates, currency conversion, and VAT rates with automatic st.cache_data / st.cache_resource caching built in.
Installation
pip install streamlit-unirate
Quick start
import streamlit as st
import streamlit_unirate as ur
# List currencies (cached 1 h)
currencies = ur.list_currencies()
from_cur = st.selectbox("From", currencies)
to_cur = st.selectbox("To", currencies)
amount = st.number_input("Amount", value=100.0)
if st.button("Convert"):
result = ur.convert(to_cur, amount, from_cur)
st.metric(f"{amount} {from_cur} →", f"{result:.4f} {to_cur}")
API key
Set UNIRATE_API_KEY in .streamlit/secrets.toml (preferred) or as an environment variable:
# .streamlit/secrets.toml
UNIRATE_API_KEY = "your_api_key_here"
UNIRATE_API_KEY=your_key streamlit run app.py
Get a free key at unirateapi.com.
API reference
All functions use Streamlit's caching automatically — no extra decorators needed.
get_client(api_key=None, base_url=None)
Returns the underlying unirate.UnirateClient singleton (cached via @st.cache_resource). Use this when you need direct access to Pro endpoints such as historical rates or time series.
client = ur.get_client()
data = client.get_time_series("2025-01-01", "2025-01-31", base_currency="USD")
get_rate(from_currency="USD", to_currency=None) → float | dict
Current exchange rate. Cached for 5 minutes.
rate = ur.get_rate("USD", "EUR") # → 0.9214 (float)
all_rates = ur.get_rate("USD") # → {"EUR": 0.92, "GBP": 0.79, ...}
convert(to_currency, amount=1.0, from_currency="USD") → float
Convert an amount. Cached for 5 minutes.
eur = ur.convert("EUR", 250.0, "USD") # → 230.35
list_currencies() → list[str]
All supported currency codes. Cached for 1 hour.
codes = ur.list_currencies() # → ["AED", "AFN", ..., "ZWL"]
get_vat_rates(country=None) → dict
VAT rates for all countries or a single ISO-3166 country code. Cached for 24 hours.
all_vat = ur.get_vat_rates()
de_vat = ur.get_vat_rates("DE")
Error handling
All functions raise exceptions from unirate.exceptions:
| Exception | Cause |
|---|---|
AuthenticationError |
Missing or invalid API key |
RateLimitError |
Free-tier rate limit exceeded |
InvalidCurrencyError |
Unknown currency code |
APIError |
Other API error (check .status_code) |
from unirate.exceptions import RateLimitError, AuthenticationError
import streamlit_unirate as ur
try:
rate = ur.get_rate("USD", "EUR")
except AuthenticationError:
st.error("Check your UNIRATE_API_KEY.")
except RateLimitError:
st.warning("Rate limit hit — try again in a moment.")
Related UniRate clients
Other UniRate integrations: Python · Node.js · Go · Rust · Ruby · PHP · Java · Swift · .NET · FastAPI · Flask · Django REST · Wagtail · Next.js · Nuxt · SvelteKit · React · Vue · Angular · Remix · NestJS · LangChain (Python) · LangChain.js · Astro · Eleventy · Hugo · Jekyll · Strapi · Directus · Medusa · MCP Server · CLI
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 streamlit_unirate-0.1.0.tar.gz.
File metadata
- Download URL: streamlit_unirate-0.1.0.tar.gz
- Upload date:
- Size: 129.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c76e08f1015503f33bb285357bd06610f4f64f5262d905e8e4acdc6c30ff926
|
|
| MD5 |
a10b0f59aa5afd509a9732f4b40eee03
|
|
| BLAKE2b-256 |
a1de3c7d5b7ea5c28b1337730441f768c76a6e3c5c4ab8b7516a83f7dd59f5c5
|
Provenance
The following attestation bundles were made for streamlit_unirate-0.1.0.tar.gz:
Publisher:
release.yml on UniRate-API/streamlit-unirate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_unirate-0.1.0.tar.gz -
Subject digest:
7c76e08f1015503f33bb285357bd06610f4f64f5262d905e8e4acdc6c30ff926 - Sigstore transparency entry: 2135913797
- Sigstore integration time:
-
Permalink:
UniRate-API/streamlit-unirate@cb8e80c42dafff844c0eb11fecdd726265bbf259 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/UniRate-API
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cb8e80c42dafff844c0eb11fecdd726265bbf259 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file streamlit_unirate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_unirate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81fc85b08fcdfdeb2e55020bcd68cf5099951097c0e6e82d7d6523fdc80a4e22
|
|
| MD5 |
d7ef7188a34c792b078d341b84ef8171
|
|
| BLAKE2b-256 |
adaae90a0ca71dd1acd56b5b68fd5ed9a62a0ddee1bde24cd5bbc85b6161e555
|
Provenance
The following attestation bundles were made for streamlit_unirate-0.1.0-py3-none-any.whl:
Publisher:
release.yml on UniRate-API/streamlit-unirate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_unirate-0.1.0-py3-none-any.whl -
Subject digest:
81fc85b08fcdfdeb2e55020bcd68cf5099951097c0e6e82d7d6523fdc80a4e22 - Sigstore transparency entry: 2135914043
- Sigstore integration time:
-
Permalink:
UniRate-API/streamlit-unirate@cb8e80c42dafff844c0eb11fecdd726265bbf259 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/UniRate-API
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cb8e80c42dafff844c0eb11fecdd726265bbf259 -
Trigger Event:
workflow_dispatch
-
Statement type: