Skip to main content

GoHighLevel API Client

Connect to the GoHighLevel API with a modern, type-safe Python client. This is auto generated based on a API spec which I believe I had an LLM generate. There are probably some bugs, but it's working for me.

Right now, this client focuses on the Contacts and Custom Fields endpoints, giving you typed interfaces for the data you use most often.

Installation

Add this package to your project using uv:

uv add gohighlevel-api

Usage

I've designed the client to be intuitive. You just need your API token (or Location API Key) to get started.

from gohighlevel_api import AuthenticatedClient
from gohighlevel_api.api.contacts import get_contacts
from gohighlevel_api.models import GetContactsVersion

# Initialize the client with your API key
client = AuthenticatedClient(
    base_url="https://services.leadconnectorhq.com",
    token="YOUR_ACCESS_TOKEN"
)

# Fetch contacts with type safety
with client as c:
    response = get_contacts.sync(client=c, location_id="YOUR_LOCATION_ID")
    
    if response:
        print(f"Found {len(response.contacts)} contacts")
        for contact in response.contacts:
            print(f"{contact.first_name} {contact.last_name}")

For async applications, it works just as smoothly:

import asyncio
from gohighlevel_api import AuthenticatedClient
from gohighlevel_api.api.contacts import get_contacts

async def main():
    client = AuthenticatedClient(
        base_url="https://services.leadconnectorhq.com",
        token="YOUR_ACCESS_TOKEN"
    )

    async with client as c:
        response = await get_contacts.asyncio(client=c, location_id="YOUR_LOCATION_ID")
        # Work with your data...

if __name__ == "__main__":
    asyncio.run(main())

Key Concepts

To use this client effectively, here are a few things to know about how the API is structured:

  1. Module Structure: Every API endpoint (path + method) becomes a Python module with four functions:
    • sync: Blocking request that returns parsed data (if successful) or None.
    • sync_detailed: Blocking request that returns a Response object (with status code, headers, etc.).
    • asyncio: Async version of sync.
    • asyncio_detailed: Async version of sync_detailed.
  2. Arguments: All path parameters, query parameters, and request bodies become arguments to these methods.
  3. Tags: If an endpoint has tags in the OpenAPI spec, the first tag is used as the module name (e.g., api.contacts). Endpoints without tags end up in api.default.

Advanced Usage

Detailed Responses

Sometimes you need more than just the parsed data—like headers or status codes.

from gohighlevel_api.api.contacts import get_contacts
from gohighlevel_api.types import Response

with client as c:
    # returns a Response object containing status_code, content, headers, and parsed data
    response: Response = get_contacts.sync_detailed(client=c, location_id="YOUR_LOCATION_ID")
    
    if response.status_code == 200:
        print(response.parsed)

SSL Configuration

By default, the client verifies SSL certificates. However, if you are testing against a local server or need a custom certificate bundle, you can configure this:

Custom Certificate Bundle:

client = AuthenticatedClient(
    base_url="https://internal.api.example.com", 
    token="SuperSecretToken",
    verify_ssl="/path/to/certificate_bundle.pem",
)

Disable Verification (Security Risk):

client = AuthenticatedClient(
    base_url="https://internal.api.example.com", 
    token="SuperSecretToken", 
    verify_ssl=False
)

Customizing the HTTP Client

You have full control over the underlying httpx client. This is useful for adding event hooks, logging, or setting proxies.

Using arguments:

from gohighlevel_api import Client

def log_request(request):
    print(f"Request event hook: {request.method} {request.url} - Waiting for response")

def log_response(response):
    request = response.request
    print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")

client = Client(
    base_url="https://api.example.com",
    httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)

Replacing the client entirely: You can also supply your own httpx.Client. Note that this overrides configuration passed to the constructor (like base_url).

import httpx
from gohighlevel_api import Client

client = Client(
    base_url="https://api.example.com",
)

# Note that base_url needs to be re-set here
client.set_httpx_client(httpx.Client(
    base_url="https://api.example.com", 
    proxies="http://localhost:8030"
))

Features

  • Type-safe Models: Every request and response is validated against generated Pydantic-style models.
  • Sync and Async: Native support for both blocking and asyncio workflows.
  • Selective Schema: focused coverage for Contacts and Custom Fields to keep the package lightweight.
  • Auto-generated: Built directly from GoHighLevel's OpenAPI specs, ensuring accuracy.
  • Modern Tooling: Built with uv for fast, reliable package management.

MIT License

Metadata

Release files for gohighlevel-api 0.2.1

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

Source distribution (sdist)

Source distribution for gohighlevel-api 0.2.1
File Size Uploaded Provenance
gohighlevel_api-0.2.1.tar.gz 55.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gohighlevel-api 0.2.1
File Interpreter ABI Platform
gohighlevel_api-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 230.0 kB

Release files / gohighlevel_api-0.2.1.tar.gz

Download URL gohighlevel_api-0.2.1.tar.gz
Size 55.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7ca7121817cca14fd2d6140d931f62ca2ff63b458a50e62358ac07d64b0249a2
BLAKE2b-256 checksum
How to use checksums
d34e3e393ce7fdead6fd69d2eecb920f324502afa8abb1b4c0d69fc039e646f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gohighlevel_api-0.2.1-py3-none-any.whl

Download URL gohighlevel_api-0.2.1-py3-none-any.whl
Size 174.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dabc8521888125cf513effaec04eec80d88da312154835257e6cc1e3d594680b
BLAKE2b-256 checksum
How to use checksums
86ca5dcfa26d0cb4509c425906349a468810d91ad607059cfd6741bc779a0506
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for gohighlevel-api 0.2.1

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.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

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