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

trivia-api

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trivia-api

A nodejs module for getting trivia questions in all your fancy projects, in a pretty simple way.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Trivia API

NPM Version NPM Downloads Dependencies Known Vulnerabilities license PayPal Say Thanks!

A Node.JS module for getting trivia questions in all your fancy projects, in a pretty simple way.

Classes

Trivia

Functions

getCategories()Promise.<Object>

Returs the available categories of the trivia questions.

getQuestions([options])Promise.<Object>

Returs a trivia question from the given options.

Trivia

Kind: global class

new Trivia([options])

ParamTypeOptionalDescription
[options]ObjectTrueThe options for Trivia API
[options.encoding]StringTrueThe encoding format of the result, either urlLegacy, url3986 and base64.

Example

const Trivia = require('trivia-api')
const trivia = new Trivia({ encoding: 'url3986' });

getCategories() ⇒ Promise.<Object>

Returs the available categories of the trivia questions.

Kind: global function
Returns: Promise.<Object> - Resolves available trivia categories and their IDs
Example

trivia.getCategories()
  .then(console.log)
  .catch(console.error);

getQuestions([options]) ⇒ Promise.<Object>

Returs a trivia question from the given options.

Kind: global function
Returns: Promise.<Object> - Resolves available trivia questions

ParamTypeOptionalDefaultDescription
[options]ObjectTrueThe options for retrieving the question
[options.amount]StringTrue1The amount of question(s) to be retrieved
[options.difficulty]StringTrueThe difficulty of question(s) to be retrieved, either easy, medium or hard
[options.category]NumberTrueThe category ID from which the question(s) should be retrieved
[options.type]StringTrueThe type of question(s) to be retrieved, either multiple or boolean

Example

let options = {
  type: 'boolean',
  amount: 10,
  difficulty: 'hard'
};
trivia.getQuestions(options)
  .then(questions => console.log(questions))
  .catch(console.error);

If you liked this project you can ⭐ Star it on GitHub and/or send a thank you note to me.

Keywords

FAQs

Package last updated on 16 Feb 2018

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