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.
Api Game List of 100 (by default)
@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.
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.
Please Log In to post.
Log in to comment