knitr::opts_chunk$set(echo = TRUE)
# Load the package.
library(igdb)

Travis-CI Build Status

The IGDB package provides access to the IGDB API which gives information on video games, developers, reviews, companies, and other related content.

Install

Use devtools to install from Github.

devtools::install_github("detroyejr/igdb")

Usage

At the time of this package was developed, most of the available API endpoints are covered. These include:

Each function follows a similar format.

You can find the full documentation for the API here.

API Key

Before you can begin to use the service, sign up and receive an API key. Once you have your key, you can pass it to the function parameter api_key or use

Sys.setenv("IGDB_KEY" = 'YOUR_API_KEY`)

to add it to your environment. The function igdb_key() will look in the system environment for a variable with that name.

Examples

Games

# Returns games matching "bioshock" but filters games released after 2015.
igdb_games(
  search = "bioshock",
  order = "first_release_date:asc",
  filter = "[first_release_date][lt]=2016-01-01",
  fields = c("id", "name", "first_release_date", "rating", "popularity")
  )

Companies

igdb_companies(
  search = "2k",
  order = "start_date:desc",
  fields = c("id", "name", "start_date", "published"),
  n = 20
  )

Reviews

igdb_reviews(
  search = "bioshock",
  fields = c("username", "created_at", "title", "game", "views", "platform")
)

Characters

igdb_characters(
  search = "booker dewitt"
)

Filtering Results

To get results for specific games, use the filter options.

# Filter on slug value.
igdb_games(filter = "[slug][eq] = bioshock-infinite")

# Filter on game id.
igdb_reviews(filter = "[game][eq] = 538")

Known Quirks

Queries with No Results

In some cases if there are no results, the API will issue a 404 reponse causing a function error.

igdb_genres(search = "action")

Scroll Issue

Scrolling may also not work always work as expected with smaller queries. We still get the first 50 results, but not as many as expected. R will issue a warning when this happens. For better results, switch to pagination using offset.

# Pagination with Scroll.
games <- igdb_games("halo", scroll = TRUE, n = 100)
NROW(games)

# Pagination with offset.
games <- igdb_games("halo", scroll = FALSE, n = 100)
NROW(games)

Contributing

If you find any bugs, you can file an issue or create a pull request. Each function was created using the same basic template. As long as there are no breaking api changes, adding new endpoints should be simple.



detroyejr/igdb documentation built on May 21, 2019, 3:09 a.m.