FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
thesolarmonk
thesolarmonkreadwise-ingester
Public
Like
readwise-ingester
Home
Code
3
README.md
S
readwise-bot.ts
H
readwise-http.ts
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
README.md

Readwise Shortlist Sync Bot

This project syncs your Readwise shortlist articles to a SQLite database for easy access and management.

Files

  • readwise-bot.ts - Standalone function version (can be used as cron)
  • readwise-http.ts - HTTP endpoint version with web dashboard ⭐ Recommended
  • README.md - This documentation

Setup

  1. Get your Readwise API token:

    • Go to https://readwise.io/access_token
    • Copy your access token
  2. Set environment variable:

    • In Val Town, add an environment variable named READWISE_TOKEN
    • Set its value to your Readwise access token

Usage

HTTP Version (Recommended)

The readwise-http.ts file provides a web interface and API endpoints:

  • Dashboard: Visit the root URL to see a simple web interface
  • Sync API: POST /sync - Triggers a sync of your shortlist
  • Links API: GET /links?limit=50 - Retrieves saved links from database

Standalone Version

The readwise-bot.ts can be:

  • Run manually by calling the function
  • Set up as a cron job for automatic syncing

Database Schema

The bot creates a readwise_links table with the following fields:

  • id - Unique document ID from Readwise
  • url - Article URL
  • title - Article title
  • author - Article author
  • source - Source publication
  • category - Document category (article, email, etc.)
  • location - Current location (shortlist, archive, etc.)
  • tags - JSON string of tags
  • site_name - Website name
  • word_count - Article word count
  • created_at - When document was created in Readwise
  • updated_at - When document was last updated in Readwise
  • published_date - Original publication date
  • summary - Article summary
  • image_url - Featured image URL
  • reading_progress - Reading progress percentage
  • first_opened_at - When first opened
  • last_opened_at - When last opened
  • saved_at - When saved to Readwise
  • last_moved_at - When last moved between locations
  • synced_at - When synced to our database

Features

  • ✅ Incremental sync: Only updates documents that have changed
  • ✅ Pagination handling: Automatically handles large shortlists
  • ✅ Error handling: Robust error handling and logging
  • ✅ Duplicate prevention: Prevents duplicate entries
  • ✅ Web dashboard: Simple interface to trigger syncs and view links
  • ✅ SQLite compatibility: Properly handles Val Town's SQLite format

API Examples

Sync shortlist

curl -X POST https://your-val-url/sync

Get saved links

curl https://your-val-url/links?limit=20

Scheduling

To run automatically, you can:

  1. Use the standalone readwise-bot.ts version and set it as a cron job
  2. Set up an external service to call the /sync endpoint periodically
  3. Manually trigger syncs through the web dashboard

Environment Variables Required

  • READWISE_TOKEN - Your Readwise API access token

Recent Updates

  • ✅ Fixed SQLite result format handling
  • ✅ Improved error handling for individual document failures
  • ✅ Added proper incremental sync logic
  • ✅ Web dashboard now displays saved articles correctly
Code
README.md
S
readwise-bot.ts
H
readwise-http.ts
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.