Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ healthchecksdb
MigrationBackup/

testing.py
testing/

# End of https://www.gitignore.io/api/osx,python,pycharm,windows,visualstudio,visualstudiocode
examples/config.json
135 changes: 135 additions & 0 deletions hyperliquid/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,141 @@ 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.
"""
if endTime is not None:
return self.post(
"/info",
{"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime, "endTime": endTime},
)
return self.post("/info", {"type": "userNonFundingLedgerUpdates", "user": user, "startTime": startTime})

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 batch_clearinghouse_states(self, users: List[str], dex: str = "") -> Any:
"""Retrieve perpetuals account summaries for multiple users.

POST /info

Args:
users (List[str]): List of onchain addresses in 42-character hexadecimal format.
dex (str): Perp dex name. Defaults to empty string (first perp dex).

Returns:
Array where each item matches the clearinghouseState schema with fields like
assetPositions, marginSummary, crossMarginSummary, time, and withdrawable.
"""
return self.post("/info", {"type": "batchClearinghouseStates", "users": users, "dex": dex})

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 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_spot_deploy_auction_status(self, user: str) -> Any:
return self.post("/info", {"type": "spotDeployState", "user": user})

Expand Down
53 changes: 53 additions & 0 deletions tests/cassettes/info_test/test_batch_clearinghouse_states.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
interactions:
- request:
body: '{"type": "batchClearinghouseStates", "users": ["0x31ca8395cf837de08b24da3f660e77761dfb974b",
"0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036"], "dex": ""}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '150'
Content-Type:
- application/json
User-Agent:
- python-requests/2.32.3
method: POST
uri: https://api.hyperliquid.xyz/info
response:
body:
string: 'null'
headers:
Connection:
- keep-alive
Content-Length:
- '4'
Content-Type:
- application/json
Date:
- Fri, 22 Aug 2025 11:45:21 GMT
Server:
- nginx/1.22.1
Via:
- 1.1 bd96095bb3c15c742ab4d72d1fecba6c.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- 716oMhKaZxZC9dod6b-3otnwwlDnfV8G-vBOT-qZ9zkZPZQzpy2YpQ==
X-Amz-Cf-Pop:
- FRA60-P5
X-Cache:
- Error from cloudfront
access-control-allow-origin:
- '*'
access-control-expose-headers:
- '*'
vary:
- origin
- access-control-request-method
- access-control-request-headers
status:
code: 500
message: Internal Server Error
version: 1
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
52 changes: 52 additions & 0 deletions tests/cassettes/info_test/test_historical_orders.yaml

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions tests/cassettes/info_test/test_user_rate_limit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
interactions:
- request:
body: '{"type": "userRateLimit", "user": "0x31ca8395cf837de08b24da3f660e77761dfb974b"}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '79'
Content-Type:
- application/json
User-Agent:
- python-requests/2.32.3
method: POST
uri: https://api.hyperliquid.xyz/info
response:
body:
string: '{"cumVlm":"170043721737.450012207","nRequestsUsed":36589831368,"nRequestsCap":170043731737}'
headers:
Connection:
- keep-alive
Content-Length:
- '91'
Content-Type:
- application/json
Date:
- Fri, 22 Aug 2025 11:45:23 GMT
Server:
- nginx/1.22.1
Via:
- 1.1 76f18545659f3cecc2213d8e93d15fb2.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- lXzwL1ejqdnvtapMPFADHuF-H134yuDqjaHhGTI0xiueITWcLuT_xw==
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