Get Accounts in Graphql
This query returns a list of accounts with basic fields and account type.
GraphQL Query
query GetAccountList {
account(
pagination: {
limit: 20
offset: 0
}
) {
id
user_code
name
type {
id
name
user_code
}
}
}
Python Example
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
- Change
limitandoffsetfor paging - Add or remove fields as needed
- Query name helps with debugging and logs
