Skip to main content

HubSpot Private API

Python library to interact with HubSpot's Private API

This is a Python library of HubSpot's Private API, which was reverse-engineered from their Mobile App. It allows users to do any kind of LLM automation / auto-reply (to live chats).

It was developed because HubSpot doesn't bother making their Public API feature-complete, and have had some modules in BETA for over a year (khm.. Conversations).

Additional features, which their Public API doesn't support:

  • Conversation: access Live Chat channels
  • Conversation: Assign the conversation to an agent
  • Conversation: Tag an agent inside a comment

Demo script

from hubspot_api import HubSpotApi

def cb_auth() -> str: # In case of 2FA, you'll need to return the code
    code = input('Enter 2FA code: ')
    return code

hs = HubSpotApi('my-email@provider.com', 'superSecretPw', cb_auth)

# You can also do hs.conversations.get_threads() to get all threads
threads = hs.conversations.get_unassigned_threads()
# Needed for assigning threads to agents
agents = hs.conversations.get_agents()

for t in threads:
    print('---------\nSubject:',t.subject, t.timestamp)
    msgs = t.read_messages()
    email_msgs = [f"FROM: {msg.fromName}, AT: {msg.timestamp}, EMAIL TEXT:\n{msg.text}" for msg in msgs]
    full_conversation = f'EMAIL SUBJECT: {t.subject}\n' + '\n\n'.join(email_msgs).lower()

    # Do some smart LLM stuff here

    if "api" in full_conversation or "code" in full_conversation:
        t.assign(agents.find('John Doe')) # Tech support
    elif "shipping" in full_conversation:
        t.assign(agents.find('Erik The Red')) # Ops/shipping
    elif "digital agency" in full_conversation:
        # They are trying to sell us something
        t.send_message("Thank you for your email, but we are not interested.")
        t.close()
    elif "tiktok" in full_conversation:
        t.spam() # TikTok? Spam for sure
    else:
        # Writing a comment (and tagging an agent) is also supported
        agent = agents.find('John Doe')
        t.comment(f'Hi {agent}, could you assign this to the best person?')

Module support

While HubSpot has many different modules (contacts, deals, tickets, etc.), most of them work as expected with their public API. Only Conversations are in "BETA", and have been for over a year now.

Installation

To install this Python package, run the following command:

pip install hubspot-api

Liability

Note: This unofficial API library is not endorsed by HubSpot and likely violates their Terms of Service. Use it at your own risk; the creator assumes no liability for any consequences.

Metadata

Release files for hubspot-api 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for hubspot-api 0.7.0
File Interpreter ABI Platform Actions
hubspot_api-0.7.0-py3-none-any.whl Python 3 none any Details for hubspot_api-0.7.0-py3-none-any.whl

Release files / hubspot_api-0.7.0-py3-none-any.whl

Download URL hubspot_api-0.7.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea79db50eddb9f6e14fcb4bde49fefc7a253977e3f2463f6ebc6b83533fff160
BLAKE2b-256 checksum
How to use checksums
5110a62c66b38e6f30c3fac7dfe9847e2c164b68836a2a92d7e3af00f833f1ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for hubspot-api 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page