• 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: v47
View latest version
README.md

Notion Book Database Auto-Populator

This Val automatically enriches your Notion book database by fetching comprehensive metadata from Google Books API.

Features

  • Monitors Notion database for new entries with title and author
  • Automatically fetches and populates:
    • ISBN (ISBN-13 preferred, ISBN-10 as fallback)
    • Year Published
    • Page Count
    • Publisher
  • Retrieves comprehensive metadata including:
    • Subtitle, description, categories
    • Average rating and ratings count
    • Language, publication date
    • Preview and info links
    • Cover image links
  • Uses Google Books API (no API key required)
  • Handles multiple book matches intelligently
  • Smart matching algorithm for best results
  • Only updates empty fields (won't overwrite existing data)

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 Auto-Populator"
  4. Select your workspace
  5. Copy the "Internal Integration Token"

Step 2: Configure Your Database

Your Notion database should have these properties:

  • Title (Title type) - Required
  • Author (Rich text) - Required
  • Published (Number) - Will be populated with publication year
  • Pg (Number) - Will be populated with page count
  • Publisher (Rich text) - Will be populated

Optional properties (won't be modified):

  • Rating, Progress, Start, Finish, Form, Medium, POV, etc.

Step 3: Share Database with Integration

  1. Open your book database in Notion
  2. Click the "Share" button (top right)
  3. Click "Invite" and search for your integration name
  4. Give it "Edit" permissions

Step 4: Get Database ID

  1. Open your database in Notion
  2. Copy the URL - it looks like: https://notion.so/workspace/DATABASE_ID?v=...
  3. The DATABASE_ID is the long string of letters/numbers between the last / and ?

Step 5: Set Environment Variables

In Val Town, set these environment variables:

  • NOTION_API_TOKEN: Your integration token from Step 1
  • NOTION_DATABASE_ID: Your database ID from Step 4

Usage

Manual Processing

Visit the HTTP endpoint to manually trigger processing:

  • Main endpoint: Process all incomplete records
  • /status: Check configuration
  • /help: View all available endpoints

Automatic Processing (Recommended)

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

  1. Set it to run daily or weekly in Val Town
  2. It will email you a summary of updates
  3. Only processes records missing metadata

API Endpoints

  • GET / - Process all incomplete records
  • GET /status - Check system configuration and status
  • GET /process/:recordId - Process a specific record by ID
  • GET /health - Health check
  • GET /help - Usage instructions and setup guide

How It Works

  1. Detection: Finds records with Title and Author but missing ISBN, Year, Pages, or Publisher
  2. Search: Queries Google Books API with title and author
  3. Matching: Uses smart algorithm to find best match
  4. Update: Only populates empty fields in Notion
  5. Reporting: Logs results and sends email summaries (cron mode)

Files

  • /backend/index.ts - Main HTTP handler and API endpoints
  • /backend/notion.ts - Notion API integration and database operations
  • /backend/books.ts - Google Books API integration and search logic
  • /backend/processor.ts - Main processing logic and orchestration
  • /cron-processor.ts - Scheduled automatic processing with email reports

Troubleshooting

  • Check /status endpoint to verify configuration
  • Ensure database properties have exact names and types
  • Verify integration has access to your database
  • Check Val Town logs for detailed error messages
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.