https://github.com/fzerorubigd/gobgg
Boardgamegeek API for Golang
https://github.com/fzerorubigd/gobgg
bgg bgg-api bgg-library boardgamegeek golang golang-library
Last synced: about 1 month ago
JSON representation
Boardgamegeek API for Golang
- Host: GitHub
- URL: https://github.com/fzerorubigd/gobgg
- Owner: fzerorubigd
- License: mit
- Created: 2020-05-29T20:33:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-13T02:13:26.000Z (about 1 month ago)
- Last Synced: 2025-03-18T11:38:58.703Z (about 1 month ago)
- Topics: bgg, bgg-api, bgg-library, boardgamegeek, golang, golang-library
- Language: Go
- Homepage:
- Size: 172 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Boardgamegeek API Client for Golang
===
[](https://goreportcard.com/report/github.com/fzerorubigd/gobgg)
[](https://codecov.io/gh/fzerorubigd/gobgg)
[](https://pkg.go.dev/github.com/fzerorubigd/gobgg)Basics
---
Create a new client using the `NewBGGClient` also you can use the `Login` function
to set the cookies, some API (like posting plays) needs the login cookies.You can set the `http.Client`, or `http.Cookie` or using different domain (do you need to?)
```go
bgg := gobgg.NewBGGClient(gobgg.SetClient(client))
// Setting the cookies (not a requirement if you want to only use public API)
if err := bgg.Login("user", "password"); err != nil {
log.Fatalf("Login failed with error: %q", err)
}
```
Collection API
---
Getting the collection in boardgamegeek is a little tricky, so the library will retry with a backoff
to get the collection. You can control the timeout using the context passed to the function
or it will retry forever.```go
collection, err := bgg.GetCollection(ctx, "fzerorubigd", gobgg.SetCollectionTypes(gobgg.CollectionTypeOwn))
```Things API
---
You can get the things detail (I just use the board game related API so far) it always
comes with the statistics (why it should be a flag!)I decided to follow the same pattern for all the functions even when it is not required.
```go
things , err := bgg.GetThings(ctx, gobgg.GetThingIDs(1, 2, 3))
```Plays API
---Getting a play is like this:
```go
// For users
plays, err := bgg.Plays(ctx, gobgg.SetUserName("fzerorubigd"))
// For a game
plays, err := bgg.Plays(ctx, gobgg.SetGameID(1))
```Posting Plays
---
Posting play is an experimental API that is not using any documented API end point, for this
you need to call `Login` first.Person API
---
For getting the person image you can use the -undocumented- person API `PersonImage`GeekList
---
The library supports getting the lists by their id using the `GeekList` functionHotness
---
It is possible to get thodays hotness and the the change since yesterday using the `Hotness` functionRate Limiting
---Boardgamegeek does rate limit on all the api calls. Its a good idea to add a rate limiter to your client.
it is already supported and I recommend the `go.uber.org/ratelimit````go
import (
"fmt"
"time""go.uber.org/ratelimit"
"github.com/fzerorubigd/gobgg"
)rl := ratelimit.New(10, ratelimit.Per(60*time.Second)) // creates a 10 per minutes rate limiter.
client := gobgg.NewBGGClient(gobgg.SetLimiter(rl))
```