Python client and CLI for the BoardGameGeek XML API
Project description
bgg-search
bgg-search is a Python package and command-line tool for querying the
BoardGameGeek XML API. It lets you search for board games
by name and retrieve full game details — player counts, play time, weight, BGG rating, and
more — from the command line or from your own Python code.
Installation
pip install bgg-search
Requires Python ≥ 3.13.
A BGG API token is required to make requests. Obtain one by registering your application at
https://boardgamegeek.com/applications, then expose it as the BGG_TOKEN environment
variable.
Quickstart
CLI
export BGG_TOKEN=<your-token>
# Search for games matching a query
bgg-search search "Catan"
# 13 Catan
# 396790 Catan: New Energies
# ...
# Fetch full details for a game by its BGG ID
bgg-search details 13
# id: 13
# name: Catan
# year: 1995
# min_players: 3
# max_players: 4
# ...
Python API
import os
from bgg_search import BggClient, search_games, get_game
client = BggClient(token=os.environ["BGG_TOKEN"])
results = search_games("Catan", client)
for game in results:
print(game.id, game.name)
details = get_game(13, client)
print(details.name, details.bgg_rating)
Python API reference
Use-case functions
search_games(query: str, client: BggClientProtocol) -> list[GameSummary]
Search BGG for board games matching query. Returns results in BGG API order.
Returns an empty list when no games match.
get_game(game_id: int, client: BggClientProtocol) -> GameDetails
Fetch full details for the game identified by game_id.
Raises BggNotFoundError when the ID does not exist on BGG.
BggClientProtocol
A typing.Protocol defining the client contract. Pass any object that implements
search(query: str) -> list[GameSummary] and get_game(game_id: int) -> GameDetails.
The bundled BggClient satisfies this protocol.
from bgg_search import BggClient
client = BggClient(token="<your-token>")
Models
GameSummary
| Field | Type | Description |
|---|---|---|
id |
int |
BGG game ID |
name |
str |
Primary game title |
GameDetails
| Field | Type | Description |
|---|---|---|
id |
int |
BGG game ID |
name |
str |
Primary game title |
year_published |
int | None |
Year of first publication |
min_players |
int | None |
Minimum number of players |
max_players |
int | None |
Maximum number of players |
min_playtime |
int | None |
Minimum play time in minutes |
max_playtime |
int | None |
Maximum play time in minutes |
weight |
float | None |
BGG complexity weight (1.0 – 5.0) |
bgg_rating |
float | None |
BGG community rating (1.0 – 10.0) |
Exceptions
| Exception | Inherits from | Raised when |
|---|---|---|
BggSearchError |
Exception |
Base class for all package exceptions |
BggApiError |
BggSearchError |
BGG API returns an HTTP error |
BggNotFoundError |
BggSearchError |
Requested game ID does not exist |
BggParseError |
BggSearchError |
BGG API response cannot be parsed |
CLI reference
All commands read the BGG token from the BGG_TOKEN environment variable and exit
with code 1 (printing an error to stderr) if it is not set or if the BGG API returns
an error.
bgg-search search <query>
Search for board games by name.
bgg-search search <query>
| Argument | Description |
|---|---|
query |
Free-text search term |
Output: one line per result, formatted as {id:>8} {name}. No output when no games match.
bgg-search details <id>
Fetch and display full details for a game.
bgg-search details <id>
| Argument | Description |
|---|---|
id |
BGG game ID (integer) |
Output: labeled key-value block, one field per line:
id: 13
name: Catan
year: 1995
min_players: 3
max_players: 4
min_playtime: 60
max_playtime: 120
weight: 2.3
bgg_rating: 7.1
Exits with code 1 and prints an error to stderr when the game ID is not found.
Development
Run the quality gate (lint, type-check, security scan, unit tests):
tox
Run integration tests against the real BGG API:
BGG_TOKEN=<your-token> tox -e integ
A BGG API token is required. Obtain one by registering your application at
https://boardgamegeek.com/applications. Tests are skipped automatically when
BGG_TOKEN is not set.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bgg_search-0.4.0.tar.gz.
File metadata
- Download URL: bgg_search-0.4.0.tar.gz
- Upload date:
- Size: 26.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4544779bc847b907e490de90362b852bc34efb3244a19f1326acd5b2ed1c33f4
|
|
| MD5 |
63511d8f23f8a385b09e28bb73570278
|
|
| BLAKE2b-256 |
7306b15635748d227deb8990220c1faa0d41d7cb740d437b36fdac7565112775
|
Provenance
The following attestation bundles were made for bgg_search-0.4.0.tar.gz:
Publisher:
publish.yml on arnauldvm/bgg-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bgg_search-0.4.0.tar.gz -
Subject digest:
4544779bc847b907e490de90362b852bc34efb3244a19f1326acd5b2ed1c33f4 - Sigstore transparency entry: 1752815993
- Sigstore integration time:
-
Permalink:
arnauldvm/bgg-search@5c7a6caa4e0c6ce86d6ac97ccc336a5890a6bfcd -
Branch / Tag:
refs/tags/version/0.4.0 - Owner: https://github.com/arnauldvm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5c7a6caa4e0c6ce86d6ac97ccc336a5890a6bfcd -
Trigger Event:
push
-
Statement type:
File details
Details for the file bgg_search-0.4.0-py3-none-any.whl.
File metadata
- Download URL: bgg_search-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12cb4bcd547187babbc78bc4c11ae3f10b23f45758fd138b7701f76f28b02e4b
|
|
| MD5 |
e59a674023144dc03cba20bf7e1cad25
|
|
| BLAKE2b-256 |
78ab12e6a11d0d378a0a3531037ecfdae6390a435280aa1fb2847659033ccf2e
|
Provenance
The following attestation bundles were made for bgg_search-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on arnauldvm/bgg-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bgg_search-0.4.0-py3-none-any.whl -
Subject digest:
12cb4bcd547187babbc78bc4c11ae3f10b23f45758fd138b7701f76f28b02e4b - Sigstore transparency entry: 1752816077
- Sigstore integration time:
-
Permalink:
arnauldvm/bgg-search@5c7a6caa4e0c6ce86d6ac97ccc336a5890a6bfcd -
Branch / Tag:
refs/tags/version/0.4.0 - Owner: https://github.com/arnauldvm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5c7a6caa4e0c6ce86d6ac97ccc336a5890a6bfcd -
Trigger Event:
push
-
Statement type: