Search with multiple filters?

Avatar image for invulnerable
invulnerable

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#1  Edited By invulnerable

I'm trying to make a dynamic app to allow users to search by game name and expected year release. How would I go about making this call? I've tried:

http://www.giantbomb.com/api/games/?api_key=API_KEY&filter=expected_release_year:2013,name:battlefield3&format=json&limit=5&sort=original_release_date:asc

amoungst other things replacing the comma. How would I go about making this call to return both filters?

Avatar image for soup_menu
soup_menu

293

Forum Posts

26

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#2  Edited By soup_menu

@invulnerable: You're most of the way there.

One issue is that the "name:battlefield3" filter won't ever return results. The there's a space between "battlefield" and "3" in the database, so you'd need to do "name:battlefield%203".

The other issue is that, per the API documentation, expected_release_year will be empty if original_release_date is set. I thought I was going to have to recommend using two queries--one for released games and another for unreleased ones--but it appears that the API will accept a request like:

http://www.giantbomb.com/api/games/?api_key=API_KEY&filter=expected_release_year:2013,original_release_date:2013-01-01%2000:00:00|2013-12-31%2023:59:59,name:battlefield%203&format=json&limit=5&sort=original_release_date:asc

In this case that still won't return any results, but that's only because Battlefield 3 came out in 2011. If you change the request like so:

http://www.giantbomb.com/api/games/?api_key=API_KEY&filter=expected_release_year:2011,original_release_date:2011-01-01%2000:00:00|2011-12-31%2023:59:59,name:battlefield%203&format=json&limit=5&sort=original_release_date:asc

...you'll get one hit.

Hope that helps!