Skip to main content

Overview

The PortfolioFetcher retrieves your profile, open positions, and trading history from the Limitless Exchange API. It requires an authenticated HttpClient.

Setup

PortfolioFetcher requires an authenticated client. Use WithHMACCredentials with a scoped API token (recommended). The legacy LIMITLESS_API_KEY / WithAPIKey still works but is not recommended for new integrations.

Current profile

Use GetCurrentProfile() to fetch the authenticated caller’s private profile via GET /profiles/me. This is the preferred helper when the client is already authenticated and you do not want to pass a wallet address.

Fetching a profile by address

Use GetProfile() to retrieve your own profile by wallet address (the API returns 403 for any other address). Prefer GetCurrentProfile(), which needs no address. Other users’ public profiles are served by GET /profiles/public/{address}, which has no SDK method yet; call it with client.GetRaw.

UserProfile fields

Fetching all positions

Use GetPositions() to retrieve all your open positions:
The response is a PortfolioPositionsResponse with the following fields:
GetPositions, GetUserHistory and GetUserOrders always read the authenticated profile: the Go client has no per-request header hook for GET requests, so it cannot send x-on-behalf-of on a single call. To read a server-wallet sub-account, build a second HttpClient with WithAdditionalHeaders(map[string]string{"x-on-behalf-of": "<profileId>"}) and use it only for these reads. The header is rejected with 400 on POST /orders and the cancel endpoints, so never set it on the client that places or cancels orders.

CLOB positions

Use GetCLOBPositions() for CLOB-only positions, or iterate over positions.CLOB:

CLOBPosition fields

AMM positions

Use GetAMMPositions() for AMM-only positions:

AMMPosition fields

Trading history

Use GetUserHistory() to retrieve cursor-paginated trading history. The signature is GetUserHistory(ctx, cursor string, limit int) — pass an empty cursor for the first page, then *history.NextCursor for subsequent pages:

Complete example