MCPcopy Create free account
hub / github.com/decodableco/examples / poll

Function poll

kafka2s3/crypto.py:14–22  ·  view source on GitHub ↗
(producer, topic)

Source from the content-addressed store, hash-verified

12import json
13
14def poll(producer, topic):
15 url = "https://api.nomics.com/v1/currencies/ticker?key={}&ids=BTC,ETH,XRP,DOGE,SHIB,BCH,BSV,LINK,LTC&interval=1d,30d&per-page=1000&page=1".format(os.getenv("NOMIC_API_KEY"))
16 msgs = json.loads(urllib.request.urlopen(url).read())
17
18 for msg in msgs:
19 print(json.dumps(msg))
20 key=bytes(msg['id'].encode('utf-8'))
21 producer.send(topic, key=key, value=msg)
22 producer.flush()
23
24
25def main():

Callers 1

mainFunction · 0.70

Calls 2

flushMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected