• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
project logo

nucky

book-lookup-notion

use google book api to look up bibliographic metadata elements
Public
Like
1
book-lookup-notion
Home
Code
3
backend
4
README.md
C
cron-processor.ts
Branches
1
Pull requests
Remixes
1
History
Environment variables
2
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
5/23/2025
Viewing readonly version of main branch: v55
View latest version
README.md

Notion Book Database Auto-Populator

This Val automatically enriches a dedicated Book Metadata database by fetching comprehensive data from Google Books API, which can then be linked to your main reading database.

Two-Database System (Recommended)

This system uses two separate databases for clean organization:

  1. Your Books Database - For reading tracking (Rating, Progress, Start/Finish dates, etc.)
  2. Book Metadata Database - Automatically managed by this Val with rich book data

Features

  • Automatically fetches comprehensive book metadata:
    • Core Data: ISBN, Year Published, Page Count, Publisher
    • Rich Metadata: Subtitle, Description, Categories, Ratings
    • Links: Preview links, info links, cover images
    • Details: Language, exact publication date
  • Uses Google Books API (no API key required)
  • Smart matching algorithm for accurate results
  • Only processes unprocessed records (won't duplicate work)
  • Stores all metadata for future use

Setup Instructions

Step 1: Create Notion Integration

  1. Go to https://www.notion.so/my-integrations
  2. Click "New integration"
  3. Give it a name like "Book Metadata Fetcher"
  4. Select your workspace
  5. Copy the "Internal Integration Token"

Step 2: Create Book Metadata Database

Create a new database with these exact property names and types:

Required Properties:

  • Title (Title) - Book title
  • Author (Rich text) - Book author
  • Processed (Checkbox) - Tracking field (defaults to unchecked)

Metadata Properties (Auto-populated):

  • ISBN (Rich text) - ISBN number
  • Year Published (Number) - Publication year
  • Page Count (Number) - Number of pages
  • Publisher (Rich text) - Publisher name
  • Subtitle (Rich text) - Book subtitle
  • Description (Rich text) - Book description
  • Categories (Multi-select) - Book categories/genres
  • Average Rating (Number) - Google Books rating
  • Ratings Count (Number) - Number of ratings
  • Language (Rich text) - Book language
  • Published Date (Rich text) - Full publication date
  • Preview Link (URL) - Google Books preview
  • Info Link (URL) - Google Books info page
  • Image Links (Rich text) - Cover image URLs (JSON)

Step 3: Share Database with Integration

  1. Open your Book Metadata database
  2. Click "Share" → "Invite"
  3. Search for your integration name
  4. Give it "Edit" permissions

Step 4: Get Database ID

  1. Open your Book Metadata database
  2. Copy the URL: https://notion.so/workspace/DATABASE_ID?v=...
  3. Extract the DATABASE_ID (the long string between / and ?)

Step 5: Set Environment Variables

In Val Town, set:

  • NOTION_API_TOKEN: Your integration token
  • NOTION_DATABASE_ID: Your Book Metadata database ID

Step 6: Link to Your Reading Database (Optional)

To connect this to your main Books database:

  1. Add Relation Property to your main Books database:

    • Property name: "Metadata"
    • Type: Relation
    • Related database: Your Book Metadata database
  2. Add Rollup Properties to show metadata in your main database:

    • ISBN: Rollup → Metadata → ISBN
    • Year: Rollup → Metadata → Year Published
    • Pages: Rollup → Metadata → Page Count
    • Publisher: Rollup → Metadata → Publisher

Workflow

Option A: Manual Entry

  1. Add book to Book Metadata database → Enter Title + Author only
  2. Run this Val to fetch metadata
  3. Optionally link to your main Books database

Option B: Automated Linking

  1. Add book to your main Books database
  2. Create linked record in Book Metadata database
  3. Run this Val to populate metadata
  4. Metadata appears in main database via rollups

Option C: Notion Automation (Advanced)

Set up Notion automation:

  • Trigger: When Books database record is created
  • Action: Create linked record in Book Metadata database
  • Result: Val automatically processes new entries

API Endpoints

  • GET / - Process all unprocessed records
  • GET /status - Check system configuration
  • GET /process/:recordId - Process specific record
  • GET /health - Health check
  • GET /help - Usage instructions

Usage

Manual Processing

Visit the HTTP endpoint to process pending records:

https://your-val-url.web.val.run/

Automatic Processing

The cron job (/cron-processor.ts) can run on schedule:

  1. Set it to run daily/weekly in Val Town
  2. Emails you a summary of updates
  3. Only processes new/unprocessed records

Files

  • /backend/index.ts - Main HTTP handler and API endpoints
  • /backend/notion.ts - Notion API integration for Book Metadata database
  • /backend/books.ts - Google Books API integration with comprehensive metadata
  • /backend/processor.ts - Processing logic and orchestration
  • /cron-processor.ts - Scheduled processing with email reports

Benefits of Two-Database System

✅ Clean Separation: Reading data vs. metadata
✅ Rich Data: Store comprehensive book information
✅ Flexible: Add more metadata fields without cluttering main database
✅ Scalable: Process hundreds of books efficiently
✅ Reusable: Same metadata can link to multiple reading entries
✅ Future-Proof: All Google Books data available for new features

Troubleshooting

  • Check /status endpoint to verify configuration
  • Ensure database properties have exact names and types
  • Verify integration has access to Book Metadata database
  • Check Val Town logs for detailed error messages
  • Make sure "Processed" checkbox exists and defaults to unchecked
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.