Skip to content
118 changes: 118 additions & 0 deletions hyperliquid/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,20 @@ def user_staking_rewards(self, address: str) -> Any:
"""
return self.post("/info", {"type": "delegatorRewards", "user": address})

def delegator_history(self, user: str) -> Any:
"""Retrieve comprehensive staking history for a user.
POST /info
Args:
user (str): Onchain address in 42-character hexadecimal format.
Returns:
Comprehensive staking history including delegation and undelegation
events with timestamps, transaction hashes, and detailed delta information.
"""
return self.post("/info", {"type": "delegatorHistory", "user": user})

def query_order_by_oid(self, user: str, oid: int) -> Any:
return self.post("/info", {"type": "orderStatus", "user": user, "oid": oid})

Expand All @@ -612,6 +626,110 @@ def query_user_to_multi_sig_signers(self, multi_sig_user: str) -> Any:
def query_perp_deploy_auction_status(self) -> Any:
return self.post("/info", {"type": "perpDeployAuctionStatus"})

def historical_orders(self, user: str) -> Any:
"""Retrieve a user's historical orders.
POST /info
Args:
user (str): Onchain address in 42-character hexadecimal format;
e.g. 0x0000000000000000000000000000000000000000.
Returns:
Returns at most 2000 most recent historical orders with their current
status and detailed order information.
"""
return self.post("/info", {"type": "historicalOrders", "user": user})

def user_non_funding_ledger_updates(self, user: str, startTime: int, endTime: Optional[int] = None) -> Any:
"""Retrieve non-funding ledger updates for a user.
POST /info
Args:
user (str): Onchain address in 42-character hexadecimal format.
startTime (int): Start time in milliseconds (epoch timestamp).
endTime (Optional[int]): End time in milliseconds (epoch timestamp).
Returns:
Comprehensive ledger updates including deposits, withdrawals, transfers,
liquidations, and other account activities excluding funding payments.
"""
return self.post(
"/info",
{"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime, "endTime": endTime},
)

def portfolio(self, user: str) -> Any:
"""Retrieve comprehensive portfolio performance data.
POST /info
Args:
user (str): Onchain address in 42-character hexadecimal format.
Returns:
Comprehensive portfolio performance data across different time periods,
including account value history, PnL history, and volume metrics.
"""
return self.post("/info", {"type": "portfolio", "user": user})

def user_twap_slice_fills(self, user: str) -> Any:
"""Retrieve a user's TWAP slice fills.
POST /info
Args:
user (str): Onchain address in 42-character hexadecimal format.
Returns:
Returns at most 2000 most recent TWAP slice fills with detailed
execution information.
"""
return self.post("/info", {"type": "userTwapSliceFills", "user": user})

def user_vault_equities(self, user: str) -> Any:
"""Retrieve user's equity positions across all vaults.
POST /info
Args:
user (str): Onchain address in 42-character hexadecimal format.
Returns:
Detailed information about user's equity positions across all vaults
including current values, profit/loss metrics, and withdrawal details.
"""
return self.post("/info", {"type": "userVaultEquities", "user": user})

def user_role(self, user: str) -> Any:
"""Retrieve the role and account type information for a user.
POST /info
Args:
user (str): Onchain address in 42-character hexadecimal format.
Returns:
Role and account type information including account structure,
permissions, and relationships within the Hyperliquid ecosystem.
"""
return self.post("/info", {"type": "userRole", "user": user})

def user_rate_limit(self, user: str) -> Any:
"""Retrieve user's API rate limit configuration and usage.
POST /info
Args:
user (str): Onchain address in 42-character hexadecimal format.
Returns:
Detailed information about user's API rate limit configuration
and current usage for managing API usage and avoiding rate limiting.
"""
return self.post("/info", {"type": "userRateLimit", "user": user})

def query_spot_deploy_auction_status(self, user: str) -> Any:
return self.post("/info", {"type": "spotDeployState", "user": user})

Expand Down
52 changes: 52 additions & 0 deletions tests/cassettes/info_test/test_delegator_history.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
interactions:
- request:
body: '{"type": "delegatorHistory", "user": "0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036"}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '82'
Content-Type:
- application/json
User-Agent:
- python-requests/2.32.3
method: POST
uri: https://api.hyperliquid.xyz/info
response:
body:
string: '[{"time":1751382238782,"hash":"0xaea14981ae79c88826b104269e1e61020161008a69327e1bd0716a870eb0032e","delta":{"delegate":{"validator":"0xb8f45222a3246a2b0104696a1df26842007c5bc5","amount":"89968.0","isUndelegate":false}}},{"time":1751382217852,"hash":"0xa41a74f16345b8b0ba4e04269e1d5d018200756676283eee1bbc9d4e86d0d942","delta":{"cDeposit":{"amount":"89968.0"}}},{"time":1746636092325,"hash":"0x1520bf77c0dae738c8130422ff52cf01cc00f7c6f145792f2eeca62d178cd048","delta":{"delegate":{"validator":"0xb8f45222a3246a2b0104696a1df26842007c5bc5","amount":"10000.1","isUndelegate":false}}},{"time":1746636051729,"hash":"0x88f45bda40a6b572ef230422ff50cf01e20075ab01e3a48566ea9979a7ac6313","delta":{"cDeposit":{"amount":"10000.1"}}}]'
headers:
Connection:
- keep-alive
Content-Length:
- '721'
Content-Type:
- application/json
Date:
- Fri, 22 Aug 2025 11:45:24 GMT
Server:
- nginx/1.22.1
Via:
- 1.1 628e5146add9b3daeb91ab8792398818.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- B6JLp5pY_ZwV5Maq5tZMTGwlfJSngY7VdiQZMSn9iMwnWap6HroQEg==
X-Amz-Cf-Pop:
- FRA60-P5
X-Cache:
- Miss from cloudfront
access-control-allow-origin:
- '*'
access-control-expose-headers:
- '*'
vary:
- origin
- access-control-request-method
- access-control-request-headers
status:
code: 200
message: OK
version: 1
76 changes: 76 additions & 0 deletions tests/cassettes/info_test/test_historical_orders.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
interactions:
- request:
body: '{"type": "historicalOrders", "user": "0x31ca8395cf837de08b24da3f660e77761dfb974b"}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '82'
Content-Type:
- application/json
User-Agent:
- python-requests/2.32.3
method: POST
uri: https://api.hyperliquid.xyz/info
response:
body:
string: '[{"order": {"coin": "TON", "side": "B", "limitPx": "3.2502", "sz":
"81.7", "oid": 141682155424, "timestamp": 1755863118217, "triggerCondition":
"N/A", "isTrigger": false, "triggerPx": "0.0", "children": [], "isPositionTpsl":
false, "reduceOnly": false, "orderType": "Limit", "origSz": "81.7", "tif":
"Ioc", "cloid": null}, "status": "iocCancelRejected", "statusTimestamp": 1755863118217},
{"order": {"coin": "ORDI", "side": "B", "limitPx": "8.6328", "sz": "3.15",
"oid": 141682155423, "timestamp": 1755863118217, "triggerCondition": "N/A",
"isTrigger": false, "triggerPx": "0.0", "children": [], "isPositionTpsl":
false, "reduceOnly": false, "orderType": "Limit", "origSz": "3.15", "tif":
"Ioc", "cloid": null}, "status": "iocCancelRejected", "statusTimestamp": 1755863118217},
{"order": {"coin": "GRIFFAIN", "side": "B", "limitPx": "0.035057", "sz": "529.0",
"oid": 141682155422, "timestamp": 1755863118217, "triggerCondition": "N/A",
"isTrigger": false, "triggerPx": "0.0", "children": [], "isPositionTpsl":
false, "reduceOnly": false, "orderType": "Limit", "origSz": "529.0", "tif":
"Ioc", "cloid": null}, "status": "iocCancelRejected", "statusTimestamp": 1755863118217},
{"order": {"coin": "DYDX", "side": "B", "limitPx": "0.62613", "sz": "1500.3",
"oid": 141682147400, "timestamp": 1755863117780, "triggerCondition": "N/A",
"isTrigger": false, "triggerPx": "0.0", "children": [], "isPositionTpsl":
false, "reduceOnly": false, "orderType": "Limit", "origSz": "1500.3", "tif":
"Alo", "cloid": null}, "status": "canceled", "statusTimestamp": 1755863118217},
{"order": {"coin": "DYDX", "side": "B", "limitPx": "0.62689", "sz": "1614.3",
"oid": 141682147399, "timestamp": 1755863117780, "triggerCondition": "N/A",
"isTrigger": false, "triggerPx": "0.0", "children": [], "isPositionTpsl":
false, "reduceOnly": false, "orderType": "Limit", "origSz": "1614.3", "tif":
"Alo", "cloid": null}, "status": "canceled", "statusTimestamp": 1755863118217}]'
headers:
Connection:
- keep-alive
Content-Length:
- '689574'
Content-Type:
- application/json
Date:
- Fri, 22 Aug 2025 11:45:18 GMT
Server:
- nginx/1.22.1
Via:
- 1.1 72500140cb63ff2dee8b57e4476902e6.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- JXelN_TiQqwyxr7GLuIrTUgS_CQKdomVFn3rF6_0bRtf0mUiv0U1Ag==
X-Amz-Cf-Pop:
- FRA60-P5
X-Cache:
- Miss from cloudfront
access-control-allow-origin:
- '*'
access-control-expose-headers:
- '*'
vary:
- origin
- access-control-request-method
- access-control-request-headers
status:
code: 200
message: OK
version: 1
52 changes: 52 additions & 0 deletions tests/cassettes/info_test/test_portfolio.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
interactions:
- request:
body: '{"type": "userNonFundingLedgerUpdates", "user": "0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036",
"startTime": 1681923833000, "endTime": 1682010233000}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '147'
Content-Type:
- application/json
User-Agent:
- python-requests/2.32.3
method: POST
uri: https://api.hyperliquid.xyz/info
response:
body:
string: '[]'
headers:
Connection:
- keep-alive
Content-Length:
- '2'
Content-Type:
- application/json
Date:
- Fri, 22 Aug 2025 11:45:20 GMT
Server:
- nginx/1.22.1
Via:
- 1.1 bc841916063a49c638b48e73f77a28e8.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- D8Oa1RQKRIe6INTVcGG14k0D09p8YP-IFdUOAeppzsojGT-ojYedOA==
X-Amz-Cf-Pop:
- FRA60-P5
X-Cache:
- Miss from cloudfront
access-control-allow-origin:
- '*'
access-control-expose-headers:
- '*'
vary:
- origin
- access-control-request-method
- access-control-request-headers
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
interactions:
- request:
body: '{"type": "userNonFundingLedgerUpdates", "user": "0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036",
"startTime": 1681923833000, "endTime": null}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '138'
Content-Type:
- application/json
User-Agent:
- python-requests/2.32.3
method: POST
uri: https://api.hyperliquid.xyz/info
response:
body:
string: '[{"time": 1731999196516, "hash": "0x09ddd9f712b5df0945af34b055bbb3329c88ca001aff41bbfd4341d80bc760ce",
"delta": {"type": "deposit", "usdc": "2703997.4500000002"}}, {"time": 1732834706761,
"hash": "0x1ddfe341d6a65a05392a0417f410fd014100a311417ccf11da13fcddea1429c9",
"delta": {"type": "accountClassTransfer", "usdc": "12.0", "toPerp": false}},
{"time": 1732834825313, "hash": "0x2ceac78e94d15a1af8660417f418400175003b84f5f2d86615b352360e4d48ac",
"delta": {"type": "spotTransfer", "token": "USDC", "amount": "10.5", "usdcValue":
"10.5", "user": "0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036", "destination":
"0xaaa0c2769cb990f4f37db951a9e48de2385c2733", "fee": "1.0", "nativeTokenFee":
"0.0", "nonce": null, "feeToken": ""}}, {"time": 1732865846906, "hash": "0xb43e5536dbe1e0393ac60417fb7e2301a400281569835033a92471582fbc705a",
"delta": {"type": "accountClassTransfer", "usdc": "2684105.0099999998", "toPerp":
false}}, {"time": 1732867345893, "hash": "0xfba2579369bfd93f45b5ea54942e59f81aa72b422064d8969917a0feb0c68694",
"delta": {"type": "deposit", "usdc": "1099994.98"}}]'
headers:
Connection:
- keep-alive
Content-Length:
- '40389'
Content-Type:
- application/json
Date:
- Sat, 30 Aug 2025 19:17:29 GMT
Server:
- nginx/1.22.1
Via:
- 1.1 e505058447bf5e74cc264f4e72f27bee.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- MV7KMQ-PpTHyokjwV3NYgHQcJrCu9w0lFL1woFwYTBadyP8i1H5ikA==
X-Amz-Cf-Pop:
- FRA60-P5
X-Cache:
- Miss from cloudfront
access-control-allow-origin:
- '*'
access-control-expose-headers:
- '*'
vary:
- origin
- access-control-request-method
- access-control-request-headers
status:
code: 200
message: OK
version: 1
Loading