# Iterate Mailchimp API data

**URL:** <https://community.easymorph.com/t/iterate-mailchimp-api-data/5489>\
**Category:** Support\
**Created:** [August 7, 2024, 12:26pm UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489 "2024-08-07T12:26:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nbegbaaji](https://community.easymorph.com/user_avatar/community.easymorph.com/nbegbaaji/32/4985_2.png) [@nbegbaaji](https://community.easymorph.com/u/nbegbaaji)\
**Post date:** [August 7, 2024, 12:26pm UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489/1 "2024-08-07T12:26:14Z")

</div>

I would really like to get a handle on iterating API data requests.

I've looked at a few examples here but they don't quite match my use case because they all use oauth, while I'm using API auth.

Here is my use case:

The events team send out a Fundraising Army newsletter every quarter. I want to ask Mailchimp to display the recipients of each of these newsletters. There is a limit of _(I think)_ 1000 records per request but the number of recipients will vary each time.

I would also like an alternative to offsetting the list of campaigns, which currently looks like this:

 ![image](https://community.easymorph.com/uploads/default/original/2X/8/8b0ff454ade91ae2fba5eeb0f6755f4a0cdee43a.png)

Please can someone help?

Thanks in advance.

Nike

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [August 7, 2024, 12:30pm UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489/2 "2024-08-07T12:30:17Z")

</div>

Check out this article:

[https://community.easymorph.com/t/api-pagination-next-page/5076/4](https://community.easymorph.com/t/api-pagination-next-page/5076/4)

---

<div class="post-metadata">

**Author:** ![nbegbaaji](https://community.easymorph.com/user_avatar/community.easymorph.com/nbegbaaji/32/4985_2.png) [@nbegbaaji](https://community.easymorph.com/u/nbegbaaji)\
**Post date:** [August 24, 2024, 10:54am UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489/3 "2024-08-24T10:54:14Z")

</div>

Thank you very much for this.

I have come back to this today but I am still struggling with this example.

I can successfully run the _ **Get Page** _ module, alone (via Run Action), pull data through and parse my desired JSON fields but I can't get it to repeat.

The reason could be:

1. because I 'bury' all my code in connectors and parameters which that I can call them from anywhere in my modules. My base URL is in a connector and my URL parameters are often called from stored Easymorph parameters. With this example, I'm needing to unfold and deconstruct my stored Easymorph parameters, to get to the API parts
2. because I'm completely unfamiliar with Pokemon (without needing to take a crash course). In my use case, I am interrogating our digital marketing platform - Mailchimp, so my references are _campaign names, campaign date, list name, lsist\_id, campaign\_subject, email\_id, opt\_in\_date, opt\_out_ etc

Screenshots of my errors:

 ![image](https://community.easymorph.com/uploads/default/original/2X/f/f7c57a07a8e245bbe35f87b2e56fa334ee7930c9.png)

Do you have any other marketing based examples?

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [September 13, 2024, 4:01am UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489/4 "2024-09-13T04:01:01Z")

</div>

Hi Nike,

Sorry for the late reply. We will prepare an example of pulling contacts from Mailchimp and publish it here.

---

<div class="post-metadata">

**Author:** ![nbegbaaji](https://community.easymorph.com/user_avatar/community.easymorph.com/nbegbaaji/32/4985_2.png) [@nbegbaaji](https://community.easymorph.com/u/nbegbaaji)\
**Post date:** [September 13, 2024, 12:00pm UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489/5 "2024-09-13T12:00:58Z")

</div>

That's very much appreciated.

Thank you.

---

<div class="post-metadata">

**Author:** ![andrew.rybka](https://community.easymorph.com/user_avatar/community.easymorph.com/andrew.rybka/32/13_2.png) [@andrew.rybka](https://community.easymorph.com/u/andrew.rybka)\
**Post date:** [September 20, 2024, 8:52pm UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489/6 "2024-09-20T20:52:08Z")

</div>

Hi Nike,

Here is the example project:  
[MailchimpPagingExample.morph](https://community.easymorph.com/uploads/short-url/1z4LHdGrfyxZGNwz5JkYYR7dOmd.morph) (12.6 KB)

To make it work, you must set your API key as a password in the connector settings and specify your campaign ID as a parameter.

The tricky parts of this task are:

- generating a correct `offset` value for each call
- detecting the first "empty" response

The former is achieved by passing the `[offset]` column between the executions of the `Query API` module and increasing that number by the number of requested recipients after each execution. The `[offset]` column is removed from the final result in the `Main` module.

 ![image](https://community.easymorph.com/uploads/default/original/2X/4/4fc9e4dd15536b75d8fd1d238dab64297df9f206.png)

The latter is achieved by checking the existence of the `sent_to{*}` in the "Parse JSON" action results. That column will appear only when the response doesn't have any recipients. There might be better alternatives to this method, but I decided to go with this one to avoid overcomplicating the example.

When the "Skip actions on condition" action detects the presence of the `sent_to{*}` column, it will return an empty dataset. That will make the "Derive table" action in the "Result" table disable all the actions and return an empty dataset, which will make the "Repeat" action in the main project stop executing the "Query API" module and return the combined result. An empty dataset will be returned if the specified campaign has no recipients.

 ![image](https://community.easymorph.com/uploads/default/original/2X/2/26c39579745bab556e7e652490f86ac24b957170.png)

I hope this helps.

---

<div class="post-metadata">

**Author:** ![nbegbaaji](https://community.easymorph.com/user_avatar/community.easymorph.com/nbegbaaji/32/4985_2.png) [@nbegbaaji](https://community.easymorph.com/u/nbegbaaji)\
**Post date:** [November 16, 2024, 2:21pm UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489/7 "2024-11-16T14:21:20Z")

</div>

Thank you for this.

I actually already have all my connectors and parameters configured, which include API keys, date parameters, count etc.

I am able to successfully, manually, call any of the endpoints, the standard way, by creating a daisy chain of offset tables

 ![image](https://community.easymorph.com/uploads/default/original/2X/1/1f749d52c20bae12bd076c4a45b8f69fde7710fd.png)

BUT I want to automate and replicate for different products.

An unknown number of emails will be sent, per product, on various dates and from multiple lists which means that I can't predict the number of records and hence, the iteration value.

Ideally, I would like to have one flow per product, which I can run on a set day each month, with limited manual input (_and ideally using EasyMorph launcher_). This means that I won't know the campaign ID, from month to month, so it doesn't work as a parameter, without launching the project AND making manual tweeks that generate the list\_recipents endpoint.

To give you some context, some of our products and the numbers are:

1. **Charity newsletter** - from the Master List and just under 4000 recipients

 ![image](https://community.easymorph.com/uploads/default/original/2X/8/8296d7578e1bccb0cdd20749fcea7163d8ec5980.png)

1. **Charity Shop** newsletter - has it's own list and just under 4000 recipients

 ![image](https://community.easymorph.com/uploads/default/original/2X/f/ff211402db6ace3aaab464b4c6d33a27eefd3029.png)

1. **Fundraising Army** newsletter - from the Master List, numbers vary, but:

 ![image](https://community.easymorph.com/uploads/default/original/2X/9/9a97eeaf342a837f99687844cc3ab30f5f219e5e.png)

1. **Event Volunteers** newsletter (own list)

 ![image](https://community.easymorph.com/uploads/default/original/2X/6/62b9de4aca771ab2bc7284b76a1eadcf9f3c73ee.png)

Once I have cracked the above, I would also like to replicate this model (or similar) with one of our Event Registration platforms that is limited to 100 records per call ☹ .

Is there a way to securely share one of my Mailchimp workflows with you? 🤔

---

<div class="post-metadata">

**Author:** ![andrew.rybka](https://community.easymorph.com/user_avatar/community.easymorph.com/andrew.rybka/32/13_2.png) [@andrew.rybka](https://community.easymorph.com/u/andrew.rybka)\
**Post date:** [November 18, 2024, 3:10pm UTC](https://community.easymorph.com/t/iterate-mailchimp-api-data/5489/8 "2024-11-18T15:10:10Z")

</div>

> [@nbegbaaji](#):
>
> Is there a way to securely share one of my Mailchimp workflows with you? 🤔

Sure. You can send it to [support@easymorph.com](mailto:support@easymorph.com)
