Skip to content

Commit ac41eb2

Browse files
feat: initial sdk for python
0 parents  commit ac41eb2

165 files changed

Lines changed: 42662 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# All files should be reviewed by a member of Marketplace Team
2+
* @GoHighLevel/marketplace-devs

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
7+
# Distribution / packaging
8+
.Python
9+
build/
10+
develop-eggs/
11+
dist/
12+
downloads/
13+
eggs/
14+
.eggs/
15+
lib/
16+
lib64/
17+
parts/
18+
sdist/
19+
var/
20+
wheels/
21+
share/python-wheels/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
MANIFEST
26+
27+
# Testing
28+
.coverage
29+
.coverage.*
30+
.pytest_cache/
31+
htmlcov/
32+
.tox/
33+
.nox/
34+
.hypothesis/
35+
36+
# IDEs and editors
37+
.idea/
38+
.vscode/
39+
*.swp
40+
*.swo
41+
*~
42+
43+
# OS
44+
.DS_Store
45+
Thumbs.db
46+
47+
# Temporary files
48+
*.tmp
49+
*.temp

CHANGELOG.md

Whitespace-only changes.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 GoHighLevel
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# GoHighLevel Python SDK
2+
3+
4+
Official Python SDK for the GoHighLevel API. This library provides a convenient way to interact with GoHighLevel's APIs from applications written in Python.
5+
6+
## Installation
7+
8+
```bash
9+
# Install the SDK
10+
pip install gohighlevel-api-client
11+
```
12+
13+
## Quick Start
14+
15+
### Basic Usage
16+
17+
```python
18+
from highlevel import HighLevel
19+
20+
# Or initialize with OAuth credentials
21+
client = HighLevel(
22+
client_id="your_client_id",
23+
client_secret="your_client_secret"
24+
)
25+
```
26+
27+
### OAuth Flow Example
28+
29+
```python
30+
import asyncio
31+
from highlevel import HighLevel
32+
33+
async def oauth_example():
34+
client = HighLevel(
35+
client_id="your_client_id",
36+
client_secret="your_client_secret"
37+
)
38+
39+
# Step 1: Get authorization URL
40+
auth_url = client.oauth.get_authorization_url(
41+
client_id="your_client_id",
42+
redirect_uri="https://your-app.com/callback",
43+
scope="contacts.readonly campaigns.readonly"
44+
)
45+
print(f"Visit: {auth_url}")
46+
47+
# Step 2: Exchange code for tokens (after user authorization)
48+
token_data = await client.oauth.get_access_token({
49+
"client_id": "your_client_id",
50+
"client_secret": "your_client_secret",
51+
"grant_type": "authorization_code",
52+
"code": "authorization_code_from_callback",
53+
"redirect_uri": "https://your-app.com/callback"
54+
})
55+
56+
# Tokens are automatically stored in session storage
57+
print("OAuth flow completed successfully!")
58+
59+
asyncio.run(oauth_example())
60+
```
61+
62+
## Storage
63+
It can be used to store the access and refresh token for your application.
64+
65+
### MongoDB Storage
66+
```python
67+
from highlevel import HighLevel
68+
from highlevel.storage import MongoDBSessionStorage
69+
70+
storage = MongoDBSessionStorage(
71+
connection_string="mongodb://localhost:27017",
72+
database_name="ghl_sessions",
73+
collection_name="jwt_tokens"
74+
)
75+
76+
client = HighLevel(
77+
client_id="your_client_id",
78+
client_secret="your_client_secret",
79+
session_storage=storage
80+
)
81+
```
82+
83+
## Documentation
84+
85+
- [Official API Documentation](http://marketplace.gohighlevel.com/docs/)
86+
- [SDK Examples](https://github.com/GoHighLevel/ghl-sdk-examples/tree/main/python)
87+
88+
## License
89+
90+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
91+
92+
## Changelog
93+
94+
See [CHANGELOG.md](CHANGELOG.md) for a list of changes and version history.

pyproject.toml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "gohighlevel-api-client"
7+
version = "1.0.0"
8+
description = "GoHighLevel Python SDK - Official API client for GoHighLevel platform"
9+
readme = "README.md"
10+
license = {text = "MIT"}
11+
authors = [
12+
{name = "HighLevel", email = "marketplace@gohighlevel.com"}
13+
]
14+
maintainers = [
15+
{name = "HighLevel", email = "marketplace@gohighlevel.com"}
16+
]
17+
keywords = [
18+
"gohighlevel",
19+
"api",
20+
"sdk",
21+
"client",
22+
"crm",
23+
"marketing",
24+
"automation"
25+
]
26+
classifiers = [
27+
"Development Status :: 5 - Production/Stable",
28+
"Intended Audience :: Developers",
29+
"License :: OSI Approved :: MIT License",
30+
"Operating System :: OS Independent",
31+
"Programming Language :: Python :: 3",
32+
"Programming Language :: Python :: 3.8",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Topic :: Internet :: WWW/HTTP",
38+
"Topic :: Software Development :: Libraries :: Python Modules",
39+
"Topic :: Office/Business",
40+
]
41+
requires-python = ">=3.8"
42+
dependencies = [
43+
"httpx>=0.24.0",
44+
"pydantic>=2.0.0",
45+
"typing-extensions>=4.0.0; python_version<'3.11'",
46+
"pymongo>=4.0.0",
47+
"cryptography>=3.0.0",
48+
]
49+
50+
[project.optional-dependencies]
51+
dev = [
52+
"build>=0.10.0",
53+
"twine>=4.0.0",
54+
]
55+
56+
[project.urls]
57+
Homepage = "https://github.com/GoHighLevel/gohighlevel-python-sdk"
58+
Documentation = "https://docs.gohighlevel.com/python"
59+
Repository = "https://github.com/GoHighLevel/gohighlevel-python-sdk"
60+
"Bug Tracker" = "https://github.com/GoHighLevel/gohighlevel-python-sdk/issues"
61+
Changelog = "https://github.com/GoHighLevel/gohighlevel-python-sdk/blob/main/CHANGELOG.md"
62+
63+
[tool.setuptools]
64+
packages = ["highlevel"]
65+
package-dir = {"" = "src"}
66+
67+
[tool.setuptools.package-data]
68+
highlevel = ["py.typed"]
69+
70+
[tool.black]
71+
line-length = 88
72+
target-version = ['py38']
73+
include = '\.pyi?$'
74+
exclude = '''
75+
/(
76+
\.eggs
77+
| \.git
78+
| \.hg
79+
| \.mypy_cache
80+
| \.tox
81+
| \.venv
82+
| _build
83+
| buck-out
84+
| build
85+
| dist
86+
)/
87+
'''
88+
89+
[tool.isort]
90+
profile = "black"
91+
multi_line_output = 3
92+
line_length = 88
93+
known_first_party = ["highlevel"]
94+
95+
[tool.mypy]
96+
python_version = "3.8"
97+
warn_return_any = true
98+
warn_unused_configs = true
99+
disallow_untyped_defs = true
100+
disallow_incomplete_defs = true
101+
check_untyped_defs = true
102+
disallow_untyped_decorators = true
103+
no_implicit_optional = true
104+
warn_redundant_casts = true
105+
warn_unused_ignores = true
106+
warn_no_return = true
107+
warn_unreachable = true
108+
strict_equality = true
109+
110+
[tool.pytest.ini_options]
111+
minversion = "7.0"
112+
addopts = "-ra -q --strict-markers --strict-config"
113+
testpaths = ["tests"]
114+
filterwarnings = [
115+
"error",
116+
"ignore::UserWarning",
117+
"ignore::DeprecationWarning",
118+
]

setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
Setup configuration for gohighlevel-api-client.
3+
4+
This file provides backward compatibility for tools that still rely on setup.py.
5+
The main configuration is in pyproject.toml.
6+
"""
7+
8+
from setuptools import setup
9+
10+
# All configuration is in pyproject.toml
11+
setup()

src/highlevel/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""HighLevel SDK - Python Package"""
2+
3+
from .highlevel import HighLevel
4+
from .error import GHLError
5+
from .storage import SessionStorage, MemorySessionStorage, ISessionData
6+
from .logging import Logger, LogLevel
7+
from .webhook import WebhookManager
8+
from .constants import UserType
9+
10+
__all__ = [
11+
"HighLevel",
12+
"GHLError",
13+
"SessionStorage",
14+
"MemorySessionStorage",
15+
"ISessionData",
16+
"Logger",
17+
"LogLevel",
18+
"WebhookManager",
19+
"UserType"
20+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Export all constants
2+
from .user_types import UserType, UserTypeValue
3+
4+
__all__ = ["UserType", "UserTypeValue"]
5+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Enum for user types in the HighLevel system
3+
Used for OAuth flows and session management
4+
"""
5+
6+
from enum import Enum
7+
8+
9+
class UserType(str, Enum):
10+
"""User type enum for GoHighLevel system"""
11+
COMPANY = "Company"
12+
LOCATION = "Location"
13+
14+
15+
# Type alias for user type values
16+
UserTypeValue = str
17+

0 commit comments

Comments
 (0)