Book Finder Script
This macro looks up a book by title and inserts its details into a new note in your vault. It uses the Google Books API, and you don’t need an API key because it only reads publicly available information.
Installation
Section titled “Installation”This works by adding the BookFinder user script to a Macro choice that you run from the main menu. You can find the script here.
- Save the script (
BookFinder.js) to your vault. Make sure it is saved as a JavaScript file, meaning that it has the.jsat the end. Important: Do not save scripts in the.obsidiandirectory - they will be ignored. Valid locations include folders like/scripts/,/macros/, or any custom folder in your vault. - Create a new template in your designated templates folder. Example template is provided below.
- Open the QuickAdd settings, click
Add Choice, and selectMacro. You decide what to name it. I named mineBook. This is what activates the macro. - Click the configure button (⚙️) on the macro choice to open the Macro Builder.
- Add the user script to the command list.
- Add a new Template step to the macro (the
Templatebutton in the command bar). This will be what creates the note in your vault. Settings are as follows:- Set the template path to the template you created.
- Enable File Name Format and use
{{VALUE:fileName}}as the file name format. You can specify this however you like. ThefileNamevalue is the name of the Book without illegal file name characters. - The remaining settings are for you to specify depending on your needs.
You can now use the macro to create notes with book information in your vault.
Example template
Section titled “Example template”
**Author**:: {{VALUE:authors}}**Title**:: {{VALUE:title}}**Category**::{{VALUE:categories}}**Status**:: 📥
**Related Books**### Core Questions for Me
### Actions
### My Notes
## Details{{VALUE:description}}You can pull any field from the API response into your template with a {{VALUE:<variable>}} placeholder (for example, {{VALUE:title}}). Below is an example response for the book ‘Flowers for Algernon’. The response is deeply nested, so if you want fields that the example template doesn’t already expose, you may need to extend the script to read them out.
{ "kind": "books#volumes", "totalItems": 119, "items": [ { "kind": "books#volume", "id": "6P_jN6zUuMcC", "etag": "FpDPG4koVaQ", "selfLink": "https://www.googleapis.com/books/v1/volumes/6P_jN6zUuMcC", "volumeInfo": { "title": "Flowers for Algernon", "authors": [ "Daniel Keyes" ], "publisher": "Houghton Mifflin Harcourt", "publishedDate": "2004", "description": "Oscar-winning film Charly starring Cliff Robertson and Claire Bloom-a mentally challenged man receives an operation that turns him into a genius...and introduces him to heartache.", "industryIdentifiers": [ { "type": "ISBN_13", "identifier": "9780156030083" }, { "type": "ISBN_10", "identifier": "015603008X" } ], "readingModes": { "text": false, "image": true }, "pageCount": 324, "printType": "BOOK", "categories": [ "Fiction" ], "averageRating": 4, "ratingsCount": 179, "maturityRating": "NOT_MATURE", "allowAnonLogging": true, "contentVersion": "1.3.3.0.preview.1", "panelizationSummary": { "containsEpubBubbles": false, "containsImageBubbles": false }, "imageLinks": { "smallThumbnail": "http://books.google.com/books/content?id=6P_jN6zUuMcC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api", "thumbnail": "http://books.google.com/books/content?id=6P_jN6zUuMcC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api" }, "language": "en", "previewLink": "http://books.google.ca/books?id=6P_jN6zUuMcC&printsec=frontcover&dq=intitle:Flowers+for+Algernon&hl=&cd=1&source=gbs_api", "infoLink": "http://books.google.ca/books?id=6P_jN6zUuMcC&dq=intitle:Flowers+for+Algernon&hl=&source=gbs_api", "canonicalVolumeLink": "https://books.google.com/books/about/Flowers_for_Algernon.html?hl=&id=6P_jN6zUuMcC" }, "saleInfo": { "country": "CA", "saleability": "NOT_FOR_SALE", "isEbook": false }, "accessInfo": { "country": "CA", "viewability": "PARTIAL", "embeddable": true, "publicDomain": false, "textToSpeechPermission": "ALLOWED", "epub": { "isAvailable": false }, "pdf": { "isAvailable": true, "acsTokenLink": "http://books.google.ca/books/download/Flowers_for_Algernon-sample-pdf.acsm?id=6P_jN6zUuMcC&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api" }, "webReaderLink": "http://play.google.com/books/reader?id=6P_jN6zUuMcC&hl=&source=gbs_api", "accessViewStatus": "SAMPLE", "quoteSharingAllowed": false }, "searchInfo": { "textSnippet": "WINNER OF THE HUGO AWARD AND THE NEBULA AWARD The classic novel that inspired the Academy Award-winning movie Charly Daniel Keyes, the author of eight books, was born in Brooklyn, New York, and received his B.A. and M.A. degrees from ..." } },