daily-trivia

1.0.8 • Public • Published

Daily Trivia Questions API

This is a simple Node.js module to retrieve daily trivia questions from the Open Trivia Database API. It utilizes the Axios library to make an HTTP GET request to the API and returns an array of 10 random questions.

Installation

To use this module, first install it using npm:

npm install daily-trivia

Usage

To use this module in your Node.js project, require it and call the getDailyQuestions function with the following parameters:

numQuestions (optional): the number of questions to retrieve. Default is 10. category (optional): the category of questions to retrieve.

Possible categories are: •General Knowledge •Entertainment: Books •Entertainment: Film •Entertainment: Music •Entertainment: Musicals & Theatres •Entertainment: Television •Entertainment: Video Games •Entertainment: Board Games •Science & Nature •Science: Computers •Science: Mathematics •Mythology •Sports •Geography •History •Politics •Art •Celebrities •Animals •Vehicles •Entertainment: Comics •Science: Gadgets •Entertainment: Japanese Anime & Manga •Entertainment: Cartoon & Animations •difficulty (optional): the difficulty of the questions to retrieve. Possible difficulties are: Easy, Medium, Hard.

const dailyTrivia = require('daily-trivia');

// Retrieve 10 random questions
dailyTrivia.getDailyQuestions()
  .then(questions => {
    console.log(questions);
  })
  .catch(error => {
    console.error(error);
  });

// Retrieve 5 random questions in the Geography category with easy difficulty
dailyTrivia.getDailyQuestions(5, 'Geography', 'easy')
  .then(questions => {
    console.log(questions);
  })
  .catch(error => {
    console.error(error);
  });


License

This project is licensed under the MIT License - see the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i daily-trivia

Weekly Downloads

0

Version

1.0.8

License

ISC

Unpacked Size

2.99 kB

Total Files

3

Last publish

Collaborators

  • broken_bones