Skip to main content

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 client
    • get_price("BTC") -> float
  • CryptoPriceAsync(...).get_price("ETH") -> float: async variant

Notes

  • Default vs_currency is USD. Override with vs_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cryptoprice_blockxai-0.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

cryptoprice_blockxai-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

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

Hashes for cryptoprice_blockxai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cebc32910b8f0fb649c71b593cc6cb973fb6d8668ae9870a309bb863c7948c25
MD5 50db8c766abf95b8c3ff8c546e8e38a7
BLAKE2b-256 5a91f5e43bda1c559c5b8482fc4b05ea87e568ffc4a68af38fba82e7b5aec85c

See more details on using hashes here.

File details

Details for the file cryptoprice_blockxai-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for cryptoprice_blockxai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e81af4ef77d64101835d89b6ba04c1cda65d71dc027aa59cb71c9bf1f4cead57
MD5 2947d82bf161cda29c961f8cfdcd7501
BLAKE2b-256 6cc45369b92a12bffb6e1f3c54dd2b55bd603e0328d63a00600b1e044ffc3470

See more details on using hashes here.

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