Pagination
Every list in the AdLib API is cursor-based. Pass next_cursor back as cursor until it is null.
List endpoints return one page and a cursor:
{
"data": [ ... ],
"next_cursor": "eyJwIjoyfQ"
}Pass next_cursor back as the cursor parameter for the next page. When next_cursor is null, you have the last page.
import os, requests
params = {"q": "running shoes", "platform": "meta"}
headers = {"X-API-Key": os.environ["ADLIB_API_KEY"]}
ads = []
while True:
r = requests.get("https://api.adlibapi.com/v1/search", params=params, headers=headers).json()
ads += r["data"]
if not r.get("next_cursor"):
break
params["cursor"] = r["next_cursor"]Page size
limit is a hint for live searches, because each platform has its own page size. Searches in our archive (source=history) return exactly limit items.
Cost
A live search page costs at most 5 credits per platform (10 on Google, 15 on LinkedIn), however many ads it returns. Stop paging when you have enough: each further page is billed. See Credits and billing.