Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iamtraction/node-trivia-api
❔ A nodejs module for getting trivia questions in all your fancy projects, in a pretty simple way.
https://github.com/iamtraction/node-trivia-api
api-wrapper nodejs npm npm-module npm-package trivia trivia-api
Last synced: 27 days ago
JSON representation
❔ A nodejs module for getting trivia questions in all your fancy projects, in a pretty simple way.
- Host: GitHub
- URL: https://github.com/iamtraction/node-trivia-api
- Owner: iamtraction
- License: mit
- Created: 2017-09-28T07:27:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-20T00:45:31.000Z (over 2 years ago)
- Last Synced: 2024-10-03T18:54:28.238Z (about 1 month ago)
- Topics: api-wrapper, nodejs, npm, npm-module, npm-package, trivia, trivia-api
- Language: JavaScript
- Homepage: https://npmjs.com/package/trivia-api
- Size: 18.6 KB
- Stars: 7
- Watchers: 0
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Trivia API
[![NPM Version](https://img.shields.io/npm/v/trivia-api.svg?style=flat)](https://www.npmjs.com/package/trivia-api)
[![NPM Downloads](https://img.shields.io/npm/dt/trivia-api.svg?style=flat)](https://www.npmjs.com/package/trivia-api)
[![Dependencies](https://david-dm.org/k3rn31p4nic/node-trivia-api.svg)](https://david-dm.org/k3rn31p4nic/node-trivia-api)
[![Known Vulnerabilities](https://snyk.io/test/github/k3rn31p4nic/node-trivia-api/badge.svg)](https://snyk.io/test/github/k3rn31p4nic/node-trivia-api)
[![license](https://img.shields.io/github/license/k3rn31p4nic/node-trivia-api.svg)](LICENSE)
[![PayPal](https://img.shields.io/badge/donate-PayPal-003086.svg)](https://paypal.me/snkrsnkampa)
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/k3rn31p4nic)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
**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**
```js
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**
```js
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**
```js
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](https://github.com/k3rn31p4nic/node-trivia-api) and/or
> [send a thank you note to me](https://saythanks.io/to/k3rn31p4nic).