K
Docs
πŸ“•

Find a Book

info.bookThe AlmanacLook-ups

Finds 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.

πŸ“•
Find a Book
info.book
Look-ups
queryrequired
e.g. {{input.options.book}}
asrequired
book
found
missing
error

Config fields

FieldTypeReqWhat it does
query
e.g. {{input.options.book}}
textyesWhich book πŸ”Ž
as
book
textyesSave 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 up

Output 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]}`);