SDKs overview
Software Development Kits (SDKs) and client libraries for the ActiveCampaign API offer developers pre-built functionalities to integrate ActiveCampaign's marketing automation, CRM, and sales features into their applications. These tools abstract the underlying RESTful API calls, allowing developers to interact with the API using native language constructs rather than manually composing HTTP requests and parsing JSON responses. This approach can reduce development time and potential error points by providing type-safe methods and handling authentication and error management internally.
The ActiveCampaign API is designed around REST principles, utilizing standard HTTP methods (GET, POST, PUT, DELETE) for resource manipulation. Authentication for all SDKs and direct API calls is performed using an API key, which must be included in requests to access protected resources. Developers can find their API key and URL within their ActiveCampaign account settings, as outlined in the ActiveCampaign API authentication overview. The API supports various resources, including contacts, accounts, campaigns, automations, and deals, enabling comprehensive programmatic control over the ActiveCampaign platform.
Official SDKs by language
ActiveCampaign provides official SDKs for several popular programming languages. These SDKs are maintained by ActiveCampaign and are designed to offer a consistent and reliable interface for interacting with the API. Each SDK typically includes methods corresponding to the API's endpoints, simplifying tasks such as creating contacts, sending campaigns, or managing deals. The official SDKs are hosted on their respective package managers and are regularly updated to reflect changes in the ActiveCampaign API.
| Language | Package Name | Install Command | Maturity |
|---|---|---|---|
| PHP | activecampaign/activecampaign-api-php |
composer require activecampaign/activecampaign-api-php |
Stable |
| Python | activecampaign-api-python |
pip install activecampaign-api-python |
Stable |
| Ruby | activecampaign_api |
gem install activecampaign_api |
Stable |
| Node.js | activecampaign-api-node |
npm install activecampaign-api-node |
Stable |
These official SDKs are the recommended approach for integrating with the ActiveCampaign API, as they are directly supported and maintained by ActiveCampaign. They typically provide comprehensive coverage of the API's features and are tested against the latest API versions. For detailed usage and specific method calls, developers should consult the official ActiveCampaign developer documentation.
Installation
Installing an ActiveCampaign SDK involves using the package manager specific to your chosen programming language. The process is generally straightforward, requiring a single command to download and add the library to your project's dependencies.
PHP Installation
For PHP projects, Composer is used to manage dependencies. Ensure Composer is installed on your system. Then, navigate to your project's root directory in your terminal and execute:
composer require activecampaign/activecampaign-api-php
This command downloads the PHP SDK and its dependencies, adding them to your vendor/ directory and updating your composer.json and composer.lock files.
Python Installation
Python developers use pip for package management. Open your terminal or command prompt and run:
pip install activecampaign-api-python
This command fetches the Python SDK from PyPI and installs it into your Python environment. It is recommended to use a Python virtual environment to manage project-specific dependencies.
Ruby Installation
Ruby projects typically use Bundler with RubyGems. First, add the gem to your Gemfile:
gem 'activecampaign_api'
Then, from your project directory, run:
bundle install
This installs the Ruby SDK and its dependencies.
Node.js Installation
For Node.js applications, npm (Node Package Manager) is used. In your project's directory, execute:
npm install activecampaign-api-node
This command downloads the Node.js SDK and adds it to your node_modules/ directory, updating your package.json file.
Quickstart example
This quickstart example demonstrates how to initialize the ActiveCampaign API client and add a new contact using the Python SDK. Ensure you have your ActiveCampaign API URL and Key available from your account settings.
from activecampaign.client import ActiveCampaignClient
# Replace with your actual API URL and Key
API_URL = "https://YOUR_ACCOUNT.api-us1.com"
API_KEY = "YOUR_API_KEY"
client = ActiveCampaignClient(API_URL, API_KEY)
try:
# Define contact details
contact_data = {
"contact": {
"email": "[email protected]",
"firstName": "Test",
"lastName": "Contact",
"phone": "+15551234567"
}
}
# Add a new contact
response = client.contacts.create_contact(contact_data)
if response.status_code == 201:
print("Contact created successfully:")
print(response.json())
else:
print(f"Error creating contact: {response.status_code}")
print(response.json())
except Exception as e:
print(f"An error occurred: {e}")
This Python snippet initializes the ActiveCampaignClient with your API credentials. It then constructs a dictionary containing the new contact's details and uses the client.contacts.create_contact() method to send the data to the API. The response is checked for a 201 Created status code, indicating successful contact creation, and the JSON response is printed. Error handling is included to catch potential issues during the API call.
Community libraries
Beyond the official SDKs, the ActiveCampaign API ecosystem includes various community-contributed libraries and wrappers. These libraries are developed and maintained by individual developers or third-party organizations and can offer support for additional programming languages or specialized functionalities not present in the official SDKs. While community libraries can provide flexibility, their maintenance and support levels may vary.
Developers often create community libraries to integrate ActiveCampaign with specific frameworks (e.g., a Django ActiveCampaign integration) or to provide a more idiomatic interface for a language not officially supported. When considering a community library, it is advisable to check its documentation, recent commit history, issue tracker, and community activity to assess its reliability and ongoing support. Popular platforms for discovering such libraries include GitHub, language-specific package repositories (like PyPI for Python or npm for Node.js), and developer forums. Always review the source code and licensing of community projects before integrating them into production systems.
Some examples of community-driven resources or integrations that interact with the ActiveCampaign API include:
- ActiveCampaign for Laravel: A package designed to integrate ActiveCampaign with the Laravel PHP framework, simplifying common tasks for web applications built with Laravel.
- Third-party connectors: Services like Tray.io provide ActiveCampaign API integrations for workflow automation, allowing non-developers to connect ActiveCampaign with other business applications without writing code.
- Specialized Python wrappers: Developers may create lightweight Python wrappers for specific API endpoints or use cases, often tailored to particular project requirements.
These community efforts demonstrate the extensibility of the ActiveCampaign API and the active developer community surrounding it. While not officially supported, they can offer valuable tools for specific integration scenarios.