A bookshelf

Photo by Aneta Pawlik

I have created a page on my website to list the books I have read. It is supposed to be like a bookshelf or library that we have in our homes. I love to browse through the books people have in their homes. I have always been fascinated by the books people read. The display of books plays a vital role in sparking thoughtful conversations. As books shape our thoughts and personality, it also helps to understand the person better.

Since we are in the digital age, I thought of creating a digital library for myself. The idea had struck me while I was living in Delhi. One of my friends had come to my home and he saw the books I had. We had a great conversation about various coding practices after he saw “The Pragmatic Programmer” book in my collection. A couple of days later, he texted and asked me to send me the Amazon link to buy the book. And that’s when I thought of creating the bookshelf. I also had worked on a similar project during my college days with my friends.

So, I created a page on my website to list the books I have read. Since I needed the book cover images, I explored a few options to do that. And they were:

  1. Good reads API
  2. Google books API
  3. Amazon associates links

I tried the first two options but went with the third one. There were a couple of reasons for that. First, as expected, the APIs worked with an API key. I didn’t want to deal with that in a static website. Second, the good read API didn’t offer a convenient way to get the cover. While Google Books API did, Google Books didn’t have an easily accessible way to buy them. It does offer a link to search the book on various platforms, but they didn’t return reliable results. For example, some search results only had Kindle editions while the paperback edition was available on Amazon. The Amazon associates links didn’t look any promising at first glance either. There was no API, but they offered a way to create a link to the book with a cover image. They have to tool to create embeddable snippets of code that could be used to display the book cover. All my requirements seemed to be met with this option.

So, I went ahead with Amazon associates links. However, recently, I noticed that the images were not being rendered. I checked and found that the image links were not working anymore. I thought maybe Amazon had made some changes to the links. Probably, they have changed the domain, path, or something. So, I went to the Amazon associates page and tried to create a new link. But, the tool didn’t offer any option to create a link with an image. The only option was to create a text link.

Broken bookshelf

Broken image thumbnails on Bookshelf

I searched on the internet and found that Amazon has disabled the images for the associate links. I couldn’t find the official announcement, but there were a few articles on the internet that mentioned this change. Amazon probably had sent an email to the associates about this change. Some opportunists have also created a tool to convert the old links to the new ones. For example, this one

However, I had no limitation on using Amazon associates links. So, I revisited the various options I had. I tried the Google Books API again, but it still did not offer a way to buy the book. So, I went the old way. I retained the links from Amazon associates and used the Google Books API to get the book cover.

Links in markdown

Separate links for images and books in Markdown

As mentioned earlier, I didn’t want to deal with the API key in a static website. So, I wrote a small script to get the book cover from Google Books API. At first, I thought of just getting the image links and updating the markdown files. But, then I thought what if those links break as well in the future? So, I decided to download the images and store them in the repository. I also wrote a small script to update the markdown files with the image links.

Fixed Bookshelf

Fixed Bookshelf

Feel free to comment, get in touch if you have any interesting ideas involving books or like to have a conversation about the book that you love.

Rohan Jaswal

Software Engineer at Udemy. Playing around with Python, Java and stuff!


Intuit Mailchimp