Dundas REST API with Python: Introducing pydundas

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.

3 Likes

Great idea - wishing you luck with it.

This is very cool - great idea. However, you should also be aware that Dundas BI now has the concept of “API accounts”, which don’t consume a license when logged on. The only limitations are that API accounts cannot make use of the UI, and also can’t make any calls to the Dundas BI data retrieval API.

HI Rob,

Indeed, I make use of the API accounts (which I only discovered after the first iteration of pydundas). I wonder what happens if the same api account is used multiple times in parallel. I never forget to log out any more so it hasn’t happened yet :slight_smile:

Pydundas goes further than just automagic logout: there are helper functions to prevent boilerplate and the latest version starts to have some actually useful methods (eg. getProjectIdByName).