Giter Club home page Giter Club logo

node-trivia-api's Introduction

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.

node-trivia-api's People

Contributors

iamtraction avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.