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).
# The request body uses camelCase keys.
token_data = await client.oauth.get_access_token({
"clientId": "your_client_id",
"clientSecret": "your_client_secret",
"grantType": "authorization_code",
"code": "authorization_code_from_callback",
})
# token_data is the raw token response, with camelCase keys:
# accessToken, refreshToken, expiresIn, userType, and locationId or companyId.
# Persist it via your session storage to authenticate later requests.
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
INSTALLandUNINSTALLwebhooks automatically - Token Storage: Generates and stores access tokens on
INSTALL, removes them onUNINSTALL - 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
Webhook Signature Verification
Incoming webhooks are verified before they are processed. Configure the public key (available in your app settings) as an environment variable. If no supported signature header and matching key are present, the middleware logs a warning and skips the webhook without processing it — so configuring a key is required for webhooks to work.
| Scheme | Header | Environment variable | Notes |
|---|---|---|---|
| Ed25519 | x-ghl-signature |
WEBHOOK_SIGNATURE_PUBLIC_KEY |
Preferred. Used when present. |
| RSA-SHA256 | x-wh-signature |
WEBHOOK_PUBLIC_KEY |
Legacy fallback. |
# CLIENT_ID is also required — the webhook's appId is matched against it before processing.
export CLIENT_ID="your_client_id"
export WEBHOOK_SIGNATURE_PUBLIC_KEY="your_ed25519_public_key"
# Optional legacy fallback:
export WEBHOOK_PUBLIC_KEY="your_rsa_public_key"
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.
Metadata
Release files for gohighlevel-api-client 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gohighlevel_api_client-3.0.0.tar.gz | 177.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gohighlevel_api_client-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 434.0 kB
Release files / gohighlevel_api_client-3.0.0.tar.gz
| Download URL | gohighlevel_api_client-3.0.0.tar.gz |
|---|---|
| Size | 177.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47bbf031d5dae0836ad431aee7d3a7fd6d51cc3ade0ed9c35ecc79134a9b86b2
|
|
BLAKE2b-256 checksum How to use checksums |
819f57f040ad4785c6d4c2db6258ba1a78be9c8b38ddfbfc20f588dc0c17e7da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / gohighlevel_api_client-3.0.0-py3-none-any.whl
| Download URL | gohighlevel_api_client-3.0.0-py3-none-any.whl |
|---|---|
| Size | 256.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
57c6cb12ef927dce217086b6264971f7f80c1837101532a94f2ebfe254e1ce0d
|
|
BLAKE2b-256 checksum How to use checksums |
24c9c3aa323e82eb8efe0713001807486d8949b3f9053d1ce1d3b37e75236c7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|