bingosync icon indicating copy to clipboard operation
bingosync copied to clipboard

Create Room API

Open Lego6245 opened this issue 3 years ago • 1 comments

I would like to be able to create a room programmatically via an API. Ideally, I would be able to define all of the options that one usually could define when creating a room, including game, format, board hidden / not hidden, and password. When called, it creates the room and returns the board ID.

I'm looking to build a discord bot that creates games for players pre-formatted to the correct game type and tracks the stats for the bingo match. The one major missing piece is the fact that boards need to be created in the browser, and due to the CSFR token, can't be created by invoking the API directly.

I understand this is a pretty big ask, but am curious if this is on your radar at all.

Lego6245 avatar Jun 06 '21 01:06 Lego6245

I'm planning to do a similar thing and managed to find a workaround: it's possible to simply send the POST request that is normally sent by submitting the form on the main page.

To do that you need to pass the CSRF protection. Therefore you will need to load the homepage using your HTTP client of choice and:

  • Persist cookies and send those with your next request
  • Parse the CSRF Token from the HTML form (look for csrfmiddlewaretoken)

Next step is sending the actual request that will open the room. The URL is still https:// bingosync.com and I suggest grabbing the body by changing the form to a GET request, so you can send it and copy the query string from the address bar.

The POST request must have the Content-Type header set to application/x-www-form-urlencoded.

If done correctly bingosync will return HTTP status 302 and the link to the room is in the Location header.

scaramangado avatar Jun 11 '21 19:06 scaramangado