JSPM

@trigunino/node-isbn

1.8.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q30729F
  • License AGPL-3.0-only

Find books by ISBN - Modernized fork with updated dependencies

Package Exports

  • @trigunino/node-isbn
  • @trigunino/node-isbn/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@trigunino/node-isbn) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-isbn

A simple node.js module that resolves books by ISBN using multiple services:

Installation

$ npm install node-isbn

Supports Node.js versions 18.x and greater.

Note: This is a maintained fork that updates dependencies and modernizes the test setup while preserving the original API and AGPL-3.0 licensing.

Examples

Using a callback

var isbn = require('node-isbn');

isbn.resolve('0735619670', function (err, book) {
    if (err) {
        console.log('Book not found', err);
    } else {
        console.log('Book found %j', book);
    }
});

Using async/await (modern Node.js)

const isbn = require('node-isbn');

async function findBook(isbnCode) {
    try {
        const book = await isbn.resolve(isbnCode);
        console.log('Book found:', book.title);
        return book;
    } catch (error) {
        console.log('Book not found:', error.message);
        return null;
    }
}

// Usage
findBook('0735619670');

Setting a timeout

var isbn = require('node-isbn');

isbn.resolve('0735619670', { timeout: 15000 }, function (err, book) {
    if (err) {
        console.log('Book not found', err);
    } else {
        console.log('Book found %j', book);
    }
});

Using a promise

var isbn = require('node-isbn');

isbn.resolve('0735619670').then(function (book) {
    console.log('Book found %j', book);
}).catch(function (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.

{
    "title": "Code Complete",
    "authors": [
        "Steve McConnell"
    ],
    "publisher": "O'Reilly Media, Inc.",
    "publishedDate": "2004",
    "description": "Features the best practices in the art and...",
    "industryIdentifiers": [
        {
            "type": "OTHER",
            "identifier": "UCSC:32106018687688"
        }
    ],
    "readingModes": {
        "text": false,
        "image": false
    },
    "pageCount": 914,
    "printType": "BOOK",
    "categories": [
        "Computers"
    ],
    "averageRating": 4,
    "ratingsCount": 123,
    "contentVersion": "preview-1.0.0",
    "imageLinks": {
        "smallThumbnail": "http://books.google.com/books/content?id=QnghAQAAIAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api",
        "thumbnail": "http://books.google.com/books/content?id=QnghAQAAIAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api"
    },
    "language": "en",
    "previewLink": "http://books.google.es/books?id=QnghAQAAIAAJ&dq=isbn:0735619670&hl=&cd=1&source=gbs_api",
    "infoLink": "http://books.google.es/books?id=QnghAQAAIAAJ&dq=isbn:0735619670&hl=&source=gbs_api",
    "canonicalVolumeLink": "http://books.google.es/books/about/Code_Complete.html?hl=&id=QnghAQAAIAAJ"
}

Setting backend providers

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

// This request will search first in the Open Library API and then in the Google Books API
isbn.provider(['openlibrary', 'google'])
    .resolve('0735619670')
    .then(function (book) {
        console.log('Book found %j', book);
    }).catch(function (err) {
        console.log('Book not found', err);
    });
// This request will search ONLY in the Google Books API
isbn.provider(['google'])
    .resolve('0735619670')
    .then(function (book) {
        console.log('Book found %j', book);
    }).catch(function (err) {
        console.log('Book 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!

// This request will search ONLY in the Google Books API
isbn.provider([isbn.PROVIDER_NAMES.GOOGLE])
    .resolve('0735619670')
    .then(function (book) {
        console.log('Book found %j', book);
    }).catch(function (err) {
        console.log('Book not found', err);
    });

License

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

This project is a fork of the original work by Guido García (@palmerabollo). Changes include dependency upgrades (axios v1, mocha v11, nock v14) and minor compatibility fixes.

See also Google Books API Terms of Service, Open Library Licensing, WorldCat xISBN Terms of Service, ISBNdb Terms and Conditions.

Development

  • Ensure that you are using Node 18 or greater.
  • Tests use mocha and nock.
  • Run tests:
npm test