Urvah Shabbir
Urvah Shabbir

Reputation: 985

Mailchimp API - Limit on number of campaigns/reports

I have 13 SENT campaigns showing on my Mailchimp dashboard.

But API call to campaigns (and reports) only return 10. I tried the Playground in Mailchimp and it is also showing only 10. I changed the query with ascending and descending and I found the problem was this limit on number of campaigns that are fetched through the API.

MWE:

function MWE(){

   var root = 'https://us19.api.mailchimp.com/3.0/';
   var endpoint = 'reports';
   var params = {
      'method': 'GET',
      'muteHttpExceptions': true,
      'headers': {
         'Authorization': 'apikey ' + API_KEY
      }
   };

   try {
      var response = UrlFetchApp.fetch(root + endpoint, params);
      var data = response.getContentText();
      var json = JSON.parse(data);
      var reports = json["reports"];

      Logger.log(reports.length); // This returns 10 when in actual it should be 13.
   }
   catch (error) {
      Logger.log(error);
   };
}

Is there something I am doing incorrectly, OR is there a workaround this issue.

Any help would be appreciated. Thanks.

Upvotes: 0

Views: 724

Answers (1)

Timothy Alexis Vass
Timothy Alexis Vass

Reputation: 2705

It's an old question, but this was where I got to when I was looking for the answer. So here is the answer:

[count]
integer

The number of records to return.
Default value is 10.
Maximum value is 1000.

[offset]
integer

Used for pagination, this it the number of records from a collection to skip.
Default value is 0. 

From: https://mailchimp.com/developer/marketing/api/campaigns/list-campaigns/

Upvotes: 0

Related Questions