Syncro MSP API Wrapper and a few example functions.
python requests module
python munch module (fork of Bunch that works with modern python)
The simplest usage:
fromsyncromsp_api_wrapperimportSyncroAPIapi=SyncroAPI("yoursubdomain", api_key="YOUR API KEY")
tickets=api.get_tickets()
forticketintickets:
print(ticket.number)Your api key can be specified or read from an env variable - SYNCRO_API_KEY
fromsyncromsp_api_wrapperimportSyncroAPIapi=SyncroAPI("yoursubdomain")
# some more ticklers to get you startedticket_types=api.get_ticket_types()
forticket_typeinticket_types:
print(ticket_type)
ticket_status_list=api.get_ticket_status_list()
forticket_statusinticket_status_list:
print(ticket_status)
billing_tickets=api.get_tickets(status="Billing")
forbilling_ticketinbilling_tickets:
print(f"The ticket number {billing_ticket.number} with the subject of {billing_ticket['subject']} needs to be billed.")If you want to filter by parameters that have not been implemented in the api wrapper yet, you can add them to the request parameters dictionary before the request goes out.
You can see available parameters in the syncro docs: https://api-docs.syncromsp.com/#/
fromsyncromsp_api_wrapperimportSyncroAPIapi=SyncroAPI("yoursubdomain")
#all tickets created after the dateapi.request_parameters['created_after'] ="2024-05-25"tickets=api.get_tickets(status=None)
forticketintickets:
print(ticket['number'])The custom request parameters that you set will stay in the requests until you clear them out with the .clean() method. This means you can chain multiple requests with similar parameters easily.
fromsyncromsp_api_wrapperimportSyncroAPIapi=SyncroAPI("yoursubdomain")
#show tickets created after the dateapi.request_parameters['created_after'] ="2024-05-25"#Billing tickets created after 2024-05-25tickets=api.get_tickets(status="Billing")
forticketintickets:
print(ticket['number'])
#scheduled tickets created after 2024-05-25 tickets=api.get_tickets(status="Scheduled")
forticketintickets:
print(ticket['number'])
#all open tickets after the datetickets=api.get_tickets()
#removes the custom parametersapi.clean()
#all open ticketstickets=api.get_tickets()
You will need the following permissions in Syncro for your api key:
Customers - View Detail Single
Customers - Edit Single
syncro_contacts_csv.py import <customer_id> contacts.csv
syncro_contacts_csv.py export <customer_id> contacts.csv