Pagination
List endpoints return results in pages. Understanding the pagination format lets you reliably fetch large datasets without missing or duplicating records.
Overview
Logimeter uses page-number-based pagination on all list endpoints that can return more records than a single response can contain. You request a specific page number and a page size; the API returns that slice of results along with metadata that tells you how to fetch the next or previous page.
Not every endpoint is paginated. Some endpoints — for example /v1/tn_prefixes/ and /v2/available_source/ — return a flat JSON array because their total result set is always small. You can tell immediately from the response shape: a paginated response is a JSON object with count, next, previous, and results keys; a non-paginated response is a plain JSON array ([...]).
Response format
All paginated list responses share the following envelope:
{
"count": 150,
"next": "https://next.logimeter.com/v2/contact/?page=3",
"previous": "https://next.logimeter.com/v2/contact/?page=1",
"results": [
{ ... },
{ ... }
]
}
| Field | Type | Description |
|---|---|---|
| count | integer | Total number of results across all pages, regardless of the current page or page size. |
| next | string or null | Full URL of the next page. null when you are on the last page. |
| previous | string or null | Full URL of the previous page. null when you are on the first page. |
| results | array | The items on the current page. Length is at most page_size items; may be fewer on the last page. |
The next and previous URLs are fully qualified — you can follow them directly without constructing your own URL. They already contain the correct page and any other query parameters you originally sent.
Query parameters
Control pagination by appending query parameters to the request URL. Both parameters are optional — the API uses sensible defaults if they are omitted.
| Parameter | Type | Default | Description |
|---|---|---|---|
| page | integer | 1 |
The page number to retrieve. Pages are 1-indexed — the first page is page=1, not page=0. Requesting a page beyond the last page returns a 404. |
| page_size | integer | 20 |
Number of results per page. The maximum allowed value is typically 100, though some endpoints may enforce a lower cap. Values exceeding the maximum are silently clamped to the maximum. |
Examples
Fetching a specific page
Append ?page=2 (and optionally &page_size=50) to any list endpoint URL:
# Fetch page 2 with the default page size
curl "https://next.logimeter.com/v2/contact/?page=2" \
-H "Authorization: Token YOUR_TOKEN"
# Fetch page 3 with 50 results per page
curl "https://next.logimeter.com/v2/contact/?page=3&page_size=50" \
-H "Authorization: Token YOUR_TOKEN"
import requests
session = requests.Session()
session.headers['Authorization'] = 'Token YOUR_TOKEN'
# Fetch page 2 with 50 results per page
resp = session.get(
'https://next.logimeter.com/v2/contact/',
params={'page': 2, 'page_size': 50}
)
data = resp.json()
print(f"Page 2 of {-(-data['count'] // 50)} pages")
print(f"Results on this page: {len(data['results'])}")
print(f"Next page URL: {data['next']}")
const TOKEN = 'YOUR_TOKEN';
const resp = await fetch(
'https://next.logimeter.com/v2/contact/?page=2&page_size=50',
{ headers: { 'Authorization': `Token ${TOKEN}` } }
);
const data = await resp.json();
console.log('Total results:', data.count);
console.log('Results on this page:', data.results.length);
console.log('Next URL:', data.next);
Iterating through all pages
When you need all records — for example during an initial data sync — follow the next URL until it is null. The example below collects every contact into a single list:
import requests
session = requests.Session()
session.headers['Authorization'] = 'Token YOUR_TOKEN'
def fetch_all(url):
"""Iterate all pages of a paginated list endpoint and return combined results."""
results = []
while url:
resp = session.get(url)
resp.raise_for_status()
data = resp.json()
results.extend(data['results'])
url = data['next'] # None on the last page — loop ends
return results
all_contacts = fetch_all('https://next.logimeter.com/v2/contact/?page_size=100')
print(f'Total contacts fetched: {len(all_contacts)}')
const TOKEN = 'YOUR_TOKEN';
async function fetchAll(startUrl) {
const results = [];
let url = startUrl;
while (url) {
const resp = await fetch(url, {
headers: { 'Authorization': `Token ${TOKEN}` }
});
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const data = await resp.json();
results.push(...data.results);
url = data.next; // null on the last page
}
return results;
}
const contacts = await fetchAll(
'https://next.logimeter.com/v2/contact/?page_size=100'
);
console.log('Total contacts:', contacts.length);
Paginated vs. flat endpoints
Not all list endpoints use the paginated envelope. Some always return a flat array because their data sets are bounded in size. When integrating with an endpoint for the first time, check the response shape before writing pagination logic:
| Response shape | Interpretation | Example endpoints |
|---|---|---|
{"count": …, "results": […]} |
Paginated. Use next to walk pages. |
/v2/contact/, /v2/company/ |
[…] |
Flat array. All results returned in one response; no pagination needed. | /v2/available_source/, /v1/tn_prefixes/ |
.results on a flat array response will throw a runtime error in your code.
Tips
- Use
page_size=100for bulk reads. Requesting the maximum page size reduces the total number of HTTP round-trips needed to fetch all records. - Do not construct page URLs manually. Always follow the
nextURL returned by the API. It includes any filter or ordering parameters that were on the original request, keeping your iteration consistent. - Count the total before iterating. You can read
countfrom the first response to give your users a progress indicator or to decide whether iterating all pages is worthwhile. - Handle the last page. The final page's
resultsarray will be shorter thanpage_sizewhencountis not a perfect multiple ofpage_size. Your code must not assume a full page. - Avoid parallel page requests. Fetching multiple pages simultaneously can push you toward rate limits. Sequential page reads with the
nextlink are the safest approach for bulk syncs.