1

In mailchimp api V2. I was able to do retrieve newsletter subscription list using one method: lists/member-info. In V3. I have to use methods:

  1. /lists/{listid}/members, to retrieve all members, and to find the emailid
  2. then use a method: /lists/{listid}/members/{emailid} to retrieve the subscription list {interest}

In our case, we now have 20K+ email addresses, so step 1 will quite bit slow (20k/1k=20 times). Is there a way I can get the subscription list quickly?

ekad
  • 14,436
  • 26
  • 44
  • 46
sunnymesa
  • 31
  • 1
  • 3
  • I'm confused . . . what are you getting back from `/lists/{listid}/members/{emailid}` that you don't get from `/lists/{listid}/members/`? – TooMuchPete May 26 '16 at 19:08
  • You are right, .../members should do it, but only 1k at a time, to list all members I prefer to use export/list which give all the user in one big dump. at this time I am more concern with one email's subscription, I think: md5 hash email; then .../members/{md5hashid} should be the quickest way for what I would like to do. Thanks. – sunnymesa May 27 '16 at 16:04
  • Makes sense. Keep in mind that the exports API will be going away at the end of 2016, so you'll want to come up with a new way to do that by then! – TooMuchPete May 27 '16 at 19:13

2 Answers2

2

Ok, just re-read the api's guide's first page, the id is a md5 hash, so I can generate the id and do the query, that would remove step 1. for the references, I found following md5 hash useful: How can I generate an MD5 hash?

Community
  • 1
  • 1
sunnymesa
  • 31
  • 1
  • 3
0

Just thought I would give the full code solution to convert an email String to MailChimp's MD5 hash. It's important to note that the MD5 hash value is based of the lowercase version of the email string.

public static String generateEndPoint_findMemberByEmail(String listId, String email) throws Exception {
    byte[] bytesOfMessage = email.toLowerCase().getBytes(StandardCharsets.UTF_8);
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] md5 = md.digest(bytesOfMessage);
    String emailHash = Hex.encodeHexString(md5);
    return "/lists/" + listId + "/members/" + emailHash;
}
Burton
  • 821
  • 8
  • 16