npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qdb-api-plus

v1.4.6

Published

A better API wrapper for Quote Database

Downloads

34

Readme

qdb-api-plus

NPM

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
  • 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 up to 50 random quotes at a time
  • Get up to 50 of the latest quotes
  • Get up to 100 of the top quotes
  • Get specific quote by its id
  • Search for a quote

Examples of all of these methods can be found in src/examples.js

Quote object

The quote object is returned by every method in this library and works like this:

let quote = {
	text: "The text of the quote",
	id: "The ID of the quote",
	score: "The score of the quote"
};

qdb.random - get random quotes

  • [count = 1] - The amount of quotes to return (max 50)
  • [over0 = false] - Whether to return only quotes that have a score greater than zero or not (basically whether to scrape http://bash.org/?random or http://bash.org/?random1)

Returns a promise which resolves to a quote object if count is one, and an array of them otherwise

qdb.latest - get the latest quotes

  • [count = 1] - The amount of quotes to return (max 50)

Returns a promise which resolves to a quote object if count is one, and an array of them otherwise

qdb.top - get the top quotes

  • [count = 1] - The amount of quotes to return (max 50)

Returns a promise which resolves to a quote object if count is one, and an array of them otherwise

qdb.get - get a quote from it's ID

  • id - The ID of the quote

Returns a promise which resolves to a quote object

qdb.search - search for a quote

  • query - The search query
  • [count = 1] - The amount of quotes to return (max 100)
  • [byNumber = false] - Whether to sort by ID number or by votes

Returns a promise which resolves to a quote object if count is one, and an array of them otherwise

How it works

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

`http://bash.org/?${id}` //Get quote from specific ID
'http://bash.org/?latest' //Latest quote(s)
'http://bash.org/?random' //Random quote(s)
'http://bash.org/?top' //Top quote(s)
`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.