用python编写的activecampaign api

activecampaign-python的Python项目详细描述


活动活动python

用python编写的activecampaign api包装器。

此库支持最新的API版本3。如果您正在寻找也受activecampaign支持的api版本1,请检查下面的内容。

安装(API v3)

pip install activecampaign-python

要求

- requests

用法

客户端实例化
from activecampaign.client import Client
client = Client(URL, API_KEY)

自动化

列出所有自动操作
response = client.automations.list_all_automations()

联系人

创建联系人
data = {
	"contact": {
		"email": "johndoe@example.com",
		"firstName": "John",
		"lastName": "Doe",
		"phone": "7223224241"
	}
}
response = client.contacts.create_a_contact(data)

创建或更新联系人
data = {
	"contact": {
		"email": "johndoe@example.com",
		"firstName": "John",
		"lastName": "Doe",
		"phone": "7223224241"
	}
}
response = client.contacts.create_or_update_contact(data)

检索联系人
response = client.contacts.retrieve_a_contact("contact_id")

更新联系人的列表状态
data = {
    "contactList": {
        "list": 2,
        "contact": 1,
        "status": 1
    }
}
response = client.contacts.update_list_status_for_a_contact(data)

更新联系人
data = {
	"contact": {
		"email": "johndoe@example.com",
		"firstName": "John",
		"lastName": "Doe"
	}
}
response = client.contacts.update_a_contact("contact_id", data)

删除联系人
response = client.contacts.delete_a_contact("contact_id")

列出所有联系人
response = client.contacts.list_all_contacts()

Additionally, you can filter a contact:
response = client.contacts.list_all_contacts(email="johndoe@example.com")

For more query params: https://developers.activecampaign.com/reference#list-all-contacts

列出联系人所在的所有自动操作
response = client.contacts.list_all_automations_the_contacts_is_in("contact_id")

检索联系人得分值
response = client.contacts.retrieve_a_contacts_score_value("contact_id")

将联系人添加到自动化系统中
data = {
    "contactAutomation": {
        "contact": 1,
        "automation": 1
    }
}
response = client.contacts.add_a_contact_to_an_automation(data)

检索联系人所在的自动化系统

response = client.contacts.retrieve_an_automation_a_contact_is_in("contact_automation_id")

从自动化中删除联系人

response = client.contacts.remove_a_contact_from_an_automation("contact_automation_id")

列出联系人所处的所有自动操作
response = client.contacts.list_all_automations_a_contact_is_in()

创建自定义字段
data = {
	"field": {
		"type": "textarea",
		"title": "Field Title",
		"descript": "Field description",
		"isrequired": 1,
		"perstag": "Personalized Tag",
		"defval": "Defaut Value",
		"visible": 1,
		"ordernum": 1
    }
}
response = client.contacts.create_a_custom_field(data)

检索自定义字段
response = client.contacts.retrieve_a_custom_field("field_id")

更新自定义字段
data = {
	"field": {
		"type": "textarea",
		"title": "Field Title",
		"descript": "Field description",
		"isrequired": 1,
		"perstag": "Personalized Tag",
		"defval": "Defaut Value",
		"visible": 1,
		"ordernum": 1
    }
}
response = client.contacts.create_a_custom_field("field_id", data)

删除自定义字段
response = client.contacts.delete_a_custom_field("field_id")

列出所有自定义字段
response = client.contacts.list_all_custom_fields()

创建与列表的自定义字段关系
data = {
	"fieldRel": {
		"field": 8,
		"relid": 2
	}
}
response = client.contacts.create_a_custom_field_relationship_to_list(data)

创建自定义字段选项
data = {
    "field": 1,
    "label": "my custom label",
    "value": 1,
    "orderid": 1,
    "isdefault": True
}
response = client.contacts.create_custom_field_options(data)

检索字段选项
response = client.contacts.retrieve_field_options("field_id")

交易

创建交易
data = {
  "deal": {
    "contact": "51",
    "description": "This deal is an important deal",
    "currency": "usd",
    "group": "1",
    "owner": "1",
    "percent": None,
    "stage": "1",
    "status": 0,
    "title": "AC Deal",
    "value": 45600
  }
}
response = client.deals.create_a_deal(data)

检索交易
response = client.deals.retrieve_a_deal("deal_id")

更新交易
data = {
  "deal": {
    "contact": "51",
    "description": "This deal is an important deal",
    "currency": "usd",
    "group": "1",
    "owner": "1",
    "percent": None,
    "stage": "1",
    "status": 0,
    "title": "AC Deal",
    "value": 45600
  }
}
response = client.deals.update_a_deal(data)

删除交易
response = client.deals.delete_a_deal("deal_id")

列出所有交易
response = client.deals.list_all_deals()

Additionally, you can filter a deal:
query = {
    "filters[stage]": 1
}
response = client.deals.list_all_deals(**query)

For more query params: https://developers.activecampaign.com/reference#list-all-deals

创建交易注释
data = {
  "note": {
    "note": "Note for the deal"
  }
}
response = client.deals.create_a_deal_note("deal_id", data)

更新交易说明
data = {
  "note": {
    "note": "Update with more info"
  }
}
response = client.deals.update_a_deal_note("deal_id", "note_id", data)

列出所有管道
response = client.deals.list_all_pipelines()

Additionally, you can filter a pipeline:
query = {
    "filters[title]": "My pipeline"
}
response = client.deals.list_all_pipelines(**query)

For more query params: https://developers.activecampaign.com/reference#list-all-pipelines

列出所有阶段
response = client.deals.list_all_stages()

Additionally, you can filter a stage:
query = {
    "filters[d_groupid]": 1
}
response = client.deals.list_all_stages(**query)

For more query params: https://developers.activecampaign.com/reference#list-all-deal-stages

列表

创建列表
data = {
	"list": {
		"name": "Name of List",
		"stringid": "Name-of-list",
		"sender_url": "http://activecampaign.com",
		"sender_reminder": "You are receiving this email as you subscribed to a newsletter when making an order on our site.",
		"send_last_broadcast": 0,
		"carboncopy": "",
		"subscription_notify": "",
		"unsubscription_notify": "",
		"user": 1
	}
}
response = client.lists.create_a_list(data)

检索列表
response = client.lists.retrieve_a_list("list_id")

删除列表
response = client.lists.delete_a_list("list_id")

检索所有列表
response = client.lists.retrieve_all_lists()

创建列表组权限

data = {
	"listGroup": {
		"listid": 19,
		"groupid": 1
	}
}
response = client.lists.create_a_list_group_permission(data)

注释

创建注释

data = {
	"note": {
		"note": "This is the text of the note",
		"relid": 2,
		"reltype": "Subscriber"
	}
}
response = client.notes.create_a_note(data)

检索注释

response = client.notes.retrieve_a_note("note_id")

更新注释

data = {
	"note": {
		"note": "This is the text of the note",
		"relid": 2,
		"reltype": "Subscriber"
	}
}
response = client.notes.update_a_note("note_id", data)

删除注释

response = client.notes.delete_a_note("note_id")

任务

创建任务
data = {
  "dealTask": {
    "title":null,
    "ownerType":"contact",
    "relid":"7",
    "status":0,
    "note":"Testing Task",
    "duedate":"2017-02-25T12:00:00-06:00",
    "edate":"2017-02-25T12:15:00-06:00",
    "dealTasktype":"1"
  }
}
response = client.tasks.create_a_task(data)

检索任务
response = client.tasks.retrieve_a_task("task_id")

更新任务
data = {
  "dealTask": {
    "title":null,
    "ownerType":"contact",
    "relid":"7",
    "status":0,
    "note":"Testing Task",
    "duedate":"2017-02-25T12:00:00-06:00",
    "edate":"2017-02-25T12:15:00-06:00",
    "dealTasktype":"1"
  }
}
response = client.tasks.update_a_task("task_id", data)

删除任务
response = client.tasks.delete_a_task("task_id")

列出所有任务
response = client.tasks.list_all_tasks()

Additionally, you can filter a task:
query = {
    "filters[title]": "My task"
}
response = client.deals.list_all_tasks(**query)

For more query params: https://developers.activecampaign.com/reference#list-all-tasks

用户

创建用户
response = client.users.create_a_user(data)

检索用户
response = client.users.retrieve_a_user("user_id")

通过电子邮件检索用户
response = client.users.retrieve_a_user_by_email("email")

通过用户名检索用户
response = client.users.retrieve_a_user_by_username("username")

检索登录用户
response = client.users.retrieve_logged_in_user()

更新用户
response = client.users.update_a_user("user_id", data)

删除用户
response = client.users.delete_a_user("user_id")

列出所有用户
response = client.users.list_all_users()

webhooks

创建webhook
data = {
    "webhook": {
        "name": "My Hook",
        "url": "http://example.com/my-hook",
        "events": [
            "subscribe",
            "unsubscribe",
            "sent"
        ],
        "sources": [
            "public",
            "system"
        ]
    }
}
response = client.webhooks.create_a_webhook(data)

检索webhook
response = client.webhooks.retrieve_a_webhook("webhook_id")

删除Webhook
response = client.webhooks.delete_a_webhook("webhook_id")

列出所有webhook
response = client.webhooks.list_all_webhooks()

Additionally, you can filter a webhook:
query = {
    "filters[name]": "My webhook"
}
response = client.deals.list_all_webhooks(**query)

For more query params: https://developers.activecampaign.com/reference#get-a-list-of-webhooks

列出所有Webhook事件
response = client.webhooks.list_all_webhook_events()

关于API v1

你可以克隆并签出我们的标签v0.1.1

$ git clone https://github.com/GearPlug/activecampaign-python.git
$ git checkout tags/v0.1.1 -b <branch_name>

也可以在pip中安装此版本

$ pip install activecampaign-python=0.1.1

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java操作数组上的字符串   java JAXB内容未实例化   图形在Java中如何绘制垂直居中的字符串?   java Apache Ant:使用Junit时出现NoClassDefFoundError   java无法从服务器上运行perl脚本   如何在java中沿树进行预排序遍历,并打印0和1以对应每个节点上的特定字符?   java如何创建。p12文件?   java线程访问无效   java只匹配命名空间中的XML节点,而不知道NS前缀   从java获取2d arraylist元素   数组Java动态集合对象   java Xpath通过通配符或布尔运算查找以相同名称开头的节点?   java注释元素类型   java在中看不到Super()。反编译后的类文件