Bipasha Roy
Bipasha Roy

Reputation: 1

How can I implement pagination using the google-ads-api Node js package?

I am trying to get the search terms,but it is returning 32k records at once. I want to limit the result and implement pagination so that it returns 100 records at a time. I can't find anything in the docs for the npm package.

Upvotes: 0

Views: 23

Answers (1)

Shashank
Shashank

Reputation: 56

You can set limit in query :

const query = `SELECT campaign.id, campaign.name,metrics.clicks FROM campaign LIMIT 100`;
const response = await customer.query({
    query: query,
    page_size: 100,
    page_token: pageToken,
});

console.log('Results:', response.results);
pageToken = response.next_page_token;

You can use do while loop for fetching all data until pageToken has value.

Upvotes: 0

Related Questions