Skip to main content
GET
/
accounts
/
{account_id}
/
folio
/
stream
Stream Folio
curl --request GET \
  --url https://api.example.com/accounts/{account_id}/folio/stream

Stream Folio

Opens a Server-Sent Events (SSE) stream that sends the sub-account’s full portfolio on connect, then streams incremental updates as positions change.

Request

GET /accounts/:account_id/folio/stream

Path parameters

ParameterTypeDescription
account_idstringThe sub-account ID

Response

The response is a text/event-stream with two event types.

snapshot event

Sent immediately on connect. Contains the full folio as a JSON array of [key, value] pairs:
event: snapshot
data: [["balances/token/base/USDC/0xaded...78ef","100e6"],["prices/token/WETH","3391.3"],...]

update event

Sent whenever folio data changes. Contains only the changed key/value pairs:
event: update
data: [["balances/token/base/USDC/0xaded...78ef","150e6"],["prices/token/WETH","3400.1"]]

Keepalive

A comment line is sent every 30 seconds to keep the connection alive:
: keepalive

Examples

curl -N https://prime-api.legend.xyz/accounts/acc_2o0yiljtp378/folio/stream \
  -H "Authorization: Bearer $LEGEND_QUERY_KEY" \
  -H "Accept: text/event-stream"
The stream sends all folio data as flat key/value pairs. See the Folio concepts page for the full key/value reference and value encoding details.

Errors

StatusCodeDescription
404account_not_foundAccount doesn’t exist