Read MailChimp Contacts

Updated: Jan 31, 2023

This example shows you how to read MailChimp contacts using DataPipeline.

You can see similar MailChimp examples here.

Java Code Listing

package com.northconcepts.datapipeline.mailchimp;

import com.northconcepts.datapipeline.core.DataReader;
import com.northconcepts.datapipeline.core.DataWriter;
import com.northconcepts.datapipeline.core.StreamWriter;
import com.northconcepts.datapipeline.job.Job;
import com.northconcepts.datapipeline.mailchimp.list.ListMemberStatus;

public class ReadMailChimpContacts {

    private static final String apiKey = "api-key";
    private static final String listId = "list-id";
    public static void main(String[] args) {
        DataReader reader = new MailChimpListMemberReader(apiKey, listId)
        DataWriter writer = StreamWriter.newSystemOutWriter();
       , writer);

Code Walkthrough

  1. apiKey is your MailChimp token which you can easily learn how to generate in
  2. listId is your audience id.
  3. MailChimpListMemberReader is used to read all the contacts in the given listId.
  4. .setStatus(ListMemberStatus.subscribed) this method is used to specify the type of contacts that you want to fetch e.g. for this case, all the subscribed contacts will be fetched.
  5. The status can either be subscribed, unsubscribed, cleaned, pending, or archived.
  6. StreamWriter.newSystemOutWriter() is used to print the output records to the console.
  7. is then used to transfer data from the reader to StreamWriter.
Mobile Analytics