{"library":"mailchimp-marketing","title":"Mailchimp Marketing Python Client","description":"The `mailchimp-marketing` library is the official Python client for the Mailchimp Marketing API. It allows developers to interact with Mailchimp to manage audiences, campaigns, reports, and other marketing-related data programmatically. As of version 3.0.80, it provides a robust interface to the Mailchimp API. The library is auto-generated from a codegen tool, suggesting its release cadence is tied to updates in the underlying Mailchimp API specification.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install mailchimp-marketing"],"cli":null},"imports":["import mailchimp_marketing as MailchimpMarketing\nclient = MailchimpMarketing.Client()","from mailchimp_marketing.api_client import ApiClient\ntry: ... except ApiClient.ApiException as e: ..."],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport mailchimp_marketing as MailchimpMarketing\nfrom mailchimp_marketing.api_client import ApiClient\n\n# It's recommended to store your API key and server prefix as environment variables.\n# The server prefix (e.g., 'us1', 'us19') is typically the last part of your API key (e.g., 'YOUR_KEY-us19').\n\napi_key = os.environ.get(\"MAILCHIMP_API_KEY\", \"\")\nserver_prefix = os.environ.get(\"MAILCHIMP_SERVER_PREFIX\", \"\")\n\n# Fallback to extract server prefix from API key if not explicitly set\nif not server_prefix and '-' in api_key:\n    server_prefix = api_key.split('-')[-1]\n\nif not api_key:\n    print(\"ERROR: MAILCHIMP_API_KEY environment variable not set.\")\n    print(\"Please set it to your Mailchimp API key. Example: export MAILCHIMP_API_KEY='yourkey-us1'\")\n    exit(1)\n\nif not server_prefix:\n    print(\"ERROR: MAILCHIMP_SERVER_PREFIX environment variable not set and could not be extracted from API key.\")\n    print(\"Please set it to your Mailchimp server prefix (e.g., 'us1').\")\n    exit(1)\n\n# Initialize the Mailchimp Marketing Client\nclient = MailchimpMarketing.Client()\nclient.set_config({\n    \"api_key\": api_key,\n    \"server\": server_prefix\n})\n\ntry:\n    # Example: Get basic account information (ping the API)\n    response = client.ping.get()\n    print(\"Successfully connected to Mailchimp API. Health status:\")\n    print(response)\n\n    # Example: List all audiences (uncomment to run)\n    # print(\"\\nFetching audiences...\")\n    # audiences_response = client.lists.get_all_lists()\n    # if 'lists' in audiences_response:\n    #     for list_item in audiences_response['lists']:\n    #         print(f\"  - Name: {list_item.get('name')}, ID: {list_item.get('id')}\")\n    # else:\n    #     print(\"No audiences found or unexpected response.\")\n\nexcept ApiClient.ApiException as e:\n    print(f\"Error calling Mailchimp API: {e}\")\n    print(f\"Status: {e.status}, Reason: {e.reason}, Body: {e.body}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the Mailchimp client using API key and server prefix from environment variables and perform a basic API call (ping). It also includes a commented-out example for listing audiences. Ensure `MAILCHIMP_API_KEY` and `MAILCHIMP_SERVER_PREFIX` are set in your environment.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"3.0.80","pypi_latest":"3.0.80","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.3,"avg_import_s":0.7,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.67,"mem_mb":11.8,"disk_size":"24.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.51,"mem_mb":11.8,"disk_size":"25M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.8,"mem_mb":13.3,"disk_size":"26.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.74,"mem_mb":13.3,"disk_size":"27M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.79,"mem_mb":13.8,"disk_size":"18.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.1,"import_time_s":0.79,"mem_mb":13.8,"disk_size":"19M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.75,"mem_mb":14.1,"disk_size":"18.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.1,"import_time_s":0.74,"mem_mb":14.1,"disk_size":"19M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.64,"mem_mb":11.6,"disk_size":"23.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"mailchimp-marketing","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.61,"mem_mb":11.6,"disk_size":"24M"}]}}