Mailchimp Marketing API v3 code snippets for PHP, JavaScript, and Python. Ready-to-use REST API calls with authentication, error handling, and tabbed placeholders.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Mailchimp Marketing API v3 code snippets for VS Code. Ready-to-use REST API calls for PHP, JavaScript, and Python with authentication, error handling, and tabbed placeholders.
Quick Start
Type mc-api-init to set up the API client
Type mc-api- to see all available snippets
Tab through placeholders to customize
All snippets use the helper function from mc-api-init. Always insert mc-api-init first, then add individual API call snippets inside the main function.
Available Snippets
Type mc-api- in any PHP, JavaScript, TypeScript, or Python file.
Setup & Connection
Prefix
Description
mc-api-init
Initialize API client with key and datacenter
mc-api-ping
Verify API connection
Audiences & Members
Prefix
Description
mc-api-lists
Get all audiences
mc-api-list-members
List members of an audience
mc-api-get-member
Get a single member by email
mc-api-subscribe
Add/subscribe a member
mc-api-update-member
Update member info
mc-api-upsert
Create or update a member (PUT)
mc-api-unsubscribe
Unsubscribe a member
mc-api-delete-member
Permanently delete a member (GDPR)
mc-api-member-tags
Add or remove member tags
mc-api-merge-fields
List audience merge fields
mc-api-segments
List audience segments
mc-api-create-segment
Create a segment
Campaigns
Prefix
Description
mc-api-campaigns
List all campaigns
mc-api-create-campaign
Create a campaign
mc-api-campaign-content
Set campaign HTML content
mc-api-send-campaign
Send a campaign
mc-api-send-test
Send a test email
mc-api-schedule-campaign
Schedule a campaign
mc-api-reports
Get campaign reports
Templates & Automations
Prefix
Description
mc-api-templates
List templates
mc-api-create-template
Create a template
mc-api-automations
List automations
mc-api-batch
Start a batch operation
Language Support
Each snippet generates idiomatic code for its language:
Language
HTTP Client
Auth Method
PHP
cURL
Basic Auth
JavaScript / TypeScript
fetch + Buffer
Basic Auth (base64)
Python
requests
Auth tuple
How It Works
Every snippet starts with mc-api-init which creates a reusable request helper function. All other snippets call this function — just tab through the placeholders:
API Key — your Mailchimp API key (includes datacenter suffix like -us1)
List/Campaign IDs — paste from your Mailchimp dashboard
Email addresses, names, content — customize per call