HubSpot
Interact with HubSpot CRM directly via the HubSpot API (api.hubapi.com).
Setup (one-time)
- 1. In HubSpot: Settings → Integrations → Private Apps → Create a private app
- Give it scopes:
crm.objects.contacts.read, crm.objects.contacts.write, crm.objects.companies.read, crm.objects.companies.write, crm.objects.deals.read, crm.objects.deals.write, INLINECODE7 - Copy the access token
- Set environment variable:
CODEBLOCK0
Queries
Search contacts
CODEBLOCK1
List contacts
CODEBLOCK2
Get a specific object
CODEBLOCK3
List companies
CODEBLOCK4
Search companies
CODEBLOCK5
List deals
CODEBLOCK6
Search deals
CODEBLOCK7
List tickets
CODEBLOCK8
Create a contact
CODEBLOCK9
Create a company
CODEBLOCK10
Create a deal
CODEBLOCK11
Update an object
CODEBLOCK12
Associate objects
CODEBLOCK13
List pipelines
CODEBLOCK14
List owners
CODEBLOCK15
HubSpot
通过 HubSpot API(api.hubapi.com)直接与 HubSpot CRM 交互。
一次性设置
- 1. 在 HubSpot 中:设置 → 集成 → 私有应用 → 创建私有应用
- 授予以下权限范围:crm.objects.contacts.read、crm.objects.contacts.write、crm.objects.companies.read、crm.objects.companies.write、crm.objects.deals.read、crm.objects.deals.write、tickets
- 复制访问令牌
- 设置环境变量:
HUBSPOT_TOKEN=pat-na1-...
查询操作
搜索联系人
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py search contacts --query john
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py search contacts --email john@example.com
列出联系人
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py list contacts --limit 20
获取特定对象
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py get contacts 12345
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py get companies 67890
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py get deals 11111
列出公司
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py list companies --limit 20
搜索公司
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py search companies --query Acme
列出交易
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py list deals --limit 20
搜索交易
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py search deals --query enterprise
列出工单
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py list tickets --limit 20
创建联系人
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py create contacts --email new@example.com --firstname Jane --lastname Doe
创建公司
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py create companies --name Acme Corp --domain acme.com
创建交易
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py create deals --dealname Enterprise Plan --amount 50000 --pipeline default --dealstage appointmentscheduled
更新对象
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py update contacts 12345 --email new@example.com --phone +1234567890
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py update deals 11111 --dealstage closedwon --amount 75000
关联对象
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py associate contacts 12345 companies 67890
列出管道
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py pipelines deals
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py pipelines tickets
列出所有者
bash
python3 /mnt/skills/user/hubspot/scripts/hubspot_query.py owners