Super-simple crypto price SDK with caching and retries (Alpha Vantage wrapper)
Project description
cryptoprice
A tiny Python SDK to get crypto prices in one line – with retries and a TTL cache. Wraps Alpha Vantage’s free API.
from cryptoprice import CryptoPrice
cp = CryptoPrice(api_key="YOUR_ALPHA_VANTAGE_KEY") # or set env ALPHAVANTAGE_API_KEY
print(cp.get_price("BTC")) # -> 61234.56 (USD by default)
Install
pip install cryptoprice-blockxai
Configure API key
Get a free API key from Alpha Vantage and either:
- Pass directly:
CryptoPrice(api_key="...") - Or set environment variable:
export ALPHAVANTAGE_API_KEY=...
Docs: https://www.alphavantage.co/documentation/
Why this exists
- Built-in retry-on-failure (including 429/503)
- Fast repeated calls via TTL cache (default 15s)
- Simple, production-ready interface
API
CryptoPrice(vs_currency="usd", ttl_seconds=15.0, api_key=None): sync clientget_price("BTC") -> float
CryptoPriceAsync(...).get_price("ETH") -> float: async variant
Notes
- Default
vs_currencyis USD. Override withvs_currency="EUR", etc. - Alpha Vantage endpoint used:
CURRENCY_EXCHANGE_RATE. - Respect free API rate limits. Keep a reasonable TTL in production.
Development
python -m venv .venv && . .venv/bin/activate
pip install -e .
pip install pytest respx
pytest
License
MIT
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 cryptoprice_blockxai-0.1.1.tar.gz.
File metadata
- Download URL: cryptoprice_blockxai-0.1.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cebc32910b8f0fb649c71b593cc6cb973fb6d8668ae9870a309bb863c7948c25
|
|
| MD5 |
50db8c766abf95b8c3ff8c546e8e38a7
|
|
| BLAKE2b-256 |
5a91f5e43bda1c559c5b8482fc4b05ea87e568ffc4a68af38fba82e7b5aec85c
|
File details
Details for the file cryptoprice_blockxai-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cryptoprice_blockxai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e81af4ef77d64101835d89b6ba04c1cda65d71dc027aa59cb71c9bf1f4cead57
|
|
| MD5 |
2947d82bf161cda29c961f8cfdcd7501
|
|
| BLAKE2b-256 |
6cc45369b92a12bffb6e1f3c54dd2b55bd603e0328d63a00600b1e044ffc3470
|