Getting Started with the MailChimp APIs

« back to the getting started docs
Are you a programmer? If not, go find one and send them here. Seriously.

First and foremost, make sure that you are using the most recent version of the whichever API and/or any wrappers.

Sending & Receiving Data

The first thing to do is determine how you want to send and receive data. The options to explore, in order of ease of use, are:

  1. API Wrappers – use one of the wrappers in the API you are working with's downloads area to get started quickly. These typically have the natural feel of the language you are using. They also will take care of the network transport and urlencoding data so that you don't have to worry about. Essentially you will end up with some sort of object that you can manipulate like you are used to without the worry of how it is connecting and passing data. At their core, these will use one of the following two options, but again, you don't really have to worry about which.
  2. XML-RPC – find an XML-RPC library for your language of choice and work on implementing it. This approach may require a little more setup time & learning curve, but will likely make your life easier in the long run. We don't really recommend using this as it has increased overhead and not all of our APIs will actually support XML-RPC.
  3. Serialized JSON – several of our APIs support passing in serialized JSON objects. Where supported, this allows you the simplicity of building up a native object, serializing it as JSON, and passing it over the wire - similarly, we'll then return a serialized JSON object. This is pretty much our preferred approach at this time and the route we'll be taking as we release new and updated APIs.
  4. Serialized GET/POST – create HTTP GET/POST URLs, pass along GET/POST parameters, and then handle one of the Serialized return formats that the API you are using supports. For small jobs, like a simple subscribe, this will work well. The more API Methods you have to implement, the more you will kick yourself for choosing this method. Seriously, unless there's no working wrapper, you can't use JSON, or you just want to write your own, don't go this route, especially if you are not particularly experienced with Web-based APIs.

Finally, this can not be stated often or strongly enough:

do ERROR CHECKING like a crazy chimp!

We know mentioning this is like beating a dead horse, but we've also found that 60% – 70% of the support requests we receive are things that folks would have quickly and easily noticed if they were making good use of the errors being returned. Just do it!

General Notes

If you are not a big coder or are looking to integrate MailChimp service with your current CMS, etc., the first thing to do is check out our Plugins & Integrations Directory page and see if someone has already released code for your system. If not, keep reading...

Know something that we don't or don't have listed here? Send us a note and we'll probably post it here (or where ever it's appropriate).

PHP 4 & 5 Notes

XML-RPC – there are plenty of PHP XML-RPC libraries, classes, etc. out there, however we're going to recommend one: the PEAR XML-RPC2 package. Install it via your system's PEAR facility. And don't let the age of it worry you—it might be a little old and under–maintained, but it works. It's also the package we use internally and test with constantly.

Serialized Formats – This is really just getting into a personal preference of what you'd like to work with.

  • Sending Requests: There are 2 standard ways you would do this: a) using PHP's fsockopen() built-in function OR use the PHP CURL library extension. CURL handles a lot of annoying HTTP protocol related things for you, so we'd suggest that.
  • Return Formats: Obviously Serialized PHP is the no-brainer for a return format, but PHP also has great support and very usable extensions and libraries for parsing and handling XML or JSON, especially if you are using PHP5 (you should be!).

.Net (ASP, C#, VB, etc) Notes

XML-RPC – pretty much the only thing we've seen that's useful in this respect is the CookComputing XML-RPC library. The one thing that is going to drive you batty with this is that .Net (and the CLS standard in general) does not support "jagged arrays" (arrays or hashes of arrays or hashes) – see this for a little more info.

Serialized Formats – While we are not .Net experts by any means, we believe that you'll likely want to look into using the XML output format as it should have the best support. Newer .Net releases as well as 3rd party libraries should also give you some options for JSON support.

Documentation

Export API

Simple Transactional Service (STS)

WebHooks