1.0.1 • Published 3 years ago

@mrmory/bggclient v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

GitHub Workflow Status (branch) GitHub release (latest by date)

forked from boardgamegeekclient

This package is forked from boardgamegeekclient in order to do maintance myself and to have an updated package in my project.

boardgamegeekclient

It's a wrapper around the offcial boardgamegeek V2 API, with the scope to create a more confortable way to interact with them since they are exposed in XML format.
With this package you can create your own web app or integrate your backend for example.

Key features

  • :ballot_box_with_check: Fully typed requests and responses
  • :ballot_box_with_check: Easy to use
  • :ballot_box_with_check: Typescript written
  • :ballot_box_with_check: Promisified
  • :ballot_box_with_check: thing, family, forum, thread, user, guild, play, collection endpoints

Installation

npm i boardgamegeekclient
yarn add boardgamegeekclient

Usage

In Node.js (commonjs) environment

const { BggClient } = require("boardgamegeekclient");

In ES environment

import { BggClient } from 'boardgamegeekclient';

or Web using module and Skypack

<script type="module">
  import boardgamegeekclient from 'https://cdn.skypack.dev/boardgamegeekclient';
</script>

Now you initialize BggClient

const client = BggClient.Create();

API

You can interact with boardgamegeek entities using the corresponding client object exposed and fire a request with query method. Any client have only this public method but with different parameters.

Thing

Get boardgame, boardgame expansion, boardgame accessory, videogame, rpgitem, rpgissue informations.

IThingRequest

PropertyTypeRequiredExampleDescription
idnumber | number[]:ballot_box_with_check:{ id: 281647 or id: 281647, 332398 }Specifies the id of the thing(s) to retrieve. To request multiple things with a single query, NNN can specify a comma-delimited list of ids.
typearray of | 'boardgame'| 'boardgameexpansion' | 'boardgameaccessory' | 'videogame' | 'rpgitem' | 'rpgissue'{ type: 'boardgame' or type: 'boardgame', 'boardgameexpansions' }Specifies that, regardless of the type of thing asked for by id, the results are filtered by the THINGTYPE(s) specified. Multiple THINGTYPEs can be specified in a comma-delimited list.
versionnumber{ version: 1 }Returns version info for the item.
videosnumber{ videos: 1 }Returns videos for the item.
statsnumber{ stats: 1 }Returns ranking and rating stats for the item.
marketplacenumber{ marketplace: 1 }Returns marketplace data.
commentsnumber{ comments: 1 }Returns all comments about the item. Also includes ratings when commented. See page parameter.
ratingcommentsnumber{ ratingcomments: 1 }Returns all ratings for the item. Also includes comments when rated. See page parameter. The ratingcomments and comments parameters cannot be used together, as the output always appears in thenode of the XML; comments parameter takes precedence if both are specified. Ratings are sorted in descending rating value, based on the highest rating they have assigned to that item (each item in the collection can have a different rating).
pagenumber{ page: 3 }Defaults to 1, controls the page of data to see for historical info, comments, and ratings data.
pagesizenumber{ pagesize: 100 }Set the number of records to return in paging. Minimum is 10, maximum is 100.

Returns

BggThingDto[]

Examples

const things = await client.thing.query({ id: [174430, 35421] });

Family

Get rpg, rpgperiodical, boardgamefamily informations.

IFamilyRequest

PropertyTypeRequiredExampleDescription
idnumber | number[]:ballot_box_with_check:{ id: 8374 or id: 8374, 22184 }Specifies the id of the family to retrieve. To request multiple families with a single query, NNN can specify a comma-delimited list of ids.
typearray of | 'rpg'| 'rpgperiodical' | 'boardgamefamily'{ type: 'boardgamefamily' or type: 'boardgamefamily', 'rpg' }Specifies that, regardless of the type of family asked for by id, the results are filtered by the FAMILYTPE(s) specified. Multiple FAMILYTYPEs can be specified.

Returns

BggFamilyDto[]

Examples

const families = await client.family.query({ id: [174430, 35421] });

Forum List

Get a list of forums
(in boardgame or family page (of the id), forums tab, left sidebars with all forums)

IForumlistRequest

PropertyTypeRequiredExampleDescription
idnumber | number[]:ballot_box_with_check:{ id: 8374 or id: 8374, 22184 }Specifies the id of the type of database entry you want the forum list for. This is the id that appears in the address of the page when visiting a particular game in the database.
typearray of | 'thing'| 'family'{ type: 'thing' }The type of entry in the database.

Returns

BggForumlistDto[]
const forumlists = await client.forumlist.query({ id: [8374,22184,59218,1029,2076], type: ['family']});

Forum

Get a single forum.

IForumRequest

PropertyTypeRequiredExampleDescription
idnumber:ballot_box_with_check:{ id: 19 }Specifies the id of the forum. This is the id that appears in the address of the page when visiting a forum in the browser.
pagenumber{ page: 2 }The page of the thread list to return; page size is 50. Threads in the thread list are sorted in order of most recent post.

Returns

BggForumDto[]

Examples

const forum = await client.forum.query({ id: 19 });

Thread

Get a single thread.

IThreadRequest

PropertyTypeRequiredExampleDescription
idnumber:ballot_box_with_check:{ id: 2571698 }Specifies the id of the thread to retrieve.
minarticleidnumber{ minarticle: 2 }Filters the results so that only articles with an equal or higher id than NNN will be returned.
minarticledatestring{ minarticledate: '2021-01-03' }Filters the results so that only articles on the specified date or later will be returned.
countnumber{ count: 20 }Limits the number of articles returned to no more than NNN.

Returns

BggThreadDto[]

Examples

const thread = await client.thread.query({ id: 2571698, minarticledate: '2021-01-03' });

User

Get public profile information about a user by username.

IUserRequest

PropertyTypeRequiredExampleDescription
namestring:ballot_box_with_check:{ name: 'mattiabanned' }Specifies the user name (only one user is requestable at a time).
buddiesnumber{ buddies: 1 }Turns on optional buddies reporting. Results are paged; see page parameter.
guildsnumber{ guilds: 1}Turns on optional guilds reporting. Results are paged; see page parameter.
hotnumber{ count: 1 }Include the user's hot 10 list from their profile. Omitted if empty.
topnumber{ top: 1 }Include the user's top 10 list from their profile. Omitted if empty.
domainstring - one of | 'boardgame' | 'rpg' | 'videogame'{ domain: 'rpg'}Controls the domain for the users hot 10 and top 10 lists. The DOMAIN default is boardgame
pagenumber{ page: 2 }Specifies the page of buddy and guild results to return. The default page is 1 if you don't specify it; page size is 100 records (Current implementation seems to return 1000 records). The page parameter controls paging for both buddies and guilds list if both are specified. If a buddies or guilds node is empty, it means that you have requested a page higher than that needed to list all the buddies/guilds or, if you're on page 1, it means that that user has no buddies and is not part of any guilds.

Returns

BggUserDto[]

Examples

const user = await client.user.query({ name: 'mattiabanned', hot: 1, top: 1 });

Guild

Get a single guild.

IGuildRequest

PropertyTypeRequiredExampleDescription
idnumber:ballot_box_with_check:{ id: 1000 }ID of the guild you want to view.
membersnumber{ buddies: 1 }Include member roster in the results. Member list is paged and sorted.
sortstring - one of | 'username' | 'date'{ sort: 'date' }Specifies how to sort the members list; default is username.
pagenumber{ page: 2 }The page of the members list to return. Page size is 25.

Returns

BggGuildDto[]

Examples

const guild = await client.guild.query({ id: 1000, members: 1, sort: 'date', page: 1 });

Play

Request plays logged by a particular user or for a particular item.

IPlayRequest

PropertyTypeRequiredExampleDescription
usernamestring:ballot_box_with_check: or id{ string: 'mattiabanned' }Name of the player you want to request play information for. Data is returned in backwards-chronological form. You must include either a username or an id and type to get results.
idnumber:ballot_box_with_check: or username{ id: 1 }Id number of the item you want to request play information for. Data is returned in backwards-chronological form.
typestring - one of | 'thing' | 'family'{ type: 'thing' }Type of the item you want to request play information for.
mindatestring{ mindate: '2020-05-27' }Returns only plays of the specified date or later.
maxdatestring{ maxdate: '2020-06-13' }Returns only plays of the specified date or earlier.
subtypestring - one of | 'boardgame' | 'boardgameexpansion' | 'boardgameaccessory' | 'rpgitem' | 'videogame'{ subtype: 'boardgameexpansion' }Limits play results to the specified TYPE; boardgame is the default.
pagenumber{ page: 2 }The page of information to request. Page size is 100 records.

Returns

BggPlayDto[]

Examples

const play = await client.play.query({ username: 'mattiabanned' });

Collection

ICollectionRequest

Get details about a user's collection.

PropertyTypeRequiredExampleDescription
usernamestring:ballot_box_with_check:{ username: 'mattiabanned' }Name of the user to request the collection for.
versionnumber{ version: 1 }Returns version info for each item in your collection.
subtypestring - one of | 'boardgame' | 'boardgameexpansion' | 'boardgameaccessory' | 'rpgitem' | 'rpgissue' | 'videogame'{ subtype: 'rpgitem' }Specifies which collection you want to retrieve the default is boardgame.
excludesubtypestring{ excludesubtype: }Specifies which subtype you want to exclude from the results.
idnumber | number[]{ id: 312484 } or { id: 312484, 255984 }Filter collection to specifically listed item(s)
briefnumber{ brief: 2 }Returns more abbreviated results.
statsnumber{ stats: 1 }Returns expanded rating/ranking info for the collection.
ownnumber{ own: 1 }Filter for owned games. Set to 0 to exclude these items so marked. Set to 1 for returning owned games and 0 for non-owned games.
ratednumber{ rated: 1 }Filter for whether an item has been rated. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
playednumber{ played: 1 }Filter for whether an item has been played. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
commentnumber{ comment: 1 }Filter for items that have been commented. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
tradenumber{ trade: 1 }Filter for items marked for trade. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
wantnumber{ want: 1 }Filter for items wanted in trade. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
wishlistnumber{ wishlist: 1 }Filter for items on the wishlist. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
wishlistprioritynumber - range 1-5{ wishlistpriority: 1 }Filter for wishlist priority. Returns only items of the specified priority.
preorderednumber{ preordered: 1 }Filter for pre-ordered games Returns only items of the specified priority. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
wanttoplaynumber{ wanttoplay: 1 }Filter for items marked as wanting to play. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
wanttobuynumber{ wanttobuy: 1 }Filter for ownership flag. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
prevownednumber{ prevowned: 1 }Filter for games marked previously owned. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
haspartsnumber{ hasparts: 1 }Filter on whether there is a comment in the Has Parts field of the item. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
wantpartsnumber{ wantparts: 1 }Filter on whether there is a comment in the Wants Parts field of the item. Set to 0 to exclude these items so marked. Set to 1 to include only these items so marked.
minratingnumber - range 1-10{ minrating: 6 }Filter on minimum personal rating assigned for that item in the collection.
ratingnumber - range 1-10{ rating: 10 }Filter on maximum personal rating assigned for that item in the collection. Note: Although you'd expect it to be maxrating, it's rating.
minbggratingnumber - range 1-10{ minbggrating: 3 }Filter on minimum BGG rating for that item in the collection. Note: 0 is ignored... you can use -1 though, for example min -1 and max 1 to get items w/no bgg rating.
bggratingnumber - range 1-10{ bggrating: 2 }Filter on maximum BGG rating for that item in the collection. Note: Although you'd expect it to be maxbggrating, it's bggrating.
minplaysnumber{ minplays: 3 }Filter by minimum number of recorded plays.
maxplaysnumber{ maxplays: 3 }Filter by maximum number of recorded plays. Note: Although the two maxima parameters above lack the max part, this one really is maxplays.
showprivatenumber{ showprivate: 1 }Filter to show private collection info. Only works when viewing your own collection and you are logged in.
collidnumber{ collid: 1000 }Restrict the collection results to the single specified collection id. Collid is returned in the results of normal queries as well.
modifiedsincestring{ modifiedsince: '20-12-31' }Restricts the collection results to only those whose status (own, want, fortrade, etc.) has changed or been added since the date specified (does not return results for deletions). Time may be added as well: modifiedsince=YY-MM-DD%20HH:MM:SS

Returns

BggPlayDto[]

Examples

const play = await client.play.query({ username: 'mattiabanned' });