-1

I am using mailchimp to display all the newsletters in my webpage.

Am using this API call to get all newsletters, https://usX.api.mailchimp.com/3.0/campaigns

But am only getting 10 campaigns, but there are many more campaigns in the mailchimp account.

Is there anything wrong here? How can I get all the newsletters or all campaign ids?

Mann
  • 576
  • 1
  • 9
  • 33
  • 1
    See the documentation [here](http://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/#read-get_campaigns). The default value of the `count` parameter is 10. You're not passing any parameters to the API call, so the default value of the `count` parameter (10) is used and that's why you only get 10 campaigns. – ekad Oct 26 '17 at 17:47
  • @ekad this is what I was looking for, you can post as an answer am happy to accept it. – Mann Oct 27 '17 at 11:14

1 Answers1

1

According to the official documentation of the /campaigns endpoint here, there is a count parameter that indicates the number of campaign records you want to return. The default value of the count parameter is 10. You're not passing any parameters to the /campaigns endpoint, so the default value of the count parameter (10) is used and that's why you only get 10 campaigns.

You can get all campaigns by making two API calls to the /campaigns endpoint. Make the first API call with count parameter set to 1. You will get only one campaign, but you will also get total_items in the response body. The value of total_items shows the total number of campaigns you currently have in your MailChimp account. The second API call should have count parameter set to the value of total_items obtained from the response of the first API call. You will get all campaigns in the response body of the second API call.

ekad
  • 14,436
  • 26
  • 44
  • 46