forked from flare-foundation/developer-hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_anchor_feeds.py
More file actions
41 lines (32 loc) · 1.07 KB
/
fetch_anchor_feeds.py
File metadata and controls
41 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# THIS IS EXAMPLE CODE. DO NOT USE THIS CODE IN PRODUCTION.
import asyncio
import aiohttp
BASE_URL = "https://flr-data-availability.flare.network/"
API_KEY = "<your-api-key>"
FEED_IDS = [
"0x01464c522f55534400000000000000000000000000", # FLR/USD
"0x014254432f55534400000000000000000000000000", # BTC/USD
"0x014554482f55534400000000000000000000000000", # ETH/USD
]
async def fetch_anchor_feeds(
feed_ids: list[str], voting_round_id: int | None = None
) -> list[dict]:
url = f"{BASE_URL}api/v0/ftso/anchor-feeds-with-proof"
if voting_round_id:
url += f"?voting_round_id={voting_round_id}"
async with (
aiohttp.ClientSession() as session,
session.post(
url,
headers={
"X-API-KEY": API_KEY,
"Content-Type": "application/json",
},
json={"feed_ids": feed_ids},
) as response,
):
return await response.json()
async def main() -> None:
data = await fetch_anchor_feeds(FEED_IDS)
print("Anchor feeds data:", data)
asyncio.run(main())