Ogsapi - A Python API Wrapper for OGS

Hey Everyone!

I am at the point where I feel comfortable letting other people look at this API wrapper I am writing for the OGS API. Its still VERY MUCH in the development stages, and absolutely no one should be using it for real projects, yet. That being said, I want to see if anyone here is Pythonically Inclined, and might be able to give some general review of the code, or just give general thoughts.

My goal is to expose as much of both the REST API, and the Realtime API as possible through functions. That way, anyone who wants to create a Python project that hooks into OGS will have a much easier time, and not have to worry about the specific API calls and whatnot.

Here is the Github link
Here is the Gitlab link (This is the one I am actually working through, Github is just because it’s basically a social media platform at this point lol)

I have also already uploaded it to PyPI, so you can just install it with:

python3 -m pip install ogsapi

Let me know your opinions on the current documentation, code format, or anything really. I am going to try and get the rest of the API endpoints implemented as soon as possible.

Disclaimer: I am not a developer by any stretch of the imagination. My code is likely horrendous, slow, terrible, bad, atrocious, and did I mention bad?

10 Likes

That’s awesome! I feel like a lot of Python is the language of choice for a lot of folks here (see the Project Euler thread), so this will be very useful - I look forward to trying it out!

Also, yay copyleft!

5 Likes

I pretty much exclusively write in Python, so it was the obvious choice for me lol. Hopefully others can eventually get some use out of it.

And always copyleft! :smile:

5 Likes

Heyo! Just a small update on this:

Most of the bare minimum game features should be implemented. I just got received moves to pass to the end client via callbacks. That means that I am only missing clock management, sending challenges, and handling the counting phase.

I am still trying to get all the random endpoints on the normal REST API implemented, but I think a good portion of them are accounted for.

After all the functions that handle talking directly to the API are done, I plan to start implementing some helper functions to take care of complicated multi stepped tasks more easily.

Here is the latest release link: 0.3.0 · Dakota Marshall / OGS-Python · GitLab

2 Likes

Howdy y’all! Back again with another quick update on this. Added some new features and whatnot

  • Added relevant game data to the OGSGame class
  • Implemented clock handling
  • Implemented handling of undo actions
  • Added asdict() method to OGSGame to get game data as a dict

But I also spent the time going through and documenting the code with docstrings, and setup mkdocks to act as a documentation wiki. You can view that here: https://ogs-python.dakotamarshall.net/

It’s not super polished yet, but it builds the documentation from the code automatically, so it should always be up-to-date (for the most part anyway)

At this point I feel comfortable saying that you could probably start toying around with this if you want, though I want to stress that the code is probably bad, and you still shouldnt rely on this for anything important. That being said, I would love to get some feedback on this if anyone has a chance to use it / wants to contribute to the project! Just let me know.

Here is the release page if you want to have a look: 0.4.1 · Dakota Marshall / OGS-Python · GitLab

1 Like

Nice project!

I’m working on something similar, just not on Python, so I gave your code a look to find some inspiration.

I noticed a minor typo on the event ‘undo_canceled’ (OGS uses the British-English spelling), so I took the liberty to send you a merge request with a fix. It’s nothing really, but if it’s OK I could help you on implementing features (callbacks, etc.).

I’m currently focusing on the real-time API, and I have a question: where did you find the events that you listed in your checklist? This doc is fairly bad, and I know a better one exists, but somehow I cannot find it anymore. Hopefully, that’s the one you used and you have a link to share.

1 Like

Thanks! I’ll take a look at the MR and merge it when I have some time tomorrow. As for helping, I am welcome to any idea / improvements people may have. I am very much a newbie at programming, so any contributions are very welcome :slight_smile:

I made a post awhile ago asking about contributing to the documentation, and anoek threw me this link. It’s the documentation for their goban client, and in it documents all of the RT API calls it sends and receives. I believe it is completely up to date with at least all the calls goban makes.

Ah yes! That’s where I initially heard about it, thanks for helping me find it!

1 Like