# Get Transactions in Graphql

This query returns transactions for one portfolio and an accounting date range.

[![Screenshot 2025-12-16 at 17.57.40.png](https://docs.finmars.com/uploads/images/gallery/2025-12/scaled-1680-/screenshot-2025-12-16-at-17-57-40.png)](https://docs.finmars.com/uploads/images/gallery/2025-12/screenshot-2025-12-16-at-17-57-40.png)

---

### GraphQL Query

```graphql
query GetTransactionList {
  transaction(
    pagination: {
      limit: 20
      offset: 0
    }
    filters: {
      portfolio: {
        user_code: {
          exact: "Commodity Portfolio"
        }
      }
      accounting_date: {
        gte: "2021-01-01"
        lte: "2023-12-31"
      }
    }
  ) {
    id
    accounting_date
    position_size_with_sign
    cash_consideration
    trade_price
    instrument {
      id
      user_code
      name
    }
    portfolio {
      id
      user_code
      name
    }
    account_cash {
      id
      user_code
      name
    }
    account_position {
      id
      user_code
      name
    }
    transaction_class {
      id
      user_code
      name
    }
  }
}
```

---

## Filter Highlights

### Filter by Portfolio (nested filter)

```graphql
portfolio: {
  user_code: { exact: "Commodity Portfolio" }
}
```

- `<span class="editor-theme-code">portfolio</span>`<span style="white-space: pre-wrap;"> is a related object.</span>
- <span style="white-space: pre-wrap;">You filter it by its field </span>`<span class="editor-theme-code">user_code</span>`.
- `<span class="editor-theme-code">exact</span>`<span style="white-space: pre-wrap;"> means strict match.</span>

---

### Filter by Date Range

```graphql
accounting_date: {
  gte: "2021-01-01"
  lte: "2023-12-31"
}
```

- `<span class="editor-theme-code">gte</span>`<span style="white-space: pre-wrap;"> = start date (inclusive)</span>
- `<span class="editor-theme-code">lte</span>`<span style="white-space: pre-wrap;"> = end date (inclusive)</span>
- <span style="white-space: pre-wrap;">Use ISO format: </span>`<span class="editor-theme-code">YYYY-MM-DD</span>`

---

### How filters work together

<span style="white-space: pre-wrap;">All filters in one </span>`<span class="editor-theme-code">filters</span>`<span style="white-space: pre-wrap;"> block are combined with </span>**AND**.

So this query means:

- <span style="white-space: pre-wrap;">portfolio user\_code is exactly </span>`<span class="editor-theme-code">"Commodity Portfolio"</span>`  
    AND
- <span style="white-space: pre-wrap;">accounting\_date is between </span>`<span class="editor-theme-code">2021-01-01</span>`<span style="white-space: pre-wrap;"> and </span>`<span class="editor-theme-code">2023-12-31</span>`

---