jservice.io api explanation

The jService api offers access to 156,800 Trivia Questions. The service is great but the documentation is sketchy, so I am going to give a brief overview of what I have been able to figure out so far.

  1. Before you do anything else, I recommend that you use the Chrome browser, visit the Chrome web store, and add an extension called the json viewer, which will format json in a way that you can actually read it without getting a headache.

  2. Visit http://jservice.io/api/random , which will bring up one random question. Once you have a good understanding of how to bring data from an api such as this one into a webpage, it would be fairly easy to create a question and answer game that asks a random question when the browser is refreshed and answers the question when a button is clicked.  The same random question generator can be extended by using the count argument with a number. It works like this:  http://jservice.io/api/random?count=100 . If you want more or less than 100 responses, simply change the number. With multiple responses you could eliminate the need to refresh the browser in order to get a new question, by storing the data ahead of time in an array or object and using the stored  q and as to produce lots of questions.
  3. Jservice questions can also be sorted by categories, and there seem to be approximately 100 categories. http://jservice.io/api/categories?count=1000  will lead you to all of the categories. This page will show the name of the various categories and also shows an id (see below). The id can, in turn, be used to pull up all items from that particular category via a url like this one:  http://jservice.io/api/category?id=11541

  4. So as I said earlier, your job here is simply to THINK about what you could do with all of the different forms of data that you can extract from this source. So think! And then move on to the next lesson