How to use Google Book Api in your projects

Iris Mu
2 min readJun 13, 2023

--

First, you need to study the Google Book Api documentation. Here is the link. I only intergrated the api for public data in my project, so I used the API keys method. You need to create an API KEY in yout Google Cloud Credentials. In order to make requests to the Google Books API, you need to create an API key. Go to the Google Cloud Console (console.cloud.google.com) and navigate to the Credentials section. Create a new API key or use an existing one.

Second, you need to determine your project’s requirements. I want mine to search for a book either based on its author or its title. So my request only require a single parameter. According to Google,

You can perform a volumes search by sending an HTTP GET request to the following URI:

https://www.googleapis.com/books/v1/volumes?q=search+terms

q - Search for volumes that contain this text string. There are special keywords you can specify in the search terms to search in particular fields, such as:

intitle: Returns results where the text following this keyword is found in the title.

inauthor: Returns results where the text following this keyword is found in the author.

inpublisher: Returns results where the text following this keyword is found in the publisher.

subject: Returns results where the text following this keyword is listed in the category list of the volume.

isbn: Returns results where the text following this keyword is the ISBN number.

lccn: Returns results where the text following this keyword is the Library of Congress Control Number.

oclc: Returns results where the text following this keyword is the Online Computer Library Center number.

The way to use this is to create an url variable because to send the API request, Google requires the search url https://www.googleapis.com/books/v1/volumes?q=, the search key word, the search term and the API KEY, these four elements. Here is an example given by Google.

Here is an example of searching for Daniel Keyes’ “Flowers for Algernon”:

GET https://www.googleapis.com/books/v1/volumes?q=flowers+inauthor:keyes&key=yourAPIKey

The search url can be stored in a const variable called SEARCH_URL, then you can write something like const url = SEARCH_URL+ YOUR_SEARCH_KEY_WORD + ‘:’ + searchTerm(choose from the list above) + &key=YOUR_API_KEY. With the url, you can use asynchronous JavaScript techniques, such as async and await, to make the API request and fetch the data from the Google Books API.

--

--