1.0.2 • Published 3 years ago
google-books-js v1.0.2
Google Books JS
This is a simple Javascript wrapper for the Google Books API.
The goal of this library is to make easy retrieving information from their API.
You can use it on a NodeJS project or a Web project.
Installation
$ npm install google-books-jsUsage
Searching for books
import { GoogleBooksAPI } from "google-books-js";
const googleBooksApi = new GoogleBooksAPI();
async function fetchBooks(): Promise<void> {
const books = await googleBooksApi.search({
filters: {
title: "Bartleby",
},
});
console.log(books);
}
fetchBooks();Getting a book by its ID
import { GoogleBooksAPI } from "google-books-js";
const googleBooksApi = new GoogleBooksAPI();
async function fetchBook(): Promise<void> {
const book = await googleBooksApi.getVolume("bookId");
console.log(book);
}
fetchBook();Methods
search()parameters:
filters:title: stringauthor: stringsubject: stringisbn: string
returns
SearchResult:kind: stringtotalItems: numberitems: Volume[]
example:
const books = await googleBooksApi.search({ filters: { title: "The old and the sea", author: "Ernest Heminghway", }, });
getVolume()parameters:
volumeId: string
returns
Volumeexample:
const book = await api.getVolume("SDepCQAAQBAJ");
Types
SearchResult:kind: stringtotalItems: numberitems: Volume[]
Volumeid: stringetag: stringkind: stringselfLink: stringvolumeInfo:title: stringsubtitle: stringdescription: stringauthors: string[]publisher: stringpublishedDate: stringindustryIdentifiers:type: stringidentifier: string
pageCount: numberprintType: stringcategories: string[]maturityRating: stringimageLinks:smallThumbnail: stringthumbnail: string
previewLink: stringinfoLink: stringcanonicalVolumeLink: string
Roadmap
- Implemented the API Key support
- Implement the pagination on search
- Improve typings