π
Find a Book
info.bookThe AlmanacLook-upsFinds a book by title (and author, if you add it) and brings back the author, first publication year, page count, reader rating, subjects, cover and a description when there is one.
When to use this
- βAdd the author for common titles: βit stephen kingβ
- βData from Open Library β {{book.url}} links to the book there
On the canvas
This is what Find a Book looks like when you place it on your flow. Each field below is something you configure in the inspector panel.
πLook-ups
Find a Book
info.bookqueryrequired
e.g. {{input.options.book}}
asrequired
book
found
missing
error
Config fields
| Field | Type | Req | What it does |
|---|---|---|---|
querye.g. {{input.options.book}} | text | yes | Which book π |
asbook | text | yes | Save it as β¨ |
Sparks this piece adds
After this piece runs, these values are available as sparks in every node downstream.
{{book.title}}stringThe book's title{{book.author}}stringAuthor(s){{book.year}}numberYear first published{{book.pages}}numberNumber of pages{{book.rating}}stringReader rating out of 5{{book.subjects}}stringA few subjects{{book.summary}}stringA description (empty when there isn't one){{book.image}}stringLink to the cover{{book.url}}stringLink to it on Open Library{{book.query}}stringWhat was looked up{{book.error}}stringWhy it couldn't be looked upOutput ports
foundThe book is in your spark β {{book.title}} by {{book.author}}
missingNothing matched β {{β¦query}} says what they asked for
errorCouldn't ask right now (busy or down) β {{β¦error}} says why
π
In TypeScript, this would beβ¦
Not something you need to write β just a look at what Kitcord does for you.
TypeScript
const res = await fetch(
`https://openlibrary.org/search.json?q=${encodeURIComponent(title)}&limit=1`,
);
const book = (await res.json()).docs[0];
if (!book) return; // Missing β
const cover = `https://covers.openlibrary.org/b/id/${book.cover_i}-L.jpg`; // {{book.image}}
await interaction.editReply(`π **${book.title}** by ${book.author_name[0]}`);Related pieces
More Look-ups pieces