Mailchimp API Best Practices
With any API, it’s important that your integrations are fault-tolerant and smart with their use of resources. To make sure your integration with the Mailchimp API is as reliable as possible, review these best practices.
When you use any API, keep in mind that errors and exceptions will sometimes happen. For example, you might experience a connection problem between your servers and Mailchimp’s, or a rare outage. To make sure that your integration is as reliable as it can be, you should always watch for errors and exceptions. If an API call returns an error, log the call in as much detail as you can, including what you sent along with the entire error response and headers. In the event that you need to contact support, this information can speed up the help process for you.
We also recommend that you async your calls to the Mailchimp API as a background job, instead of making your users wait for a response. In the case of custom signup forms, most users want to know if their attempt to subscribe worked or not.
Use Specific Requests
Sometimes, the API will return values that are large and slow to calculate. After you know what data you need, use our partial response capabilities to request only what’s essential to you. Often, when you make fewer requests, you’ll generate quicker responses.
Another way to reduce response time is to make fewer calls. Calls that are too frequent can slow your application, and may also receive unwanted attention from our operations team. For example, you probably don’t need to query campaign statistics every hour for several days, because most campaigns receive the bulk of their open and click activity in the first 24 hours after a send. To reduce calls further, we recommend you sync only new data, and cache data that’s unlikely to change.
We recommend OAuth2 for platform integrations.
It’s best to cache frequently-used values that don’t change often. For simple subscriptions, cache required values for resources like Lists, Interests, and Merge Fields, and offer a setup area where users can change those values.
To avoid the possibility of abuse complaints, balance your calls with your list size. For example, when you make hundreds of calls per second to get list member details for 200 members, it will look like abuse to our operations team. Learn more about our connection limits.
If you create dozens of new campaigns a day, your email marketing strategy may be better suited for Mandrill’s powerful delivery service. The Mandrill API is ideal for sending data-driven transactional emails, including targeted e-commerce messages and personalized one-to-one emails.