Api Game List of 100 (by default)

Avatar image for sinistersanatra
SinisterSanatra

2

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

So I am building a game search android app for school and I have a list of games that people can look at. What I want to know is if there is a way to have the games api call that Giant Bombs allows you to get a list of games to show up (100 by default,) to be randomly generated each time someone clicks the button to see the list of games.

Avatar image for peteace
peteace

39

Forum Posts

996

Wiki Points

0

Followers

Reviews: 2

User Lists: 3

@sinistersanatra: You could use the offset parameter to make it seem like you're pulling a random list of games. Just generate a random number between 0 and however many games are in the database - 100. Then use the URL http://www.giantbomb.com/api/games/?api_key=<key>&format=json&offset=<offset> and it will give you 100 games from that offset on. The games are sorted by their ID that is given when added to the database, so they look kind of random if you just grab a slice of 100 games.

Avatar image for chaser324
chaser324

9415

Forum Posts

14945

Wiki Points

0

Followers

Reviews: 1

User Lists: 15

#3  Edited By chaser324  Moderator

The best way to do this would probably be to use the API populate your own SQLite database and then pull 100 random entries from there. Assuming no gaps in the entry IDs, it should be pretty easy to just generate 100 random integers between the min and max ID (you could use something like a hashset to store them and check that each ID is unique) and then query the table for those entries.