Skip to content

ymattw/googs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go OGS

Summary

googs is a Go package implements REST and Realtime APIs of OGS (online-go.com).

Status

The package allows users to authenticate, connect to games, receive game events, and submit moves as a player or watch as an observer.

Usage

First request an OGS application, with Authorization grant type set to Resource owner password-based, keep note of the client ID and unhashed client secret. Note empty client secret must be used if the Client type is Public.

Login once and persist credentials

client := googs.NewClient(clientID, clientSecret)
err := client.Login(username, password)
// if err != nil { ... }

client.Save(secretFile)

// Use REST API
overview, err := client.Overview())
// if err != nil { ... }
fmt.Printf("Total %d active games\n", len(overview.ActiveGames))

// Use Realtime API
client.GameConnect(12345)

client.OnGameData(gameID, func(g *googs.Game) {
	fmt.Printf("Received game data %s\n", g)
})

Load a client from a credential file

client, err := googs.LoadClient(secretFile)
// if err != nil { ... }

// Websocket is connected, ready to use the APIs

Demo

See example usages in demo/ which is a working minimal OGS client program that you can use to watch and play games on OGS.

And check out ymattw/tenuki for a full OGS client application!

About

Go client package for OGS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •