Skip to content

Flows#

GET https://api.pro.anboto.xyz/api/v2/portfolio/flows

The flows the daily PnL subtracts, deduplicated and signed: net_flow_usd is a flow's contribution to net_flows (positive in, negative out; 0 with counted_in_pnl: false for transfers within one account and for unknown directions). When the asset could not be priced, usd_value and net_flow_usd are null (counted_in_pnl: false; transfers within one account stay 0) and the flow is counted in totals.unpriced_count. The window is half-open, [startMs, endMs): a flow at exactly endMs is not returned, so the next window starts at to_ms. Oldest first; pass next_cursor back as cursor for the next page; totals always cover the whole window. ApiKeyAuth required.

Query params#

accounts string
Comma-separated accounts: binance = every account on Binance (main and subaccounts), binance: = the main account only, binance:Sub1 = that subaccount. Omit for every account of the team. At most 20 items. Unlike /api/v2/trading/*, a missing subaccount means all accounts. Sign the raw value, e.g. accounts=binance:,bybit:Sub1.
Example: binance
startMs integer
Start, ms since epoch (inclusive). Defaults to 30 days before endMs. Must be before endMs
endMs integer
End, ms since epoch (exclusive: a flow at exactly endMs is not returned). Defaults to now; at most 4102444800000 (2100-01-01). The window spans at most 366 days
types string
Comma-separated flow types: deposit, withdrawal, internal_transfer. Default all
Example: deposit,withdrawal
external boolean
true: only flows that cross the team's boundary (deposits, withdrawals); false: only transfers inside the team. Default both
limit integer
Flows per page, 1 to 500 (default 500)
Default: 500
cursor string
next_cursor of the previous page

Headers#

Header
X-API-KEY string required
X-TIMESTAMP int64 ms required
X-SIGN string required
X-RECV-WINDOW int, default 5000

Responses#

200 The flows
400 Invalid parameter,
401 Unauthorized: missing or unknown API key
429 Rate limit exceeded, retry later
503 The portfolio service is unavailable,

Response fields — PortfolioFlowsResponse#

from_ms integer required
Start of the window, ms since epoch (inclusive)
to_ms integer required
End of the window, ms since epoch (exclusive): a flow at exactly to_ms is not in this window. Pass it as startMs to read the next window
flows array[FlowRecord] required
Flows of this page, oldest first
flows[].id string required
Stable identifier of the flow
flows[].time integer required
Event time, ms since epoch
flows[].exchange string required
flows[].subaccount string required
"" is the main account
flows[].type enum required
deposit, withdrawal, internal_transfer
flows[].direction enum required
Direction for this account — in, out, internal, unknown
flows[].external boolean required
True for flows that cross the team's boundary (deposits and withdrawals)
flows[].asset string required
flows[].qty number required
Absolute amount of the asset, with every stored decimal digit
flows[].usd_value number required
USD value at the event time; null when the asset could not be priced
flows[].net_flow_usd number required
Signed contribution to the total-scope net_flows of the daily PnL (positive in, negative out). 0 for transfers within one account (whatever the price) and for unknown directions. null when the asset could not be priced: the flow is then not in the USD totals and is counted in totals.unpriced_count. counted_in_pnl is false whenever net_flow_usd is 0 for those reasons or null
flows[].counted_in_pnl boolean required
Whether the flow moves net_flows of the daily PnL: true when net_flow_usd is not null and direction is in or out
flows[].source string required
Exchange history the flow was read from, e.g. binance_deposit, binance_sub_transfer
totals FlowTotals required
Sums of net_flow_usd over the whole window and selection
totals.deposits_usd number required
Sum of deposits (≥ 0)
totals.withdrawals_usd number required
Sum of withdrawals, signed (≤ 0)
totals.net_external_usd number required
deposits_usd + withdrawals_usd
totals.net_internal_usd number required
Net of internal transfers counted in PnL (non-zero when the selection is part of the team)
totals.unpriced_count integer required
Flows whose net_flow_usd is null (unpriced); they are not in the USD sums
next_cursor string required
Pass as cursor to read the next page; null on the last page
curl -X GET "$BASE/api/v2/portfolio/flows?accounts=string" \
  -H "X-API-KEY: $API_KEY" -H "X-TIMESTAMP: $ts" \
  -H "X-SIGN: $sign"
params = {"accounts": ..., "startMs": ..., "endMs": ..., "types": ..., "external": ..., "limit": ..., "cursor": ...}
r = requests.get(f"{BASE}/api/v2/portfolio/flows",
    params=params
    headers=signed_headers_query(params))
print(r.json())
let resp = client
    .get(format!("{BASE}/api/v2/portfolio/flows?accounts=string"))
    .headers(signed_headers_query(&params))
    .send()?;
println!("{}", resp.text()?);
req, _ := http.NewRequest("GET", BASE+"/api/v2/portfolio/flows?accounts=string", nil)
for k, v := range signedHeadersQuery(req.URL.Query()) {
    req.Header.Set(k, v)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
HttpResponse<String> resp = client.send(
    signedGet("/api/v2/portfolio/flows?accounts=string"),
    HttpResponse.BodyHandlers.ofString());
const res = await fetch(`${BASE}/api/v2/portfolio/flows?accounts=string`, {
  method: "GET",
  headers: signedHeadersQuery(params),
});
const data: PortfolioFlowsResponse = await res.json();
val request = signedGet("/api/v2/portfolio/flows?accounts=string")
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
cpr::Response r = cpr::Get(
    cpr::Url{BASE + "/api/v2/portfolio/flows?accounts=string"},
    signedHeadersQuery(params));
std::cout << r.text << std::endl;
const res = await fetch(`${BASE}/api/v2/portfolio/flows?accounts=string`, {
  method: "GET",
  headers: signedHeadersQuery(params),
});
console.log(await res.json());

Response 200

{
  "from_ms": 0,
  "to_ms": 0,
  "flows": [
    {
      "id": "string",
      "time": 0,
      "exchange": "string",
      "subaccount": "string",
      "type": "deposit",
      "direction": "in",
      "external": true,
      "asset": "string",
      "qty": 0.0,
      "usd_value": 0.0,
      "net_flow_usd": 0.0,
      "counted_in_pnl": true,
      "source": "string"
    }
  ],
  "totals": {
    "deposits_usd": 0.0,
    "withdrawals_usd": 0.0,
    "net_external_usd": 0.0,
    "net_internal_usd": 0.0,
    "unpriced_count": 0
  },
  "next_cursor": "string"
}