A simple CoinmarketCap API for getting cryptocurrency prices and data
Project description
RealTimeCrypto
Get crypto prices and coin data from CoinmarketCap, using a simple API.
Installation
The easiest way to install the latest version from PyPI is by using pip:
pip install realtime-crypto
Alternatively, install directly from the GitHub repository:
pip install git+https://github.com/SanderSita/realtime-crypto-prices.git
Usage
from realtime-crypto import RealTimeCrypto
import asyncio
tracker = RealTimeCrypto()
# Get bitcoin price
bitcoin = tracker.get_coin("bitcoin")
price = bitcoin.get_price()
print(price)
# Get price history
bitcoin.get_history("1Y")
# Get ethereum stats
eth = tracker.get_coin("ethereum")
high24h = eth.get_statistics().high24h
eth_1h = eth.get_statistics().get_price_change("1h")
eth_24h = eth.get_statistics().get_price_change("24h")
eth_1y = eth.get_statistics().get_price_change("1y")
# Get fear and greed index
tracker.get_current_fear_greed_index()
# Get best performing cryptos
tracker.get_best_performing_cryptos("24h")
# Get realtime crypto prices
async def main():
async def callback(data):
new_price = data.get_new_price()
name = ws_detail.get_crypto()
print(f"{name}: {new_price}")
# Track bitcoin price
bitcoin = tracker.get_coin("bitcoin")
asyncio.create_task(bitcoin.get_realtime_price(callback))
# Track multiple coins
coins = ["ethereum", "dogecoin", "pepe"]
asyncio.create_task(tracker.realtime_prices(coins, callback))
# Ensure script doesn't close
await asyncio.sleep(1000)
asyncio.run(main())
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
realtime_crypto-0.0.1.tar.gz
(8.8 kB
view details)
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 realtime_crypto-0.0.1.tar.gz.
File metadata
- Download URL: realtime_crypto-0.0.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
567d9d4b61c70a0bac0177976f3a43a6554b4f6baa231852e8c2b54aadd9507f
|
|
| MD5 |
8436455944dc905baa6cdcfd7acaf456
|
|
| BLAKE2b-256 |
22fb1e3f4d7d267b0c112d015e9b8609696ebf1e596532eaddcdc4a84e0fef75
|
File details
Details for the file realtime_crypto-0.0.1-py3-none-any.whl.
File metadata
- Download URL: realtime_crypto-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
956950a96435da18ab18fbc6106bdb480b271d524350a6e1a2b49a39f8991916
|
|
| MD5 |
ab18684b9185cd654c8cbec7ac73bf08
|
|
| BLAKE2b-256 |
93b11384bb30692907529190365a62e583d6194987b34b465a03cade1f2bd080
|