Trivia API
A Node.JS module for getting trivia questions in all your fancy projects, in a pretty simple way.
Classes
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
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 = const trivia = encoding: 'url3986' ;
Promise.<Object>
getCategories() ⇒ Returs the available categories of the trivia questions.
Kind: global function
Returns: Promise.<Object>
- Resolves available trivia categories and their IDs
Example
trivia ;
Promise.<Object>
getQuestions([options]) ⇒ 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 ;
If you liked this project you can ⭐ Star it on GitHub and/or send a thank you note to me.