Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

daily-trivia

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daily-trivia

daily-trivia is used to get daily questions

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 07 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc