ConnectPyse
ConnectWise (Manage) REST API client written in Python 3.x The original project was created by Joshua M. Smith. This forked version was started by Mark Ciecior.
ConnectWise RESTful API Client
Following the layout style of the official SDKs from CW team. Classes and their API counter part classes are under their appropriate sections. Import the API class(es) you want to leverage and the model classes are imported with them.
Setup (old way)
- Copy your_api.json to new my_api.json file and update with your API key and clientId details
Setup (new way)
- Create two variables which are passed to the constructor of the API classes.
- URL = 'https://connectwise.mycompany.com/v4_6_release/apis/3.0'
- AUTH = {'Authorization': 'Basic Wmdlasdkjfeklamwekf=', 'clientId': 'myClientIdKey'}
Usage
- Import the sections you'll be using
- Create an object from API Class
- Leverage member methods to access features
Paging
>>> from connectpyse.sales import opportunity_api
>>> o = opportunity_api.OpportunityAPI(url=URL, auth=AUTH)
>>> o.pageSize = 27
>>> o.get_opportunities()
Filtering
>>> from connectpyse.sales import opportunity_api
>>> o = opportunity_api.OpportunityAPI(url=URL, auth=AUTH)
>>> o.conditions = 'name="My Opportunity"'
>>> o.get_opportunities()
Filtering on sub-attributes (use '/')
>>> from connectpyse.sales import opportunity_api
>>> o = opportunity_api.OpportunityAPI(url=URL, auth=AUTH)
>>> o.conditions = 'company/id=19297'
>>> result = o.get_opportunities()
>>> for i in result:
>>> print(i.company['id'])
To upload a document to an opportunity:
>>> from connectpyse.system import document_api
>>> from connectpyse.sales import opportunity_api
>>> o = opportunity_api.OpportunityAPI(url=URL, auth=AUTH)
>>> d = document_api.DocumentAPI(url=URL, auth=AUTH)
>>> a_opp = o.get_opportunity_by_id(1234)
>>> f = os.path.join(os.path.curdir, 'local_info.txt')
>>> a_document = d.create_document(o, 'Newly Uploaded Document', 'server_info.txt', open(f, 'rb'))
>>> print(a_document.title)
To retrieve the documents attached to an opportunity:
>>> from connectpyse.system import document_api
>>> from connectpyse.sales import opportunity_api
>>> o = opportunity_api.OpportunityAPI(url=URL, auth=AUTH)
>>> d = document_api.DocumentAPI(url=URL, auth=AUTH)
>>> a_opp = o.get_opportunity_by_id(1234)
>>> myDocs = d.get_documents(a_pp)
>>> for doc in myDocs:
>>> print(doc.title)
>>>
To download the documents attached to an opportunity:
>>> from connectpyse.system import document_api
>>> from connectpyse.system import document_download_api
>>> from connectpyse.sales import opportunity_api
>>> o = opportunity_api.OpportunityAPI(url=URL, auth=AUTH)
>>> d = document_api.DocumentAPI(url=URL, auth=AUTH)
>>> a_opp = o.get_opportunity_by_id(1234)
>>> myDocs = d.get_documents(a_pp)
>>> for doc in myDocs:
>>> doc_download = document_download_api.DocumentDownloadAPI(doc.id, url=URL, auth=AUTH)
>>> ## Option 1: Get the BytesIO object
>>> bytes = doc_download.download_document().bytes
>>> ## Option 2: Download directly to disk
>>> doc_download.save_to_file("/path/to/file.txt")
For example to get a Member's office phone number you would:
>>> from connectpyse.system import members_api
>>> m = members_api.MembersAPI() #Assuming the my_api.json file has been updated
-or-
>>> from connectpyse.system import members_api
>>> m = members_api.MembersAPI(url=URL, auth=AUTH) #No my_api.json file necessary
>>> a_member = m.get_member_by_id(123)
>>> print(a_member.officePhone)
For example to find the name of all activities related to a particular opportunity you would:
>>> from connectpyse.sales import activity_api
>>> myAct = activity_api.ActivityAPI() #Assuming the my_api.json file has been updated
-or-
>>> from connectpyse.sales import activity_api
>>> myAct = activity_api.ActivityAPI(url=URL, auth=AUTH) #No my_api.json file necessary
>>> myAct.conditions = 'opportunity/id=1250'
>>> allActivities = myAct.get_activities()
>>> for oneAct in allActivities:
>>> print(oneAct.name)
For example to find all line items of a parent purchase order:
>>> from connectpyse.procurement import purchase_order_line_item_api
>>> lineItems = purchase_order_line_item_api.PurchaseOrderLineItemAPI(url=URL,auth=AUTH,parent=1919)
>>> myItems = lineItems.get_purchase_order_line_items()
For example to update a ticket note:
>>> from connectpyse.service import ticket_notes_api, ticket_note
>>> ticket_notes = ticket_notes_api.TicketNotesAPI(url=URL, auth=AUTH, ticket_id=TICKET_ID)
>>> note = ticket_note.TicketNote({"text":"testing ticket note update.. ", "detailDescriptionFlag": True})
>>> ticket_notes.create_ticket_note(note)
For example to update multiple fields on a ticket:
>>> from connectpyse.service import tickets_api
>>> api = tickets_api.TicketsAPI(url=URL, auth=AUTH)
>>> mychanges = {"summary": "update multiple keys", "budgetHours": .50}
>>> ticket = api.update_ticket_multiple_keys(ticketId, mychanges)
Tell the json module to use ensure_ascii=True:
>>> from connectpyse.sales import opportunity_api
>>> o = opportunity_api.OpportunityAPI(url=URL, auth=AUTH, ensure_ascii=True)
Metadata
Release files for connectpyse 0.8.1
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 |
|---|---|---|---|---|
| connectpyse-0.8.1.tar.gz | 39.1 kB | Without provenance | Details for connectpyse-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| connectpyse-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for connectpyse-0.8.1-py3-none-any.whl |
Total release size: 141.4 kB
Release files / connectpyse-0.8.1.tar.gz
| Download URL | connectpyse-0.8.1.tar.gz |
|---|---|
| Size | 39.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a5afab084ee422b34906d6bde118590306ba3efb232891a22cfa5a1baeb9cc5
|
|
BLAKE2b-256 checksum How to use checksums |
b7dcbe6358891aa952b59eff5d0803aa3f235defe92a2cbf1b33e6b0b1ce7f45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / connectpyse-0.8.1-py3-none-any.whl
| Download URL | connectpyse-0.8.1-py3-none-any.whl |
|---|---|
| Size | 102.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49287a235d08ca4f6c7659ab8dda29265d9e46c95a5483cf5080d81f9ec3cb98
|
|
BLAKE2b-256 checksum How to use checksums |
2f75444e3336432bdd8346d6c38d60f8a59b692aca89eb94e811dba6db319efa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for connectpyse 0.8.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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.