You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何开发需在URL中集成API密钥的API?ActiveCampaign API调用求助

How to Structure a Valid ActiveCampaign API GET Request for Contact Lists

Based on your description, it looks like you’re working with ActiveCampaign’s older v1 API (given the ?call=contact_list parameter format), but I’ll cover both that approach (to match your example) and the recommended v3 API (the current supported version) to give you the best options.

For the v1 API (Matching Your Example Endpoint)

ActiveCampaign’s v1 API requires two mandatory authentication parameters in the query string, plus the call parameter to specify the action you want to perform:

  • api_key: Your unique API key from your ActiveCampaign account settings
  • api_url: The base URL you retrieved (https://url.api-us1.com)
  • call: The action to execute (in your case, contact_list)

Corrected Request Code

Here’s how to adjust your existing requests code to include all required parameters:

import requests

# Replace with your actual API credentials
api_key = "YOUR_ACTIVECAMPAIGN_API_KEY"
base_url = "https://url.api-us1.com"

# Construct the full request URL and parameters
request_url = f"{base_url}/api/example.php"
params = {
    "call": "contact_list",
    "api_key": api_key,
    "api_url": base_url
}

# Execute the GET request
response = requests.get(request_url, params=params)

# Handle the response
if response.status_code == 200:
    # v1 returns XML by default; add "&output=json" to params for JSON
    contact_lists = response.text
    print(contact_lists)
else:
    print(f"Request failed: {response.status_code}")
    print(response.text)

The v3 API is more modern, RESTful, and natively supports JSON. For retrieving contact lists, here’s how to structure the request properly:

  • Base URL: https://url.api-us1.com/api/3
  • Endpoint: /contacts/lists
  • Authentication: Pass your API key in the Api-Token request header

v3 Request Code

import requests

api_key = "YOUR_ACTIVECAMPAIGN_API_KEY"
base_url = "https://url.api-us1.com/api/3"

# Set up authentication headers
headers = {
    "Api-Token": api_key,
    "Content-Type": "application/json"
}

# Execute the GET request to the contact lists endpoint
response = requests.get(f"{base_url}/contacts/lists", headers=headers)

# Handle the response
if response.status_code == 200:
    # v3 returns JSON by default
    contact_lists = response.json()
    print(contact_lists)
else:
    print(f"Request failed: {response.status_code}")
    print(response.json())

Key Tips

  • Always replace YOUR_ACTIVECAMPAIGN_API_KEY with the actual key from your account settings.
  • For the v1 API, ensure the api_url parameter exactly matches your base URL (no trailing slashes).
  • If you’re building a new integration, stick with v3—it’s the officially supported version with better documentation and functionality.

内容的提问来源于stack exchange,提问作者RustyShackleford

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:07:32