Add userDetails API method to Python SDK#1
Conversation
- Add user_details() method to Info class in hyperliquid/info.py - Method retrieves array of user transaction details via POST /info - Supports all transaction types: orders, cancels, leverage updates, vault transfers, withdrawals, deposits, etc. - Add comprehensive example in examples/basic_user_details.py - Example demonstrates fetching and displaying transaction details with proper formatting Co-authored-by: Stenton Mayne <stentonian@protonmail.com>
|
@coderabbitai review
|
✅ Actions performedReview triggered.
|
|
@Stentonian: I'll review the changes in this PR for you! 🐰 ✅ Actions performedReview triggered.
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the WalkthroughAdds a new Info.user_details(user) API call and an example script that sets up a client, fetches user details, and prints transaction metadata and actions (up to five). The script runs via main() when executed directly and uses the new endpoint to POST type "userDetails" to /info. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Script as basic_user_details.py
participant Utils as example_utils.setup
participant Info as Info
participant API as /info endpoint
User->>Script: Run main()
Script->>Utils: setup(MAINNET_API_URL, skip_ws=True)
Utils-->>Script: address, info, exchange
Script->>Info: user_details(address)
Info->>API: POST { type: "userDetails", user: address }
API-->>Info: userDetails payload (txs[])
Info-->>Script: response
Script->>Script: Print response type, tx count, sample tx details
Script-->>User: Console output
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Note Free review on us!CodeRabbit is offering free reviews until Wed Oct 08 2025 to showcase some of the refinements we've made. Comment |
Code Review Summary ✅I've completed a thorough review of this PR. Overall, this is a well-implemented addition that successfully brings the ✅ StrengthsAPI Implementation
Example Implementation
Documentation Quality
🔍 Minor SuggestionsType Hints EnhancementConsider adding more specific type hints for better IDE support: from typing import Dict, List, Union, Optional
def user_details(self, user: str) -> Dict[str, Union[str, List[Dict]]]:Example EnhancementThe example could benefit from showing how to filter by specific transaction types: # Filter for specific transaction types
orders = [tx for tx in txs if tx.get('action', {}).get('type') == 'order']🎯 Verification
Recommendation: APPROVE ✅This PR successfully implements the |
|
I've completed my review of PR #1! 🔍 Summary: This is an excellent implementation that successfully adds the Key findings: Minor suggestions:
Recommendation: APPROVE ✅ - This PR is ready for merge and will provide valuable functionality to Python SDK users. You can see all my detailed comments directly on the GitHub PR! 💻 View my work • 🛑 Stop |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
examples/basic_user_details.py (1)
9-9: Prefix unused variable with underscore.The
exchangevariable is unpacked but never used in this example.Apply this diff to follow Python conventions for unused variables:
- address, info, exchange = example_utils.setup(base_url=constants.MAINNET_API_URL, skip_ws=True) + address, info, _exchange = example_utils.setup(base_url=constants.MAINNET_API_URL, skip_ws=True)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
examples/basic_user_details.py(1 hunks)hyperliquid/info.py(1 hunks)
🧰 Additional context used
🪛 Ruff (0.13.3)
examples/basic_user_details.py
9-9: Unpacked variable exchange is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
🔇 Additional comments (1)
hyperliquid/info.py (1)
757-792: LGTM!The implementation follows the established pattern of other Info methods, and the comprehensive docstring clearly documents the endpoint, parameters, return structure, and supported action types.
- Change from POST /info to POST /explorer endpoint - This matches the TypeScript SDK implementation which uses the explorer endpoint - Fixes 422 error: 'Failed to deserialize the JSON body into the target type' Co-authored-by: Stenton Mayne <stentonian@protonmail.com>
- Add MAINNET_RPC_URL and TESTNET_RPC_URL constants - Update user_details() to use RPC URL (rpc.hyperliquid.xyz) instead of API URL - The explorer endpoint is only available on RPC, not API - Automatically detect testnet vs mainnet based on base_url - Tested and confirmed working with testnet address Co-authored-by: Stenton Mayne <stentonian@protonmail.com>
|
that seems to work now
|
Summary
This PR adds the
userDetailsAPI method to the Hyperliquid Python SDK, bringing it in line with the TypeScript SDK functionality.Changes
🔧 Core Implementation
user_details()method to theInfoclass inhyperliquid/info.pyPOST /infowithtype: "userDetails"📚 Documentation & Examples
examples/basic_user_details.pyAPI Details
The
user_details(user: str)method returns:{ "type": "userDetails", "txs": [ { "time": int, # Transaction timestamp "user": str, # User address "action": dict, # Action details with type field "block": int, # Block number "hash": str, # Transaction hash (66 chars) "error": Optional[str] # Error message if failed }, # ... more transactions ] }Supported Transaction Types
The API supports all transaction types including:
type: "order")type: "cancel")type: "updateLeverage")type: "vaultTransfer")type: "withdraw2")type: "evmRawTx")Usage Example
Testing
Tested with the same user address as the TypeScript SDK example to ensure compatibility and consistent behavior.
This implementation maintains consistency with the existing Python SDK patterns while providing the same functionality as the TypeScript version.
💻 View my work • 👤 Initiated by @Stentonian • About Codegen
⛔ Remove Codegen from PR • 🚫 Ban action checks
Summary by CodeRabbit