knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(knitr)
library(dplyr)
library(boardgameatlasR)

Introduction

The boardgameatlasR package contains a function called search_bga(). search_bga() is an API wrapper for the API of https://www.boardgameatlas.com.

This vignette will cover a few of the basic usages of search_bga() and how to avoid some common mistakes.

Setup

Before you get started, you'll have to take the following steps:

Adding your client_id to your R Environment

You can add the token with code like edit_r_environ() from the usethis package

And then enter your BGA client_id in the following manner into your .Renviron file:

# Boardgame Atlas API Key
BOARDGAMEATLAS_PAT = "YOUR_CLIENT_ID"

Once you have done this, you'll have to restart R or your R session for the changes to take effect.

Arguments of search_bga()

limit & skip

An important thing to understand is that the BGA API is restricted to queries of no more than 100 objects per query. In order to get more than 100 games you have to use the skip feature to start where you left off. For instance, the first five games returned when ordered by popularity (at the time of writing this, 12/12/2019) are the following:


 id                 name             year_published

kPDxpJZ8PD Spirit Island 2016

RLlDWHh7hR Gloomhaven 2017

i5Oqu5VZgP Azul 2017

yqR4PtpO8X Scythe 2016

6FmFeux5xH Pandemic 2008

This could be queried with the following:

search_bga(limit = 5, skip = 0, order_by = "popularity")

The above code skips no games, returning the first object onward up to the limit, which in this case is 5 game objects. The default order_by value is popularity, which is based on the total number of times the game is mentioned at https://www.reddit.com/r/boardgames - a subreddit - a kind of forum - that is based on the discussion and recommendation of board games.

The 6th-10th games returned when ordered by popularity are as follows:


 id                 name             year_published

oGVgRSAKwX Carcassonne 2000

fDn9rQjH9O Terraforming Mars 2016

TAAifFP590 Root 2018

FCuXPSfhDR Concordia 2013

6VQXkkC5ql Dominion: Second Edition 2016

And the above could be queried with the following:

search_bga(limit = 5, skip = 5, order_by = "popularity")

You can see above it skips the first 5 games and returns an additional 5 games, the limit.

You can use this pattern to go beyond the 100 game limit of the API by requesting 100 games and then adjusting the skip value, like so:

games_1_to_100 <- search_bga(limit = 100, skip = 0, order_by = "popularity")
games_101_to_200 <- search_bga(limit = 100, skip = 100, order_by = "popularity")

You could then merge the datasets with code along the lines of the following:

games_1_to_200 <- cbind(games_1_to_100, games_101_to_200)

name

It's important to talk about what is probably the most logical way to search for a game, which is by its name. Name is relatively complicated in terms of this API, however.

order_by

The order_by variable takes specific string arguments. Typos or other values will cause the query to stop. The values are as follows:

Logical Arguments

The search_bga() function includes a number of logical arguments, including kickstarter, random, name_exact, name_fuzzy, ascending.

Gameplay Statistics

The BGA API has multiple ways of querying certian values, such as an exact match, "less than" (e.g. lt_min_players), and "greater than" (e.g. gt_max_players) versions of most metrics. To simplify this system and maximize functionality, I focused on the query arguments that allowed for the building of ranges of requests. In most cases I created a bottom floor and a ceiling variable, which allow for the querying of specific values by making the two values equal. Down the line it might be valuable to add smoe of these other versions, but this provided the most elegant and simple solution to capturing, theoretically, every useful range of data.

The some sample values of these can be seen below:


year_published min_players max_players min_playtime max_playtime min_age


  2016             1             4             90            120          13

  2017             1             4             60            150          12

  2017             2             4             30             60           8

  2016             1             5             90            120          14

  2008             2             4             45             60           8

Pricing

Data

[SECTION COMING SOON]

Textual Data

[SECTION COMING SOON]

Monetary Data

[SECTION COMING SOON]

Publisher Data

[SECTION COMING SOON]

Physical Data

[SECTION COMING SOON]

Reddit Data

[SECTION COMING SOON]

Mechanics

[SECTION COMING SOON]

Categories

[SECTION COMING SOON]

Returned Data Basics

[SECTION COMING SOON]



mdweisner/boardgameatlasR documentation built on July 10, 2020, 12:24 p.m.