Skip to content
A nodejs module for getting trivia questions in all your fancy projects, in a pretty simple way.
Branch: master
Clone or download
Sankarsan Kampa
Sankarsan Kampa Updated dev deps
Latest commit 8b97390 Feb 16, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Initial Commit Sep 28, 2017
lib Updated examples Feb 16, 2018
.eslintrc Updated eslint configuration Sep 29, 2017
.gitattributes Initial Commit Sep 28, 2017
.gitignore Initial Commit Sep 28, 2017
LICENSE Initial Commit Sep 28, 2017
README.md Updated README Feb 16, 2018
index.js Initial release Sep 29, 2017
package.json Updated dev deps Feb 16, 2018

README.md

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])

Param Type Optional Description
[options] Object True The options for Trivia API
[options.encoding] String True The 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

Param Type Optional Default Description
[options] Object True The options for retrieving the question
[options.amount] String True 1 The amount of question(s) to be retrieved
[options.difficulty] String True The difficulty of question(s) to be retrieved, either easy, medium or hard
[options.category] Number True The category ID from which the question(s) should be retrieved
[options.type] String True The 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.

You can’t perform that action at this time.