Skip to content

Commit a35bb3c

Browse files
authored
feat(info): add extra agents info method (#206)
1 parent a1fca2a commit a35bb3c

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

hyperliquid/info.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,27 @@ def user_rate_limit(self, user: str) -> Any:
733733
def query_spot_deploy_auction_status(self, user: str) -> Any:
734734
return self.post("/info", {"type": "spotDeployState", "user": user})
735735

736+
def extra_agents(self, user: str) -> Any:
737+
"""Retrieve extra agents associated with a user.
738+
739+
POST /info
740+
741+
Args:
742+
user (str): Onchain address in 42-character hexadecimal format;
743+
e.g. 0x0000000000000000000000000000000000000000.
744+
745+
Returns:
746+
[
747+
{
748+
"name": str,
749+
"address": str,
750+
"validUntil": int
751+
},
752+
...
753+
]
754+
"""
755+
return self.post("/info", {"type": "extraAgents", "user": user})
756+
736757
def _remap_coin_subscription(self, subscription: Subscription) -> None:
737758
if (
738759
subscription["type"] == "l2Book"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
interactions:
2+
- request:
3+
body: '{"type": "extraAgents", "user": "0xd42f2bB0e06455eDB652e27b7374FC2bDa8448ee"}'
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
Content-Length:
12+
- '77'
13+
Content-Type:
14+
- application/json
15+
User-Agent:
16+
- python-requests/2.32.3
17+
method: POST
18+
uri: https://api.hyperliquid.xyz/info
19+
response:
20+
body:
21+
string: '[{"name":"ok","address":"0x286edfa08c04f6899dab3bfdecf2dd133f9733b9","validUntil":1767776120478},{"name":"new","address":"0xc06e6617005c1888aeb8b3017fe00f82b7b84fc0","validUntil":1771174068515}]'
22+
headers:
23+
Connection:
24+
- keep-alive
25+
Content-Length:
26+
- '194'
27+
Content-Type:
28+
- application/json
29+
Date:
30+
- Thu, 04 Sep 2025 13:52:30 GMT
31+
Server:
32+
- nginx/1.22.1
33+
Via:
34+
- 1.1 a5613e7afb4b10039b3efde5527e95c2.cloudfront.net (CloudFront)
35+
X-Amz-Cf-Id:
36+
- yc2KyjT9MRCS_a0SdoUv_9O1CH3UFOcK0Mik61PTbLkaVvCt4pFmHg==
37+
X-Amz-Cf-Pop:
38+
- IAD61-P5
39+
X-Cache:
40+
- Miss from cloudfront
41+
access-control-allow-origin:
42+
- '*'
43+
access-control-expose-headers:
44+
- '*'
45+
vary:
46+
- origin
47+
- access-control-request-method
48+
- access-control-request-headers
49+
status:
50+
code: 200
51+
message: OK
52+
version: 1

tests/info_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,16 @@ def test_delegator_history():
244244
assert "delta" in event, "Each event should have a 'delta' field"
245245
assert "hash" in event, "Each event should have a transaction 'hash'"
246246
assert "time" in event, "Each event should have a 'time' field"
247+
248+
249+
@pytest.mark.vcr()
250+
def test_extra_agents():
251+
info = Info(skip_ws=True, meta=TEST_META, spot_meta=TEST_SPOT_META)
252+
response = info.extra_agents(user="0xd42f2bB0e06455eDB652e27b7374FC2bDa8448ee")
253+
assert isinstance(response, list), "The response should be a list"
254+
# Extra agents should contain agent information
255+
assert len(response) > 0, "The response should contain at least one agent"
256+
for agent in response:
257+
assert "name" in agent, "Each agent should have a 'name' field"
258+
assert "address" in agent, "Each agent should have an 'address' field"
259+
assert "validUntil" in agent, "Each agent should have a 'validUntil' field"

0 commit comments

Comments
 (0)