Skip to main content

GoHighLevel Python SDK - Official API client for GoHighLevel platform

Project description

GoHighLevel Python SDK

Official Python SDK for the GoHighLevel API. This library provides a convenient way to interact with GoHighLevel's APIs from applications written in Python.

Installation

# Install the SDK 
pip install gohighlevel-api-client

Quick Start

Basic Usage

from highlevel import HighLevel

# Initialize with OAuth credentials
client = HighLevel(
    client_id="your_client_id",
    client_secret="your_client_secret"
)

OAuth Flow Example

import asyncio
from highlevel import HighLevel

async def oauth_example():
    client = HighLevel(
        client_id="your_client_id",
        client_secret="your_client_secret"
    )
    
    # Step 1: Get authorization URL
    auth_url = client.oauth.get_authorization_url(
        client_id="your_client_id",
        redirect_uri="https://your-app.com/callback",
        scope="contacts.readonly campaigns.readonly"
    )
    print(f"Visit: {auth_url}")
    
    # Step 2: Exchange code for tokens (after user authorization)
    token_data = await client.oauth.get_access_token({
        "client_id": "your_client_id",
        "client_secret": "your_client_secret",
        "grant_type": "authorization_code",
        "code": "authorization_code_from_callback",
        "redirect_uri": "https://your-app.com/callback"
    })
    
    # Tokens are automatically stored in session storage
    print("OAuth flow completed successfully!")

asyncio.run(oauth_example())

Storage

It can be used to store the access and refresh token for your application.

MongoDB Storage

from highlevel import HighLevel
from highlevel.storage import MongoDBSessionStorage

storage = MongoDBSessionStorage(
    connection_string="mongodb://localhost:27017",
    database_name="ghl_sessions",
    collection_name="jwt_tokens"
)

client = HighLevel(
    client_id="your_client_id",
    client_secret="your_client_secret",
    session_storage=storage
)

Webhook Integration

The SDK provides comprehensive webhook support for handling GoHighLevel webhook events, including automatic token management and session storage integration.

Features

  • Automatic Token Management: Handles INSTALL and UNINSTALL webhooks automatically
  • Token Storage: Generates and stores access tokens on INSTALL, removes them on UNINSTALL
  • Session Management: Integrates with your chosen session storage (Memory/MongoDB)
  • Auto Token Refresh: Automatically refreshes expired tokens during API calls if tokens are stored

Webhook Handler Setup

from highlevel import HighLevel
from highlevel.storage import MemorySessionStorage

# Initialize the SDK client with session storage
client = HighLevel(
    client_id="your_client_id",
    client_secret="your_client_secret",
    session_storage=MemorySessionStorage()
)

# Get the webhook middleware
webhook_middleware = client.webhooks.subscribe()

@app.route('/api/webhooks/ghl', methods=['POST'])
async def handle_ghl_webhook():
    """Handle incoming GoHighLevel webhooks"""
    # Process the webhook using the middleware
    await webhook_middleware(request)
    # Add your custom webhook logic here
    return jsonify({"status": "success"}), 200

Documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for a list of changes and version history.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gohighlevel_api_client-1.0.0b1.tar.gz (122.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gohighlevel_api_client-1.0.0b1-py3-none-any.whl (184.0 kB view details)

Uploaded Python 3

File details

Details for the file gohighlevel_api_client-1.0.0b1.tar.gz.

File metadata

  • Download URL: gohighlevel_api_client-1.0.0b1.tar.gz
  • Upload date:
  • Size: 122.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for gohighlevel_api_client-1.0.0b1.tar.gz
Algorithm Hash digest
SHA256 89de140869ff8baa9dc83ec7e9aa48b1a37e67832f6cf2cda0d1df06aa1d3706
MD5 5be7c60ae29ad3ae648e94dde115683d
BLAKE2b-256 45c35f78b6be2de4c0d76043128bfc72fc6114cb27782bda2778cb93e18aa94f

See more details on using hashes here.

File details

Details for the file gohighlevel_api_client-1.0.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for gohighlevel_api_client-1.0.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 d970bf4596ea789476a533817c52afc57ff56d5b096aa196496a058387d43fea
MD5 f03450bd8cf343ec7e7be15e003c8569
BLAKE2b-256 55427cbaf2ac969be7a0626d434762c32d58ef70b039313fa74dd775b29846c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page