This is a simple Haxe implementation for fetching data from the BoardGameGeek API.
Installation
The library is available on Haxelib.
haxelib install boardgamegeek
Add tink_xml as a git library. Haxelib does not currently allow git dependencies in haxelib.json.
--library tink_xml:git:https://github.com/haxetink/tink_xml.git
Usage
All the API interactions are implemented in the BoardGameGeek class.
Note that all methods return tink_core promises. As such they are compatible with the rest of the tink framework. For the examples here, it is assumed that tink_await is also installed, but it is not a dependency of this library.
var bgg: BoardGameGeek = new BoardGameGeek();
// get a specific board game by id
var game: Thing = @await bgg.getThing(283355);
game.name;
game.categories;
// get all of the game's expansions
var expansions: Array<Thing> = @await bgg.getExpansions(game);
// search for a board game by name
var results: Array<SearchResult> = @await bgg.search('Carcassone', BoardGameExpansion);
// get a user's public profile
var user: User = @await bgg.getUser('Haath');
Collections
User collections are fetched using a queue system. This means that on the first request, BGG will put us in a queue while it fetches the data.
// get a user's collection
var collection: UserCollection = null;
while (true)
{
collection = @await bgg.getCollection('Haath');
if (collection.items != null)
{
// got the result!
break;
}
// our request is in the queue, try again after 1sec
@await Future.delay(1000, 0);
}
Rate limiting
What is returned by the promise will be:
Success(data)if the request was successful, anddatais the returned object.Success(null)if the rate limiting error codes were returned by the API.Failure(err)on any other errorerr.