Guide for using the API with Python

So it took me quite a while to figure out how to use the API properly in python. Every time i tried i found that the documentation was hard for me to understand both on the ogs-side and on the python-side for the different modules that you can use (apparently).
For instance, the documentation has examples using urllib2 but the devs themselfs recommend requests in the forums (i now understand why) tho never provided examples of code accessing the API.
Having no prior knowledge of html-requests it was all very confusing to me and i suspect there are more people like me out there who just give up on the API before they figure out the ins and outs.

Well it turns out its super simple after you figure out how it works and get over the pitfalls in the documentation so i thought id share some example-code here that should help anyone thats struggling to quickly get on with building something around the API in python.

You can find the .py and any future projects surrounding ogs here :


Nice! I was in a similar situation to you a few weeks ago and made a similar little self-contained “tutorial”:

I never posted it because for some reason my OGS account wasn’t able to post anything on the forums… I’m not sure why and it hasn’t been resolved, so I made this second account but forgot to post my example code (until now)