Skip to main content

PortfolioFetcher Setup

PortfolioFetcher provides access to your profile, positions, trade history, and accumulated points. Authentication is required.

Current Profile

Call getProfile() without an address to fetch the authenticated caller’s private profile via GET /profiles/me. This avoids passing or persisting the wallet address when the client is already authenticated.
To keep the existing address-based lookup, pass an address:
getProfile() without an address calls GET /profiles/me; getProfile(address) calls GET /profiles/:account. Both return the private authenticated profile shape and require authentication.

All Positions

Fetch all positions across CLOB and AMM markets in a single call:

Response Structure

CLOB Positions

Retrieve only your CLOB market positions:

CLOB Position Structure

AMM Positions

Retrieve only your AMM market positions:

Trade History

Fetch paginated trade history:

Parameters

Response

getUserHistory() resolves to { data, nextCursor }. The feed is a merged, newest-first activity stream (CLOB trades, AMM trades, splits/merges, NegRisk conversions, claims); tell entry kinds apart by strategy. Each entry in data:
A filled order maps to a single trade entry, keyed by transactionHash — the same value returned as execution.txHash on the mined POST /orders response and on the MINED settlement WebSocket event. There is no order id on history entries, so transactionHash is the join key.

Combining Positions with Market Data

For a richer view, combine position data with live market information:
For real-time PnL tracking, combine PortfolioFetcher with WebSocket orderbook updates rather than repeatedly polling getOrderBook(). See the WebSocket Streaming guide.

Error Handling

Portfolio endpoints require a valid API key. If the key is missing or invalid, the SDK throws an APIError with status 401.
See the Error Handling and Retry guide for retry strategies and common error codes.