Skip to content

Commit e43c218

Browse files
authored
Switch to the Hermes v2 API (#79)
1 parent 95f890c commit e43c218

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pyth_observer/crosschain.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ async def get_crosschain_prices(self) -> Dict[str, CrosschainPrice]:
3232
async with ClientSession(
3333
headers={"content-type": "application/json"}
3434
) as session:
35-
price_feed_ids_url = f"{self.url}/api/price_feed_ids"
35+
price_feeds_index_url = f"{self.url}/v2/price_feeds"
3636

37-
async with session.get(price_feed_ids_url) as response:
38-
price_feed_ids = await response.json()
37+
async with session.get(price_feeds_index_url) as response:
38+
price_feeds_index = await response.json()
3939

4040
price_feeds = []
4141

42-
for ids in chunked(price_feed_ids, 25):
43-
price_feeds_url = f"{self.url}/api/latest_price_feeds"
42+
for feeds in chunked(price_feeds_index, 25):
43+
price_feeds_url = f"{self.url}/v2/updates/price/latest"
4444

4545
# aiohttp does not support encoding array params using PHP-style `ids=[]`
4646
# naming, so we encode it manually and append to the URL.
47-
query_string = "?" + "&".join(f"ids[]={v}" for v in ids)
47+
query_string = "?" + "&".join(f"ids[]={v['id']}" for v in feeds)
4848
async with session.get(
4949
price_feeds_url + query_string,
5050
) as response:

0 commit comments

Comments
 (0)