Skip to main content

An API Wrapper for online-go.com, an online Go / Baduk server

Project description

OGS Python Library

pipeline status Latest Release PyPI version

Summary

An API wrapper written in python for the Online-Go Server's (OGS) REST API and Realtime (SocketIO) API

THIS IS STILL HEAVILY IN DEVELOPMENT. VERY MUCH NOT READY FOR USE

Read the documentation here for more info: https://ogs-python.dakotamarshall.net/

Install

Pip Package

python3 -m pip install ogsapi

Manual

Installing the specific versions in requirements.txt is REQUIRED, the OGS API does not support newer versions, and these versions of socketio and engineio are tested to be compatible with each other.

pip3 install -r requirements.txt

If you install the wrong version by accident, you must uninstall and re-install.

pip3 uninstall python-engineio python-socketio
pip3 install -r requirements.txt

Usage

from ogsapi.client import OGSClient

ogs = OGSClient('your_client_id', 'your_client_secret', 'your_username', 'your_password')

This will authenticate you to OGS using your API credentials, and connect you to the Realtime API Socket. You can now call the usable functions.

Implemented API Functions

NOTE All usernames are case sensitive

User Functions

  • Get User vitals: ogs.user_vitals()
  • Get User Settings: ogs.user_settings()
  • Update User Settings: `ogs.update_user_settings()
    • username: str
    • first_name: str
    • last_name: str
    • country: str
    • private_name: bool
    • website: str
    • about: str
  • Get User Games: ogs.user_games()
  • Get User Friends (Optionally search for user): ogs.user_friends(username)
  • Send friend request: ogs.send_friend_request(username)

Player Functions

  • Get Player Info: ogs.get_player(username)
  • Get Received Challenges: ogs.received_challenges
  • Get Sent Challenges: ogs.sent_challenges()
  • Get Challenge Details: ogs.challenge_details(challenge_id)
  • Get Game Details: ogs.game_details(game_id)

Implemented Realtime API Functions

  • Get Host Info: ogs.sock.host_info()
  • Ping: ogs.sock.ping()
  • Connect To Notification Stream: ogs.sock.notification_connect()
  • Connect to Chat: ogs.sock.chat_connect()
  • Connect to a Game: ogs.sock.game_connect(gameid: int)
    • This returns an object containing all the functions to handle received events from that game
    • To be able to run code when a move is received, you need to register a callback function you made with:
    • ogs.sock.games[game_id].register_callback(callback)
  • Disconnect from a Game: ogs.sock.game_disconnect(game_id)

Implemented Game Functions

  • Make a move: ogs.sock.games[game_id].move('jj')
  • Pass turn: ogs.sock.games[game_id].pass_turn()
  • Request an undo: ogs.sock.games[game_id].undo()
  • Resign: ogs.sock.games[game_id].resign()

Implemented Received Events

  • Getting gamedata: ogs.sock.games[game_id].game_data
  • Getting connection latency: ogs.sock.games[game_id].latency
  • Getting a move: ogs.sock.games[game_id].callback_func['on_move']

Currently Supported Time Controls

  • Fischer
  • Byoyomi
  • None

Checklist

Current checklist of API calls / events that are implemented

  • REST API
    • Games
      • GET - id
      • GET - id/png
      • GET - id/reviews
      • GET - id/sgf
    • Me
      • GET - /
      • GET - account_settings
      • GET - blocks
      • GET - friends
      • GET - games
      • GET - challenges
      • GET - groups
      • GET - ladders
      • GET - settings
      • GET - ui/overview
    • Players
      • GET - id
      • GET - id/full
      • GET - id/games
      • GET - id/groups
      • GET - id/ladders
      • GET - id/tournaments
  • Realtime API Game Events
    • Server to Client
      • auto_resign
      • chat (This is for chat rooms, low priority)
      • chat/remove
      • clear_auto_resign
      • clock
      • conditional_moves
      • error
      • gamedata
      • latency
      • phase
      • removed_stones
      • removed_stones_accepted
      • reset
      • reset-chats
      • undo_accepted
      • undo_canceled
      • undo_requested
    • Client to Server
      • annul
      • cancel
      • chat
      • chat/remove
      • clear_delayed_resign
      • conditional_moves/set
      • connect
      • delayed_resign
      • disconnect
      • latency
      • log
      • move
      • pause
      • removed_stones/accept
      • removed_stones/reject
      • removed_stones/set
      • resign
      • resume
      • timed_out
      • undo/accept
      • undo/cancel
      • undo/request
  • Implement proper challenge creation
  • Create open challenge
  • Handle accepting / rejecting counting

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ogsapi-0.7.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ogsapi-0.7.0-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file ogsapi-0.7.0.tar.gz.

File metadata

  • Download URL: ogsapi-0.7.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for ogsapi-0.7.0.tar.gz
Algorithm Hash digest
SHA256 dfa99d2b9c3cdb119ecfd525bf1c25d278ff302b1810d21f7dae4450c298a3bc
MD5 8237fc0c77a70a2a5580f9fc6efda8a4
BLAKE2b-256 0fc305a8a526cd44924505edc74f8d4ddb2c75a175fbe7da9c9a5adc8a16889f

See more details on using hashes here.

File details

Details for the file ogsapi-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: ogsapi-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for ogsapi-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 710a3e8b294f4d27af2dc64ab79e3cf0339d0dcd24acb6ef9e51d7478e3ecd56
MD5 e32ee5ca3f7afafde6c06af7d0b71502
BLAKE2b-256 5072262fb1a221285520b632420eff810a137fb1fd85aaa50c79b6989eddd0a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page