Simple API wrapper for Mailchimp API V3

v1.0.6 2016-08-02 12:04 UTC

This package is not auto-updated.

Last update: 2022-11-26 07:52:23 UTC



Add the following to your composer.json

    "require": {
        "pacely/mailchimp-apiv3": "dev-master"

Laravel Users

We've added some classes to help Laravel 5 users make use of the library with ease.

Service Provider

You can register our service provider in your app.php config file.

// config/app.php
'providers' => [


If you prefer facades, make sure you add this as well:

// config/app.php
'aliases' => [
    'MC' => Mailchimp\MailchimpFacade::class

NOTE: Make sure not to register the facade with the Mailchimp alias, as that could potentially clash with the base class.


There are only one configuration option you need to fill in. Publish the config by running:

php artisan vendor:publish

Now, the config file will be located under config/mailchimp.php:


return [

    | Mailchimp API key
    | To obtain an API key, go to under your profile
    | you will find Extras -> API keys. Paste the key below.
    'apikey' => ''


There's one method to rule them all:

request($resource, $arguments = [], $method = 'GET') // $arguments is used as POST data or GET parameters, depending on the method used.

But its clever enough to map these calls aswell:

get($resource, array $options = [])
head($resource, array $options = [])
put($resource, array $options = [])
post($resource, array $options = [])
patch($resource, array $options = [])
delete($resource, array $options = [])


We use offset and count in the query string to paginate data, because it provides greater control over how you view your data. Offset defaults to 0, so if you use offset=1, you'll miss the first element in the dataset. Count defaults to 10.



Most endpoints don't currently support filtering, but we plan to add these capabilities over time. Schemas will tell you which collections can be filtered, and what to include in your query string.


Partial Response

To cut down on data transfers, pass a comma separated list of fields to include or exclude from a certain response in the query string. The parameters fields and exclude_fields are mutually exclusive and will throw an error if a field isn't valid in your request.


Behind Proxy

If you are behind a proxy, you can use setProxy directly on the class.

setProxy(host : string, port : int, [ssl : bool = false], [username = null], [password = null]);

See the example.


Collection object

All queries will return an instance of the Illuminate\Support\Collection object, which is really easy to work with. If you don't want to use the Collection object however, you can transform it into an array using $result->toArray().

$mc = new Mailchimp('<api-key>', '<guzzle-options[array]>');

// Get 10 lists starting from offset 10 and include only a specific set of fields
$result = $mc->request('lists', [
    'fields' => ',,lists.stats.member_count',
    'offset' => 10,
    'count' => 10

// Will fire this query: 
// GET,,lists.stats.member_count&count=10

// Returns object(Illuminate\Support\Collection)

// Returns the first item

// Returns 3 items

// Returns a JSON string

// Returns an array

You can use a simple foreach/for loop or use the built in each(callable $callback) provided by our Collection object to loop through your items.

$result->each(function ($item) {
    echo $item['name'].' ('.$item['stats']['member_count'].')'.PHP_EOL;

There's alot more you can do with the Collection object.

Create lists

// All these fields are required to create a new list.
$result = $mc->post('lists', [
    'name' => 'New list',
    'permission_reminder' => 'You signed up for updates on Greeks economy.',
    'email_type_option' => false,
    'contact' => [
        'company' => 'Doe Ltd.',
		'address1' => 'DoeStreet 1',
		'address2' => '',
		'city' => 'Doesy',
		'state' => 'Doedoe',
		'zip' => '1672-12',
		'country' => 'US',
		'phone' => '55533344412'
    'campaign_defaults' => [
        'from_name' => 'John Doe',
        'from_email' => '',
        'subject' => 'My new campaign!',
        'language' => 'US'


$result = $mc->get('lists/e04d611199', [
    'fields' => 'id,name,stats.member_count'


$mc->setProxy('', 10, true, 'username', 'password');

$result = $mc->get('lists/e04d611199', [
    'fields' => 'id,name,stats.member_count'

Further documentation

You should read through Mailchimp's API v3 documentation (I know, it's pretty rough. Should get better soon.). To find out which resources is available, take a look at the JSON API Schema for Mailchimp.