After months of mucking around with MailChimp API 3.0 using C#, it came to my attention that there are not many examples out on the internet. Therefore this post will show some code examples on how to perform GET/POST/PUT operations on MailChimp lists and list members (i.e. create, read and update MailChimp lists and list members).
With MailChimp API 3.0, you can sync email activity and campaign stats with your database, manage lists, create and edit Automation workflows, and many more. It is designed for developers, engineers, or anyone else who’s comfortable creating custom-coded solutions or integrating with RESTful APIs, where you can find tutorial "Get Started with the MailChimp API 3.0" and full official documentation here.
To begin with, get an API key from your MailChimp account as per documentation here. Here for example, 2ffadd1fe2293bbbc7b1c5cb3e94d89b-us10 is my MailChimp API key, where 2ffadd1fe2293bbbc7b1c5cb3e94d89b is the actual token and us10 is the datacenter my MailChimp uses.
Lists
Read (GET)
MailChimp API 3.0 provides methods to read all lists or just a particular one list. Note that by default, only the first 10 lists will be returned when no list ID is specified.
Create (POST)
MailChimp API 3.0 supports creating list using HTTP POST. A list of required fields can be found here.
List Members
Read (GET)
Just like getting lists information using MailChimp API 3.0, list members can be retrieved in the similar fashion. If the subscriber hash is not provided, all members within a list will be retrieved.
Create or Update (PUT)
MailChimp API 3.0 has standard HTTP POST/PATCH methods to create/update a list member. In addition to that, there is also a HTTP PUT method to add or update a list member, which I personally find it quite handy.