HubSpot API wrapper written in Python.
pip install hubspot-python
- requests
from hubspot.client import Client
client = Client(APP_ID, HAPIKEY, CLIENT_ID, CLIENT_SECRET)
response = client.companies.get_companies(data)
data = {
"name": "A company name",
"description": "A company description"
}
response = client.companies.create_company(data)
response = client.companies.delete_company(COMPANY_ID)
response = client.companies.get_recently_created_companies()
response = client.companies.get_company(COMPANY_ID)
response = client.contact_lists.get_contact_lists()
data = {
"name": "tweeters",
"dynamic": true,
"portalId": 62515,
"filters":
[
[{
"operator": "EQ",
"value": "@hubspot",
"property": "twitterhandle",
"type": "string"
}]
]
}
response = client.contact_lists.create_contact_list(data)
response = client.contact_lists.delete_contact_list(CONTACT_LIST_ID)
response = client.contact_lists.get_recently_added_contacts_in_a_list()
response = client.contact_lists.get_contact_list(CONTACT_LIST_ID)
data = {
"vids": [
3057124,
5524274
],
"emails": [
"testingapis@hubspot.com"
]
}
response = client.contact_lists.add_contact_to_list(CONTACT_LIST_ID, data)
response = client.contacts.get_contacts()
data = {
"email": "testingapis@hubspot.com",
"firstname": "Adrian",
"lastname": "Mott",
"website": "http://hubspot.com",
"company": "HubSpot",
"phone": "555-122-2323",
"address": "25 First Street",
"city": "Cambridge",
"state": "MA",
"zip": "02139",
}
response = client.contacts.create_contact(data)
response = client.contacts.delete_contact(CONTACT_ID)
response = client.contacts.get_recently_created_contacts()
response = client.contacts.get_contact(CONTACT_ID)
response = client.deals.get_deals()
data = {
"dealname": "Tim's Newer Deal",
"dealstage": "appointmentscheduled",
"pipeline": "default",
"hubspot_owner_id": "24",
"closedate": 1409443200000,
"amount": "60000",
"dealtype": "newbusiness",
}
response = client.deals.create_deal(data)
response = client.deals.delete_deal(DEAL_ID)
response = client.deals.get_recently_created_deals()
response = client.deals.get_deal(DEAL_ID)
response = client.fields.get_fields(MODULE)
response = client.integrations.get_account_details()
response = client.integrations.get_daily_api_usage()
response = client.webhooks.get_settings()
data = {
"webhookUrl": "https://testing.com/webhook-modified",
"maxConcurrentRequests": 25
}
response = client.webhooks.update_settings(data)
response = client.webhooks.get_subscriptions()
data = {
"subscriptionDetails" : {
"subscriptionType" : "company.propertyChange",
"propertyName" : "companyname"
},
"enabled": False
}
response = client.webhooks.create_subscription(data)
data = {
"enabled": False
}
response = client.webhooks.create_subscription(SUBSCRIPTION_ID, data)
response = client.webhooks.delete_subscription(SUBSCRIPTION_ID)
response = client.workflows.get_workflows()
response = client.workflows.get_workflow(WORKFLOW_ID)
data = {
"name": "Test Workflow",
"type": "DRIP_DELAY",
"onlyEnrollsManually": true,
"actions": [
{
"type": "DELAY",
"delayMillis": 3600000
},
{
"newValue": "HubSpot",
"propertyName": "company",
"type": "SET_CONTACT_PROPERTY"
},
{
"type": "WEBHOOK",
"url": "https://www.myintegration.com/webhook.php",
"method": "POST",
"authCreds": {
"user": "user",
"password": "password"
}
}
]
}
response = client.workflows.create_workflow(data)
response = client.workflows.delete_workflow(WORKFLOW_ID)
response = client.workflows.enroll_a_contact_into_workflow(WORKFLOW_ID, EMAIL)
response = client.workflows.unenroll_a_contact_into_workflow(WORKFLOW_ID, EMAIL)