BoardGameGeek-Data-Extractor

BGG Extractor API Reference

Complete API reference for all modules and functions in the BGG Extractor library.

Table of Contents

Client Functions

Synchronous API

High-level synchronous functions that handle async operations internally.

search(query, **kwargs)

Search for board games by name.

Parameters:

Returns:

Example:

from bgg_extractor import search

results = search("Wingspan")
results = search("Pandemic", type="boardgame", exact=True)

get_things(ids, **kwargs)

Get detailed information about specific games.

Parameters:

Returns:

Example:

from bgg_extractor import get_things

# Get single game
game = get_things([174430], stats=True)

# Get multiple games
games = get_things([13, 174430, 266192], stats=True, videos=True)

get_collection(username, **kwargs)

Get a user’s game collection.

Parameters:

Returns:

Example:

from bgg_extractor import get_collection

collection = get_collection("eekspider", stats=True)
owned_games = get_collection("username", stats=True, minrating=7)

get_plays(username=None, **kwargs)

Get play history for a user or game.

Parameters:

Returns:

Example:

from bgg_extractor import get_plays

plays = get_plays(username="eekspider")
recent_plays = get_plays(username="eekspider", mindate="2024-01-01")

get_user(name, **kwargs)

Get user profile information.

Parameters:

Returns:

Example:

from bgg_extractor import get_user

user = get_user("eekspider")
user_with_top = get_user("eekspider", top=True, domain="boardgame")

get_family(ids, **kwargs)

Get details for specific game families.

Parameters:

Returns:

Example:

from bgg_extractor import get_family

family = get_family([2651], type="boardgamefamily")

Asynchronous API

Direct async client for advanced use cases.

BGGClient

Async context manager for BGG API operations.

Constructor Parameters:

Methods: All methods are async and must be awaited. They have the same parameters as their synchronous counterparts.

Example:

import asyncio
from bgg_extractor import BGGClient

async def fetch_data():
    async with BGGClient(token="your_token") as client:
        results = await client.search("Gloomhaven")
        games = await client.get_thing([174430], stats=True)
        return games

games = asyncio.run(fetch_data())

Persistence Functions

save_json(data, filepath)

Save data to JSON file.

Parameters:

Example:

from bgg_extractor import get_things, save_json

games = get_things([13, 174430])
save_json(games.items, "games.json")

save_csv(data, filepath)

Save data to CSV file.

Parameters:

Example:

from bgg_extractor import get_things, save_csv

games = get_things([13, 174430])
save_csv(games.items, "games.csv")

Transform Functions

model_to_dict(model)

Convert a single Pydantic model to dictionary.

Parameters:

Returns:

Example:

from bgg_extractor import get_things
from bgg_extractor.transform import model_to_dict

games = get_things([13])
game_dict = model_to_dict(games.items[0])

models_to_list(models)

Convert a sequence of Pydantic models to list of dictionaries.

Parameters:

Returns:

Example:

from bgg_extractor import get_things
from bgg_extractor.transform import models_to_list
import pandas as pd

games = get_things([13, 174430, 266192])
games_dict = models_to_list(games.items)
df = pd.DataFrame(games_dict)

Data Models

SearchSchema

Fields:

SearchItem


ThingSchema

Fields:

ThingItem


CollectionSchema

Fields:

CollectionItem


PlaysSchema

Fields:

Play


UserSchema

Fields:


Error Handling

Exceptions

The library raises standard Python exceptions:

Example Error Handling

from bgg_extractor import get_things

try:
    games = get_things([999999])  # Invalid ID
except RuntimeError as e:
    print(f"API Error: {e}")
except ValueError as e:
    print(f"Configuration Error: {e}")

API Rate Limiting

The BGG API has the following limits:

Handling 202 Responses:

The library automatically polls for up to 12 attempts (configurable) with exponential backoff.

from bgg_extractor import BGGClient

# Increase polling attempts
async with BGGClient(max_poll_attempts=20) as client:
    results = await client.search("Catan")

Increasing Delay:

# Increase delay between requests to 5 seconds
async with BGGClient(min_delay=5.0) as client:
    results = await client.search("Catan")