|
| 1 | +# Readwise |
| 2 | + |
| 3 | +List and upsert/delete highlights and documents from Readwise and Readwise Reader |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +First, install the plugin: |
| 8 | + |
| 9 | +```bash |
| 10 | +anyquery plugin install readwise |
| 11 | +``` |
| 12 | + |
| 13 | +Anyquery will ask you to create a Readwise API token. To create one, go to [https://readwise.io/access_token](https://readwise.io/access_token) and click on "Get Access Token". Copy the token and paste it in the plugin configuration. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +### Highlights |
| 18 | + |
| 19 | +The plugin lets you CRUD highlights from Readwise. |
| 20 | + |
| 21 | +```sql |
| 22 | +-- List all highlights |
| 23 | +SELECT * FROM readwise_highlights; |
| 24 | + |
| 25 | +-- Insert a new highlight |
| 26 | +INSERT INTO readwise_highlights (text, note, book_source, book_title) VALUES ('Lorem ipsum dolor sit amet.', 'My annotation note.', 'https://source.example.com/highlight/abc', 'My Book Title'); |
| 27 | + |
| 28 | +-- Update an existing highlight |
| 29 | +UPDATE readwise_highlights SET text = 'Updated text.' WHERE text = 'Lorem ipsum dolor sit amet.'; |
| 30 | + |
| 31 | +-- Delete an existing highlight |
| 32 | +DELETE FROM readwise_highlights WHERE text = 'Updated text.'; |
| 33 | +``` |
| 34 | + |
| 35 | +### Documents |
| 36 | + |
| 37 | +The plugin lets you CRUD documents from Readwise Reader. |
| 38 | + |
| 39 | +```sql |
| 40 | +-- List all documents |
| 41 | +SELECT * FROM readwise_documents; |
| 42 | + |
| 43 | +-- Insert a new document |
| 44 | +INSERT INTO readwise_documents (source_url, title, author, category) VALUES ('https://source.example.com/article/abc', 'My Article Title', 'John Doe', 'archive'); |
| 45 | + |
| 46 | +-- Update an existing document |
| 47 | +UPDATE readwise_documents SET title = 'Updated title.' WHERE title = 'My Article Title'; |
| 48 | + |
| 49 | +-- Delete an existing document |
| 50 | +DELETE FROM readwise_documents WHERE title = 'Updated title.'; |
| 51 | +``` |
| 52 | + |
| 53 | +## Schema |
| 54 | + |
| 55 | +### readwise_highlights |
| 56 | + |
| 57 | +| Column index | Column name | Type | |
| 58 | +| ------------ | -------------------- | -------- | |
| 59 | +| 0 | id | INTEGER | |
| 60 | +| 1 | text | TEXT | |
| 61 | +| 2 | note | TEXT | |
| 62 | +| 3 | location | INTEGER | |
| 63 | +| 4 | location_type | TEXT | |
| 64 | +| 5 | color | TEXT | |
| 65 | +| 6 | highlighted_at | DATETIME | |
| 66 | +| 7 | created_at | DATETIME | |
| 67 | +| 8 | updated_at | DATETIME | |
| 68 | +| 9 | url | TEXT | |
| 69 | +| 10 | is_favorite | BOOLEAN | |
| 70 | +| 11 | is_discard | BOOLEAN | |
| 71 | +| 12 | tags | TEXT | |
| 72 | +| 13 | book_id | INTEGER | |
| 73 | +| 14 | book_title | TEXT | |
| 74 | +| 15 | book_author | TEXT | |
| 75 | +| 16 | book_source | TEXT | |
| 76 | +| 17 | book_category | TEXT | |
| 77 | +| 18 | book_cover_image_url | TEXT | |
| 78 | +| 19 | book_summary | TEXT | |
| 79 | + |
| 80 | +### readwise_documents |
| 81 | + |
| 82 | +| Column index | Column name | Type | |
| 83 | +| ------------ | ---------------- | -------- | |
| 84 | +| 0 | id | TEXT | |
| 85 | +| 1 | url | TEXT | |
| 86 | +| 2 | source_url | TEXT | |
| 87 | +| 3 | title | TEXT | |
| 88 | +| 4 | author | TEXT | |
| 89 | +| 5 | source | TEXT | |
| 90 | +| 6 | category | TEXT | |
| 91 | +| 7 | location | TEXT | |
| 92 | +| 8 | tags | TEXT | |
| 93 | +| 9 | site_name | TEXT | |
| 94 | +| 10 | word_count | INTEGER | |
| 95 | +| 11 | created_at | DATETIME | |
| 96 | +| 12 | updated_at | DATETIME | |
| 97 | +| 13 | published_date | DATE | |
| 98 | +| 14 | notes | TEXT | |
| 99 | +| 15 | summary | TEXT | |
| 100 | +| 16 | image_url | TEXT | |
| 101 | +| 17 | parent_id | TEXT | |
| 102 | +| 18 | reading_progress | REAL | |
| 103 | +| 19 | first_opened_at | DATETIME | |
| 104 | +| 20 | last_opened_at | DATETIME | |
| 105 | +| 21 | saved_at | DATETIME | |
| 106 | +| 22 | last_moved_at | DATETIME | |
| 107 | + |
| 108 | +## Additional Information |
| 109 | + |
| 110 | +### Rate Limits |
| 111 | + |
| 112 | +The plugin is subject to the Readwise API Rate Limits. Essentially, you can: |
| 113 | + |
| 114 | +- read up to 24 000 highlights per minute |
| 115 | +- create up to 12 000 highlights per minute |
| 116 | +- update up to 240 highlights per minute |
| 117 | +- delete up to 240 highlights per minute |
| 118 | +- read up to 2000 documents per minute |
| 119 | +- create up to 50 documents per minute |
| 120 | +- update up to 50 documents per minute |
| 121 | +- delete up to 20 documents per minute |
| 122 | + |
| 123 | +### Cache |
| 124 | + |
| 125 | +The plugin uses a cache to store the highlights and documents. Documents and highlights are cached for 4 hours. Any insert/update/delete operation will invalidate the cache. |
0 commit comments