Though it's an old question, I am posting this answer as the selected answer works no more. The suggested 'API Playground' has been discontinued by MailChimp.
I am using simple CURL commands. You can implement CURL in the language you are working on.
Note that ${dc}
in CURL commands to be replaced by your MailChimp server prefix.
- To do this, first you need to fetch/check the id of the list:
curl -X GET \
'https://${dc}.api.mailchimp.com/3.0/lists?fields=<SOME_ARRAY_VALUE>&exclude_fields=<SOME_ARRAY_VALUE>&count=10&offset=0&before_date_created=<SOME_STRING_VALUE>&since_date_created=<SOME_STRING_VALUE>&before_campaign_last_sent=<SOME_STRING_VALUE>&since_campaign_last_sent=<SOME_STRING_VALUE>&email=<SOME_STRING_VALUE>&sort_field=<SOME_STRING_VALUE>&sort_dir=<SOME_STRING_VALUE>&has_ecommerce_store=<SOME_BOOLEAN_VALUE>' \
--user "anystring:${apikey}"'
- Once you get the designated ID (
{list_id}
) from the above output, fetch the interest categories:
curl -X GET \
'https://${dc}.api.mailchimp.com/3.0/lists/{list_id}/interest-categories?fields=<SOME_ARRAY_VALUE>&exclude_fields=<SOME_ARRAY_VALUE>&count=10&offset=0&type=<SOME_STRING_VALUE>' \
--user "anystring:${apikey}"'
- Note
{interest_category_id}
from the above output. Finally to get the interest details, use:
curl -X GET \
'https://${dc}.api.mailchimp.com/3.0/lists/{list_id}/interest-categories/{interest_category_id}/interests?fields=<SOME_ARRAY_VALUE>&exclude_fields=<SOME_ARRAY_VALUE>&count=10&offset=0' \
--user "anystring:${apikey}"'
A sample PHP function (for Step 3 only) will be as:
function mailchimp_findgrpids()
{
$mcurl = 'https://'.MAILCHIMP_SERVER_PREFIX.'.api.mailchimp.com/3.0/lists/'.MAILCHIMP_LIST.'/interest-categories/'.MAILCHIMP_INTEREST_CAT.'/interests';
$ch = curl_init($mcurl);
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . MAILCHIMP_API_KEY);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
}