Unable to figure out how to post a move with the API

I have spent hours trying many variations of this function but here is my code as it currently stands:

url = 'https://online-go.com/api/v1/games/23497324/move/'
g = requests.post(url, headers={'Authorization': 'Bearer {}'.format(token)}, data= {'move': 'bc'})
print(g)

This returns a 500 response code and doesn’t make the move.

The api has url = ‘https://online-go.com/api/v1/games/23497324/move/’ but that returns a 404 error. Does anyone know how to successfully post a move?

I don’t have an answer for you sadly. But I am curious, what project are you working on?

You have to use the socketio API. The API you’re trying to use is outdated.

I’ve recently gotten into go and have been playing a ton, but my computer screen has been putting a strain on my eyes. So I’m trying to make a physical board with an Arduino and some leds and some buttons so that I can play for longer :laughing:

1 Like

I actually saw you on some other posts and was really hoping you’d answer cause your other answers we’re helpful on other things, so thanks! But quick question: I looked into socketio API but it seemed I needed to use python 2.7 for it. I would prefer to use python 3, so do you know if that’s possible? Also if you had some already written working sample code of using socketio API to make a move in Python, could you share it? That would be greatly appreciated and save me a lot of work!

1 Like

I’m using python3.8

2 Likes

Ok great thanks! My mistake from earlier was my pip was setup for python 2.7 when I tried installing socket :expressionless:

1 Like

Just replying to post a working move played for anyone who might stumble upon this thread with the same problem as me

token = get_token(client_id, client_secret, username, password)
auth = requests.get('https://online-go.com/api/v1/ui/config', headers={'Authorization': 'Bearer {}'.format(token)}).json()

socket = socketio.Client(reconnection_delay_max=60, logger=False, engineio_logger=False)
socket.connect("https://online-go.com/socket.io/?EIO=3", headers={'Authorization': 'Bearer {}'.format(token)}, transports='websocket')

socket.emit("notification/connect", data={"auth": auth['notification_auth'],
                                        "player_id": 767011,
                                        "username": "ben1182367"})

socket.emit("chat/connect", data={"auth": auth['chat_auth'],
                                        "player_id": 767011,
                                        "username": "ben1182367"})

socket.emit("authenticate", data={"auth": auth['chat_auth'],
                                        "player_id": 767011,
                                        "username": "ben1182367",})

socket.emit("game/connect", data={"game_id": 23497324,
                                       "player_id": 767011,
                                       "chat": False})

socket.emit("game/move", data={"game_id": 23497324,
                         "player_id": 767011,
                         "move": "ac"})
2 Likes

You rock! Thanks for posting this example for us to learn from

2 Likes