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

qdb-api-plus

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qdb-api-plus

A better API wrapper for Quote Database

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

qdb-api-plus

A better API wrapper for Quote Database. Fork of qdb-api.

Looking for a REST API? See qdb-rest-api

npm install qdb-api-plus

const qdb = require('qdb-api-plus')

qdb-api vs qdb-api-plus

  • qdb-api-plus doesn't use axios
  • qdb-api-plus has slightly better documentation
  • qdb-api-plus has a couple more methods like latestID and randomID
  • You can search for any number of results under 101 with qdb-api-plus, instead of being constrained to 10, 25, 50, 75, or 100
  • You can get any amount of latest/random quotes under 51 with qdb-api-plus, instead of just getting one

Methods available

  • Get a random quote or a random ID
  • Get the latest quote or it's ID
  • Get specific quote by it's id
  • Search for a quote

Get a random quote

Parameters

  • count (optional) - How many quotes to get

Returns a quote if count is 1, and an array of quotes otherwise

Example:

qdb.random()
	.then(quote => {
		console.log(quote.id);
		console.log(quote.score);
		console.log(quote.text);
	})
	.catch(reason => {
		console.log(reason);
	});

Get a random quote ID

Example:

qdb.randomID()
	.then(id => {
		console.log(id);
	})
	.catch(reason => {
		console.log(reason);
	});

Get the latest quote

Parameters

  • count (optional) - How many quotes to get

Returns a quote if count is 1, and an array of quotes otherwise

Example:

qdb.latest()
	.then(quote => {
		console.log(quote.id);
		console.log(quote.score);
		console.log(quote.text);
	})
	.catch(reason => {
		console.log(reason);
	});

Get the latest quote ID

Example:

qdb.latestID()
	.then(id => {
		console.log(id);
	})
	.catch(reason => {
		console.log(reason);
	});

Get a specific quote by its ID

Parameters

  • ID number

Example:

qdb.get(4680)
	.then(quote => {
		console.log(quote.id);
		console.log(quote.score);
		console.log(quote.text);
	})
	.catch(reason => {
		console.log(reason);
	});

Search for a quote

Parameters

  • Search string
  • Sort by - 0 for score, 1 for number
  • Number of results - Any number under 101

Returns a quote if Number of results is 1, and an array of quotes otherwise

Example:

qdb.search('tom', 0, 10)
	.then(quotes => {
		quotes.forEach(quote => {
			console.log(quote.id);
			console.log(quote.score);
			console.log(quote.text);
		});
	})
	.catch(reason => {
		console.log(reason);
	});

How it works

First, the program gets a specific bash.org website:

`http://bash.org/?${id}` //Get specific ID
'http://bash.org/?latest' //Latest quote/ID
'http://bash.org/?random' //Random quote/ID
`http://bash.org/?search=${query}&sort=${sort}&show=${count}` //Search

Then, it uses cheerio to scrape the page for the quote text, the votes, and the ID.

Disclaimer

Please note that is an unofficial API.

Keywords

FAQs

Package last updated on 07 Mar 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