Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import requests
import boto3
import uuid
import time
import json
client = boto3.client('kinesis', region_name='eu-central-1')
partition_key = str(uuid.uuid4())
def send_data_record(crypto="BTC"):
base_url = "https://min-api.cryptocompare.com/data"
r = requests.get(f"{base_url}/price?fsym={crypto}&tsyms=USD")
data = r.json()
data["timestamp"] = str(int(time.time()))
data["crypto"] = crypto
result = client.put_record(StreamName="crypto_prices",
Data=json.dumps(data),
PartitionKey=crypto)
print(result)
while True:
send_data_record("BTC")
send_data_record("ETH")
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment