# Positions

> Intear API positions.get: an account's positions in tokens from its swaps, open and closed, with what each cost and made.

This page is part of the Intear API docs. The Intear API is at `https://api.intea.rs` and `wss://api.intea.rs/ws`, with no API key. https://docs.intear.tech/api/llms-full.txt has all of its pages in one file, and https://docs.intear.tech/llms.txt lists every page of the Intear docs.

## `positions.get`

An account's positions, built from its swaps, newest trade first. HTTP: `/positions`.

| Param | Description |
| --- | --- |
| `account` | **Required** |
| `limit` | 1 to 1000, default 1000 |

Every account's positions are built from its first swap on, and kept current with every block, a few seconds behind `height`, and longer while a swap's transaction is still executing.

Result:

```json
{
  "height": 220122260,
  "timestamp_millis": 1792093696887,
  "since_millis": 1790709119408,
  "columns": ["token", "opened_at_millis", "closed_at_millis", "last_trade_millis", "amount", "cost_usd", "bought", "bought_usd", "sold", "sold_usd", "realized_pnl_usd", "buys", "sells"],
  "rows": [["ribbit-426.meme-cooking.near", 1791563912000, null, 1792086520230, "600000000000000000000000", 3600, "1000000000000000000000000", 6000, "400000000000000000000000", 4000, 1600, 3, 1]]
}
```

- `since_millis`: the account's first swap, `null` when it has none. Liquidity changes don't count.
- A position is open while `closed_at_millis` is `null`. An account has at most one open position per token.
- `amount`, `bought` and `sold` are in the token's smallest units. `amount` is what's held now, and `cost_usd` what it cost.
- `realized_pnl_usd`: what sells got, minus what the part sold cost, at average cost. For an open position, what it's worth now is up to you: `amount` at the token's price.

### How swaps count

- A transaction's trades, one per pool, count as one swap. A token passed from one pool to the next nets to nothing.
- A swap buys what the account got and sells what it gave. wNEAR, USDC, USDt and their bridged forms are what positions are paid in, so they never hold one.
- A buy opens a position in the token, or adds to the open one at a new average entry.
- A sell takes from the open position. The position closes once 1% or less of what was bought is left.
- A sell of more than the position holds, like of tokens the account was sent, sells only what it holds, for that share of what it got.
- Tokens sent out of an open position, or burned, shrink it as if they were never bought: `amount` and `bought` by the tokens sent, and `cost_usd` and `bought_usd` by the share of the cost they carry. One left with 1% or less of what was bought is closed if it sold before, and deleted if it never did.
- Tokens sent in don't count, and neither do deposits to and withdrawals from DEXes, which stay the account's.
