Many people have asked me if they can use the Finesse APIs in an application written in Python. Finesse APIs are REST APIs, so if the programming language, Python in this case, has the ability to call REST APIs (either native or with a library), then it can. Great. You can make REST API calls, but it’s not very useful without the Finesse notifications. So, is it possible to get the Finesse notifications? Getting Finesse notifications is nothing more than establishing an XMPP connection to the Finesse Notification Service. There are many libraries to accomplish this task.
Ok. That is great in theory, but how?
Since this question seems to be gaining some traction, I decided to try it for myself. Can I build a Python application utilizing the Finesse REST APIs and notifications?
It started off being very easy because I was able to leverage the DevNet APIC-EM APIs with Python - Basic Labs learning lab to make REST API requests in Python. Then when I looked at the list of XMPP libraries, I saw 10 XMPP libraries just for Python and didn’t know where to begin. After some trial and error, I settled on putting my efforts in using SleekXMPP because there was an example that had a comment about connecting to an OpenFire server, so it seemed promising. Many hours later, success! I was able to connect to the Finesse Notification Server and receive Finesse notifications when the appropriate APIs were invoked.
I decided to stop at that point since I had proved that it is possible to make Finesse REST API calls, connect to the Finesse Notification Service and receive Finesse notifications using Python. This code that I put together, named Non Gadget Python Sample, is now available as part of the DevNet Finesse Sample Code/Gadgets.
This Finesse Python script demonstrates how to use Finesse REST APIs in Python, how to establish a XMPP connection to the Finesse Notification Service and receive Finesse events using a third party XMPP library. It s a very simple script that logs in, changes state, and logs out. The script does not integrate the Finesse events back into the User object. The code was tested on Finesse 11.5, but should work with previous versions.
Feel free to use this sample code as a base for your application, but do note that it is not guaranteed to be bug free or production ready.