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

@library-pals/isbn

v1.4.1

Published

Find books by ISBN

Downloads

46

Readme

@library-pals/isbn

An npm module that given an ISBN will return the book's metadata using the following providers:

Acknowledgements

This repository is a fork of node-isbn by Guido García <@palmerabollo>.

Installation

npm install @library-pals/isbn

Supports Node.js versions 20.x and greater.

Examples

import Isbn from "@library-pals/isbn";

try {
  const isbn = new Isbn();
  const book = await isbn.resolve("9780374104092");
  console.log("Book found %j", book);
} catch (err) {
  console.log("Book not found", err);
}

Setting a timeout

import Isbn from "@library-pals/isbn";

try {
  const isbn = new Isbn();
  const book = await isbn.resolve("9780374104092", { timeout: 15000 });
  console.log("Book found %j", book);
} catch (err) {
  console.log("Book not found", err);
}

Response

Response follows the same schema, but some fields could depend on the service that was used to find the book. In general, Google Books API returns more information.

Response: Google

{
  "title": "Annihilation",
  "authors": ["Jeff VanderMeer"],
  "description": "Area X has claimed the lives of members of eleven expeditions. The twelfth expedition consisting of four women hopes to map the terrain and collect specimens; to record all their observations, scientific and otherwise, of their surroundings and of one another; and, above all, to avoid being contaminated by Area X itself.",
  "pageCount": 209,
  "format": "book",
  "categories": [
    "Fiction",
    "Fiction / General",
    "Fiction / Fantasy / General",
    "Fiction / Horror",
    "Fiction / Literary",
    "Fiction / Science Fiction / General",
    "Fiction / Science Fiction / Action & Adventure",
    "Fiction / Thrillers / Suspense",
    "Fiction / Dystopian"
  ],
  "thumbnail": "http://books.google.com/books/publisher/content?id=2cl7AgAAQBAJ&printsec=frontcover&img=1&zoom=6&edge=curl&source=gbs_api",
  "link": "https://books.google.com/books/about/Annihilation.html?hl=&id=2cl7AgAAQBAJ",
  "publisher": "Macmillan",
  "publishedDate": "2014-02-04",
  "language": "en",
  "isbn": "9780374104092",
  "bookProvider": "Google Books"
}

Response: OpenLibrary

{
  "title": "Annihilation",
  "authors": ["Jeff VanderMeer"],
  "description": "Area X has been cut off from the rest of the continent for decades. Nature has reclaimed the last vestiges of human civilization. The twelfth expedition arrives expecting the unexpected, and Area X delivers. They discover a massive topographic anomaly and life-forms that surpass understanding. But it's the surprises that came across the border with them, and the secrets the expedition members are keeping from one another that change everything.",
  "pageCount": 208,
  "format": "book",
  "categories": [
    "Nebula Award Winner",
    "award:nebula_award=novel",
    "award:nebula_award=2015",
    "Discoveries in geography",
    "Fiction",
    "Scientists",
    "Science-Fiction",
    "Suspense fiction",
    "Paranormal fiction",
    "Women scientists",
    "Science fiction",
    "Fantasy fiction",
    "Mystery fiction",
    "Adventure fiction",
    "Exploration",
    "Amerikanisches Englisch",
    "Fiction, science fiction, action & adventure",
    "Fiction, suspense",
    "Action & Adventure",
    "Dystopian",
    "Fantasy",
    "Extrasensory perception",
    "Literary",
    "Suspense",
    "Thrillers",
    "General",
    "Pollution",
    "horror",
    "body horror",
    "alien invasion",
    "nyt:trade-fiction-paperback=2018-03-18",
    "New York Times bestseller",
    "Explorers",
    "Secrecy",
    "Scientific expeditions",
    "Psychic ability",
    "Fiction, thrillers, suspense",
    "Discoveries in geography--fiction",
    "Scientists--fiction",
    "Women scientists--fiction",
    "Ps3572.a4284 a84 2014",
    "813/.54"
  ],
  "thumbnail": "https://covers.openlibrary.org/b/id/10520611-L.jpg",
  "link": "https://openlibrary.org/books/OL31444108M",
  "publisher": "Farrar, Straus and Giroux",
  "publishedDate": "2014",
  "language": "en",
  "isbn": "9780374104092",
  "bookProvider": "Open Library"
}

Setting backend providers

You can optionally specify the providers that you want to use, in the order you need them to be invoked.

import Isbn from "@library-pals/isbn";

try {
  const isbn = new Isbn();
  // This request will search first in the Open Library API and then in the Google Books API
  isbn.provider(["openlibrary", "google"]);
  const book = await isbn.resolve("9780374104092");
  console.log("Book isbn:" + input + " found %j", book);
} catch (err) {
  console.log("Book isbn:" + input + " not found", err);
}
import Isbn from "@library-pals/isbn";

try {
  const isbn = new Isbn();
  // This request will search ONLY in the Google Books API
  isbn.provider( "google"]);
  const book = await isbn.resolve("9780374104092");
  console.log("Book isbn:" + input + " found %j", book);
} catch (err) {
  console.log("Book isbn:" + input + " not found", err);
}

If you do not like using strings to specify the providers, you could grab the providers from isbn.PROVIDER_NAMES constant that the library provides!

import Isbn from "@library-pals/isbn";

try {
  const isbn = new Isbn();
  // This request will search ONLY in the Google Books API
  isbn.provider([isbn.PROVIDER_NAMES.GOOGLE]);

  const book = await isbn.resolve("9780374104092");
  console.log("Book isbn:" + input + " found %j", book);
} catch (err) {
  console.log("Book isbn:" + input + " not found", err);
}

License

AGPL v3.0 LICENSE http://www.gnu.org/licenses/agpl-3.0.html

See also Google Books API Terms of Service, Open Library Licensing