Pagination
Long lists — the channel catalog and channel posts — are returned in pages with a cursor.
How it works
limit— rows per page: from 1 to 100, 50 by default.- The response has two fields:
results— the rows of the page,next— a ready link to the next page.nullinnextmeans there are no more pages. - Use the link from
nextas is. The cursor inside it is encoded and remembers the sorting and filters — you don’t need to build it yourself. - The cursor is stable against new data: posts that appear while you are paging don’t shift pages or cause duplicates.
- Each page is a separate request and costs as many units as the method.
Example: all posts of a channel
import requests
# first page — up to 100 posts
URL = "https://api.datool.ru/v1/max/channels/@citynews/posts/?limit=100"
HEADERS = {"Authorization": "Bearer dtk_…"}
posts = []
while URL:
page = requests.get(URL, headers=HEADERS, timeout=30).json()
posts += page["results"]
# None — no more pages
URL = page["next"]
Without pages
The category and territory directories, daily statistics and the webhook list are returned in full. The catalog with the ids parameter (up to 100 numbers) also has no pages: cards come in request order.