detroyejr / igdb

Provides functions for accessing the internet game database api.
GNU General Public License v3.0
2 stars 0 forks source link

Expander Feature of API not implemented #1

Closed EnsuingRequiem closed 6 years ago

EnsuingRequiem commented 6 years ago

When attempting to use the expander function of the IGDB API, R returns an error.

Code returning the error: pkmn <- igdb::igdb_games(search = "pokemon", filter = "[developers][eq]=1617", n = 20, order = "first_release_date:asc", fields = c("name", "developers.name", "first_release_date"), expand = "companies")

Error received: Error in igdb::igdb_games(search = "pokemon", filter = "[developers][eq]=1617", : unused argument (expand = "companies")

detroyejr commented 6 years ago

Hi, thanks for submitting an issue! It looks like that part of the api isn't implemented yet. Though it looks like a pretty easy addition. Let me check in a few things and see if that gets you what you need.

detroyejr commented 6 years ago

Original query still doesn't work (404: Bad Request Error), but the following now works in the new branch:

# Install package at feature branch.
devtools::install_github("detroyejr/igdb", ref = "feature/expand")

# Working query.
pkmn <- igdb::igdb_games(
  search = "pokemon",
  filter = "[developers][eq]=1617",
  n = 20, order = "first_release_date:asc",
  fields = c("game.name", "developers.name", "first_release_date"),
  expand = "developers"
)

Can you verify that the query you originally attempted is correct? And, then verify that the output is what you're expecting?

EnsuingRequiem commented 6 years ago

I did have to make one change to the original query, but I actually prefer it the way implemented. expand = "companies" became expand = " developers". The output appears correct and I went ahead to try a couple of other scenarios (I'm new to both R and APIs). Looking at the first example presented, the query can accept multiple expanders (same for filters). Is the preferred method of inputting these something along the lines of expand = "developers,franchise" or more like the fields input which is fields = c("name", "developers.name", "first_release_date", "franchise.name")?

This is the query I have with multiple filters & expanders in a format that works:

# Query with compound filters and compound expands
pkmn <- igdb::igdb_games(
  search = "pokemon",
  filter = "[developers][eq]=1617&filter[franchise][eq]=60",
  n = 10,
  order = "first_release_date:asc",
  fields = c("name", "developers.name", "first_release_date", "franchise.name"),
  expand = "developers,franchise"
)

Here is the properly formed query from the original comment:

# Query from the original issue post
pkmn <- igdb::igdb_games(
  search = "pokemon",
  filter = "[developers][eq]=1617",
  n = 10,
  order = "first_release_date:asc",
  fields = c("name", "developers.name", "first_release_date"),
  expand = "developers"
)