Skip to main content

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.

Reason this release was yanked:

Invalid Version Number

Project description

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.

:warning: 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.

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

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

threecxapi-0.0.0.tar.gz (79.5 kB view details)

Uploaded Source

Built Distribution

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

threecxapi-0.0.0-py3-none-any.whl (75.8 kB view details)

Uploaded Python 3

File details

Details for the file threecxapi-0.0.0.tar.gz.

File metadata

  • Download URL: threecxapi-0.0.0.tar.gz
  • Upload date:
  • Size: 79.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for threecxapi-0.0.0.tar.gz
Algorithm Hash digest
SHA256 9728c7b4ca25a998f7d7905784f7c6d99a8e8abccebcf138f5b43a49319230e1
MD5 718350fc0fd5eb0d605878204226074e
BLAKE2b-256 2df1ef6e4fcaf99ca37f5981d4703b91516124961e41c1e901a2112ecd927aae

See more details on using hashes here.

File details

Details for the file threecxapi-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: threecxapi-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 75.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for threecxapi-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 826f7211f6e275f705c7e187ede33501de1839b3ae030ceeca01698627b62c06
MD5 177667a47ab01c5c24ffebe7667fd09a
BLAKE2b-256 7a045221e442167328089af55df9faeab573757970b3625804eea211303cb263

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