#1 Edited by latros (80 posts) -

For example,

  1. "I want a JSON representation of every game in the database where the Genre is FPS"

I thought the query for that would be something like,

"http://www.giantbomb.com/api/games/?api_key=[MY KEY]&format=JSON&genre=fps"

But that returns:

{

"error": "OK",

"limit": 100,

"offset": 0,

"number_of_page_results": 100,

"number_of_total_results": 42273,

"status_code": 1,

"results": [ array of 100 game objects ]

}

None of the objects in the results array even have a "genre" property, much less does it look like it's actually filtering properly.

  • How do I filter by genre, what would the query look like?

While we're at it:

  • How do I filter by release date, I.E. in a range, "between 1980 and 1990"?
  • How do I filter by giantbomb rating, I.E. "above 3 stars"?
  • How do I filter by whether or not GiantBomb has any videos uploaded for that game?

So many questions, so little API documentation with answers!

#2 Edited by Chaser324 (6335 posts) -

Let's address these questions one at a time:

How do I filter by genre, what would the query look like?

You need to filter by the ID of the genre you want. To get these IDs, you can pull the list from the genres resource:

http://www.giantbomb.com/api/genres/?format=json&api_key=YOUR_API_KEY

In the case of FPS, the ID is 32. So, now you'll filter the games resource based on that ID:

http://www.giantbomb.com/api/games/?format=json&api_key=YOUR_API_KEY&filter=genres:32

The same basic principle of filtering by ID works in many other cases too.

EDIT: Unfortunately upon testing that, genres only shows up for a single game and not in the collection. I guess maybe you need to ask someone like @frobie, @mrpibb about possibly adding it.

How do I filter by release date, I.E. in a range, "between 1980 and 1990"?

Again, you should use filter, with a pipe between the two desired date values. You'll also likely want to use sort so that your results are in some logical order:

http://www.giantbomb.com/api/games/?format=json&api_key=YOUR_API_KEY&filter=original_release_date:1980-1-1 00:00:00|1990-1-1 00:00:00&sort=original_release_date:asc

How do I filter by giantbomb rating, I.E. "above 3 stars"?

I think the only way you can handle this is to filter on the reviews resource rather than games, and I'm not sure if it's possible to do a range.

Also, take note that review scores are identified by their percentage value out of 100 (i.e. one star = 20, two stars = 40, etc.)

Here's an example for getting all three star reviews:

http://www.giantbomb.com/api/reviews/?format=json&api_key=YOUR_API_KEY&filter=score:60

How do I filter by whether or not GiantBomb has any videos uploaded for that game?

I'm not sure that you're going to be able to do this filtering in the API call. You'll likely need to handle this filtering on your end. Also, the videos resource isn't appearing in results pulled from the games resource (the same issue noted above).

Moderator