3CX API Python Module
Description
This is a python wrapper for the 3CX API. It is designed to make it easier to interact with the 3CX API. It is a work in progress and is not yet feature complete. It is designed to be used with the official 3CX v20 API.
⚠️ Notice This package is not affiliated with 3CX. It is an unofficial package that is designed to make it easier to interact with the 3CX API.
3CX API Compatibility
The 3CX API can change at any time. They do provide a swagger file. The following table works to show compatibility between this package and the 3CX and swagger reported versions.
| Package Version | 3CX Version | OpenAPI Version |
|---|---|---|
| 1.0.6 | Version 20.0 Update 6 + | 3.0.4 |
| < 1.0.6 | < Version 20.0 Update 6 | 3.0.0 |
Supported Endpoints
Objects are created for almost every endpoint, response, exception, etc from the swagger provided by 3CX. The following endpoints are fully implemented into a resource that makes it easier to perform actions on them. Other endpoints can be accessed but must be done so manually with the ThreeCXApiConnection object.
Supported Endpoints:
- Users
- Groups
- Trunks
- Peers
Feel free to read the provided swagger.yaml or pull your own swagger from your own 3CX installation to see what is available.
Installation
python3 -m pip install threecxapi
Example Usage
Connection
from threecxapi.connection import ThreeCXApiConnection
# Build Connection
api_connection = ThreeCXApiConnection(server_url=app_config.server_url)
api_connection.authenticate(
username="username",
password="password",
)
Users
from threecxapi.resources.users import UsersResource, ListUserParameters
from threecxapi.resources.exceptions.users_exceptions import UserListError
# Get Users
users_resource = UsersResource(api=api_connection)
try:
user_collection_response = self.users_resource.list_user(
params=ListUserParameters(
expand="Groups($expand=Rights,GroupRights),ForwardingProfiles,ForwardingExceptions,Phones,Greetings"
)
)
users = user_collection_response.users
except UserListError as e:
print(e)
Direct calls to API
# Import an object from here:
# from threecxapi.components.schemas.pbx import MyObject
response = api_connection.get(
endpoint="SomeEndpoint/123",
)
api_connection.patch(
endpoint="SomeEndpoint/123",
data=MyObject.to_dict(),
)
api_connection.delete(
endpoint="SomeEndpoint/123",
)
Type Conversions
# All objects use pydantic BaseModel so you can use TypeAdapter to convert responses to the appropriate objects like so:
from pydantic import TypeAdapter
from threecxapi.components.schemas.pbx import MyObject
response = api_connection.get(
endpoint="SomeEndpoint/123",
)
TypeAdapter(MyObject).validate_python(response.json())
# Note that List endpoints will return a CollectionResponse found in from threecxapi.components.responses.pbx
Metadata
Release files for threecxapi 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| threecxapi-1.0.6.tar.gz | 265.4 kB | Without provenance | Details for threecxapi-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| threecxapi-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for threecxapi-1.0.6-py3-none-any.whl |
Total release size: 335.6 kB
Release files / threecxapi-1.0.6.tar.gz
| Download URL | threecxapi-1.0.6.tar.gz |
|---|---|
| Size | 265.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bff3a037de5803e226ca4f67bdaa59195fa0208e88e3093319d6ca00c0a5ec56
|
|
BLAKE2b-256 checksum How to use checksums |
24b3ff266a5b49fd25e987067a55b36354935ab6c426222366ad0680241ce58c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / threecxapi-1.0.6-py3-none-any.whl
| Download URL | threecxapi-1.0.6-py3-none-any.whl |
|---|---|
| Size | 70.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36315c0514932ada7145a241e73096108b0abc9bd08c7bd80946e1a59c676fe7
|
|
BLAKE2b-256 checksum How to use checksums |
414bd146faba0026fc5ce2a81cfeeb73a79368a3e67729f695e3574a2fdb5baa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for threecxapi 1.0.6
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.