It turns out I am using the REST API more and more because my needs seem to always fall just a tiny bit outside what Dundas can do by default. Python is my language of choice and there are enough options to easily interface with a REST API.
The first time I played with the API, I forgot to log out in my script. After a few runs, I had burnt through all my elastic hours.
This prompted the idea of having an easy, guaranteed, automated, fool proof, no boilerplate way to always log out, and pydundas was born.
It is now open source (MIT), accessible on GitHub and of course on pypi.
Using pydundas is trivial. install it:
pip install pydundas
and use it:
from pydundas import Session
with Session(user=user, pwd=pwd, url=url) as d:
print(d.get('Server').text)
And that’s it. You will be automatically logged in within the with
statement, logged out no matter what happens (as long as you do not pull the plug out).
There are more examples in the Readme on GitHub.
Never forget to log out was my first need, and that’s what pydundas does. It creates a few shortcuts as well because I am very lazy and each and every REST call need to have the same parameter and prefix, and I do not like to repeat myself. There are get
, post
and delete
dundas-aware shortcuts saving you a good few keystrokes.
I am not done with the API. I expect to add helpers (eg. getAccoutIdByName()
and the likes) for whatever I need to use. My goal is not to fully mirror the official API, but to make my life easier, and share it with the world. Hopefully, the world will find pydundas useful and will send me some pull requests to extend it.