Portfolio
Get Folio
Get a sub-account’s portfolio (balances and positions)
GET
/
accounts
/
{account_id}
/
folio
Get Folio
curl --request GET \
--url https://api.example.com/accounts/{account_id}/folioimport requests
url = "https://api.example.com/accounts/{account_id}/folio"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/accounts/{account_id}/folio', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/accounts/{account_id}/folio",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/accounts/{account_id}/folio"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/accounts/{account_id}/folio")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/accounts/{account_id}/folio")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyGet Folio
Returns the sub-account’s portfolio, including wallet balances and DeFi positions across all networks.Request
GET /accounts/:account_id/folio
GET /accounts/:account_id/folio?cached=true
Path parameters
| Parameter | Type | Description |
|---|---|---|
account_id | string | The sub-account ID |
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
cached | boolean | false | If true, return the most recent cached folio instead of computing a fresh one. Faster but may be slightly stale. |
Examples
curl https://prime-api.legend.xyz/accounts/acc_2o0yiljtp378/folio \
-H "Authorization: Bearer $LEGEND_QUERY_KEY"
const folio = await client.accounts.folio("acc_2o0yiljtp378");
// Or use cached for faster response
const cached = await client.accounts.folio("acc_2o0yiljtp378", { cached: true });
folio = await client.accounts.folio("acc_2o0yiljtp378")
# Or use cached for faster response
cached = await client.accounts.folio("acc_2o0yiljtp378", cached=True)
use legend_client::FolioOpts;
let folio = client.accounts.folio("acc_2o0yiljtp378", &FolioOpts::default()).await?;
Response
{
"folio": {
...
}
}
A fresh folio requires reading on-chain state across multiple networks. This can take 10-30 seconds. Use
cached=true when you need a fast response and can tolerate slightly stale data.Errors
| Status | Code | Description |
|---|---|---|
| 404 | account_not_found | Account doesn’t exist |
| 408 | timeout | Folio computation timed out (try cached=true) |
⌘I
Get Folio
curl --request GET \
--url https://api.example.com/accounts/{account_id}/folioimport requests
url = "https://api.example.com/accounts/{account_id}/folio"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/accounts/{account_id}/folio', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/accounts/{account_id}/folio",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/accounts/{account_id}/folio"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/accounts/{account_id}/folio")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/accounts/{account_id}/folio")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body