# Get Accounts in Graphql

This query returns a list of accounts with basic fields and account type.

---

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

### GraphQL Query

```graphql
query GetAccountList {
  account(
    pagination: {
      limit: 20
      offset: 0
    }
  ) {
    id
    user_code
    name
    type {
      id
      name
      user_code
    }
  }
}
```

---

### Python Example

```python
import requests

url = "https://<domain_name>/<realm_code>/<space_code>/graphql/"

headers = {
    "Authorization": "Bearer <access_token>",
    "Content-Type": "application/json"
}

payload = {
    "query": """
    query GetAccountList {
      account(
        pagination: {
          limit: 20
          offset: 0
        }
      ) {
        id
        user_code
        name
        type {
          id
          name
          user_code
        }
      }
    }
    """
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

---

### What This Query Does

- Fetches a paginated list of accounts
- Returns only required fields
- Includes related account type
- Uses a single API call

---

### Notes

- <span style="white-space: pre-wrap;">Change </span>`<span class="editor-theme-code">limit</span>`<span style="white-space: pre-wrap;"> and </span>`<span class="editor-theme-code">offset</span>`<span style="white-space: pre-wrap;"> for paging</span>
- Add or remove fields as needed
- Query name helps with debugging and logs