Interactive Trivia Using an API

Welcome to my sample fun facts trivia page!

Each time you click on the "Get Fun Fact" button, a new random fact will be generated. The fact is retrieved using a Trivia API from a database of thousands of fun facts. The result that will be retrieved when you click "Get Fun Fact" will display one general fun fact. This fun fact result was configured in the settings which I applied at the API's query customizer tool. The fun fact result will display one question and one answer since I set the number of questions, which the API returns, to one.

Upon doing so, the API's query tool generated the following URL, which I copied into the JS code to show the respective results:

The trivia API's query tool can also be configured to display just society & culture questions and answers, which can be displayed on this page when you click the "Get Fun Society & Culture Fact" button, below:

Upon doing so, the API's query tool generated the following URL, which I copied into the JS code to show the respective results:

The trivia API's query tool can also be configured to display just film & tv questions and answers, which can be displayed on this page when you click the "Get Fun Film & TV Fact" button, below:

Upon doing so, the API's query tool generated the following URL, which I copied into the JS code to show the respective results:

I could also have configured this trivia API's query tool to display just music questions, which can be displayed on this page when you click the "Get Fun Music Fact" button, below:

This time the API's query tool generated the following URL, which I copied into the JS code to show the respective results:

This trivia API's query tool has a variety of other categories to choose from, which random questions & answers can be generated for, including: