Pagination

All list endpoints in the Levrage API return paginated results. This keeps responses fast even when you have thousands of agents, calls, or campaigns.

How It Works

Pass page and page_size query parameters to any list endpoint:

$curl -H "Authorization: Bearer $API_KEY" \
> "https://api.levrage.ai/v1/calls?page=1&page_size=20"

Response Format

Every paginated response includes pagination metadata:

1{
2 "success": true,
3 "data": [ ... ],
4 "total": 1250,
5 "page": 1,
6 "page_size": 20,
7 "has_more": true,
8 "request_id": "req_abc123",
9 "timestamp": "2025-01-01T12:00:00Z"
10}
FieldTypeDescription
totalintegerTotal number of records matching your filters
pageintegerCurrent page number (1-indexed)
page_sizeintegerNumber of items per page
has_morebooleantrue if more pages exist

Defaults & Limits

ParameterDefaultMinMax
page11
page_size201100

Paginated Endpoints

EndpointDescription
GET /v1/agentsList your agents
GET /v1/callsCall history with filters
GET /v1/campaignsCampaign list

Iterating Through All Pages

1import requests
2
3API_KEY = "lev_YOUR_API_KEY"
4BASE_URL = "https://api.levrage.ai/v1"
5headers = {"Authorization": f"Bearer {API_KEY}"}
6
7def get_all_calls(status=None):
8 """Fetch all calls, iterating through all pages."""
9 all_calls = []
10 page = 1
11
12 while True:
13 params = {"page": page, "page_size": 100}
14 if status:
15 params["status"] = status
16
17 response = requests.get(f"{BASE_URL}/calls", headers=headers, params=params)
18 data = response.json()
19
20 all_calls.extend(data["data"])
21 print(f"Page {page}: fetched {len(data['data'])} calls ({len(all_calls)}/{data['total']})")
22
23 if not data["has_more"]:
24 break
25 page += 1
26
27 return all_calls
28
29# Get all completed calls
30completed = get_all_calls(status="completed")
31print(f"Total completed calls: {len(completed)}")

Combining with Filters

Pagination works with all filters. For example, get the second page of completed outbound calls from a specific agent:

$curl -H "Authorization: Bearer $API_KEY" \
> "https://api.levrage.ai/v1/calls?page=2&page_size=50&status=completed&direction=outbound&agent_id=YOUR_AGENT_ID"

Best Practices

  1. Use page_size: 100 for bulk operations — minimizes round-trips
  2. Use page_size: 20 for UI displays — keeps responses snappy
  3. Always check has_more — don’t assume a fixed number of pages
  4. Add small delays between pages for bulk fetches to avoid rate limits
  5. Filter first, paginate second — narrowing results with filters is more efficient than fetching everything