Pagination
Pagination
Section titled “Pagination”The proxy limits requests to 50 rows per call (default is 25). Use ordering plus filters to paginate through a dataset and the total_count field to know how many records match your filters.
Shared setup
Section titled “Shared setup”export BASE_URL="https://api.graphadv.com"export GRAPHADV_API_KEY="YOUR_API_KEY"All examples use a single header: x-api-key.
Single Page With Count
Section titled “Single Page With Count”curl -X POST "$BASE_URL/firms" \ -H "x-api-key: $GRAPHADV_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "select": ["legal_name","sec_number","aum_total_usd"], "filters": { "region": "eq.West" }, "order": "aum_total_usd.desc", "limit": 25 }'import osimport requests
headers = {"x-api-key": os.getenv("GRAPHADV_API_KEY"), "Content-Type": "application/json"}page = requests.post( f"{os.getenv('BASE_URL', 'https://api.graphadv.com')}/firms", headers=headers, json={ "select": ["legal_name", "sec_number", "aum_total_usd"], "filters": {"region": "eq.West"}, "order": "aum_total_usd.desc", "limit": 25, },).json()firms = page["data"]total = page.get("total_count")const resp = await fetch(`${BASE_URL}/firms`, { method: 'POST', headers: { 'x-api-key': process.env.GRAPHADV_API_KEY ?? '', 'Content-Type': 'application/json' }, body: JSON.stringify({ select: ['legal_name', 'sec_number', 'aum_total_usd'], filters: { region: 'eq.West' }, order: 'aum_total_usd.desc', limit: 25 })});const { data: firms, total_count } = await resp.json();const resp = await fetch(`${BASE_URL}/firms`, { method: 'POST', headers: { 'x-api-key': process.env.GRAPHADV_API_KEY ?? '', 'Content-Type': 'application/json' }, body: JSON.stringify({ select: ['legal_name', 'sec_number', 'aum_total_usd'], filters: { region: 'eq.West' }, order: 'aum_total_usd.desc', limit: 25 })});const { data: firms, total_count } = (await resp.json()) as { data: unknown[]; total_count: number | null };Cursor-Style “Load More”
Section titled “Cursor-Style “Load More””Offset is not exposed in the proxy. Instead, order by a stable field and filter based on the last value you received.
PAGE_SIZE=20LAST_AUM=""
curl_page() { local filter_part="" if [ -n "$LAST_AUM" ]; then filter_part=", \"aum_total_usd\": \"lt.${LAST_AUM}\"" fi
curl -s -X POST "$BASE_URL/firms" \ -H "x-api-key: $GRAPHADV_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"select\": [\"legal_name\",\"sec_number\",\"aum_total_usd\"], \"filters\": { \"region\": \"eq.West\"${filter_part} }, \"order\": \"aum_total_usd.desc\", \"limit\": ${PAGE_SIZE} }"}
page=$(curl_page)LAST_AUM=$(echo "$page" | jq -r '.data[-1].aum_total_usd // empty')def load_firm_pages(page_size: int = 20): last_aum = None while True: filters = {"region": "eq.West"} if last_aum is not None: filters["aum_total_usd"] = f"lt.{last_aum}"
resp = requests.post( f"{os.getenv('BASE_URL', 'https://api.graphadv.com')}/firms", headers=headers, json={ "select": ["legal_name", "sec_number", "aum_total_usd"], "filters": filters, "order": "aum_total_usd.desc", "limit": page_size, }, ).json()
rows = resp["data"] if not rows: break yield from rows last_aum = rows[-1]["aum_total_usd"]async function* loadFirms(pageSize = 20) { let lastAum = null;
while (true) { const filters = { region: 'eq.West' }; if (lastAum !== null) filters.aum_total_usd = `lt.${lastAum}`;
const resp = await fetch(`${BASE_URL}/firms`, { method: 'POST', headers: { 'x-api-key': process.env.GRAPHADV_API_KEY ?? '', 'Content-Type': 'application/json' }, body: JSON.stringify({ select: ['legal_name', 'sec_number', 'aum_total_usd'], filters, order: 'aum_total_usd.desc', limit: pageSize }) });
const { data } = await resp.json(); if (!data?.length) break; yield* data; lastAum = data[data.length - 1].aum_total_usd; }}async function* loadFirms(pageSize = 20) { let lastAum: number | null = null;
while (true) { const filters: Record<string, string> = { region: 'eq.West' }; if (lastAum !== null) filters.aum_total_usd = `lt.${lastAum}`;
const resp = await fetch(`${BASE_URL}/firms`, { method: 'POST', headers: { 'x-api-key': process.env.GRAPHADV_API_KEY ?? '', 'Content-Type': 'application/json' }, body: JSON.stringify({ select: ['legal_name', 'sec_number', 'aum_total_usd'], filters, order: 'aum_total_usd.desc', limit: pageSize }) });
const { data } = (await resp.json()) as { data: Array<{ aum_total_usd: number }> }; if (!data?.length) break; yield* data; lastAum = data[data.length - 1].aum_total_usd; }}- Keep
limitat or below 50; the proxy enforces the cap. - Use
total_countfrom the response to size your pagination UI. - For large datasets, paginate by a stable sort column and filter on the last value (as shown above) instead of relying on offsets.