Skip to content

Commit 20d17b2

Browse files
committed
✨ Add Readwise plugin
1 parent a3435da commit 20d17b2

File tree

12 files changed

+1659
-0
lines changed

12 files changed

+1659
-0
lines changed

plugins/readwise/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
# Go template downloaded with gut
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
*.test
9+
*.out
10+
go.work
11+
.gut
12+
13+
# Dev files
14+
*.log
15+
devManifest.*
16+
.init
17+
18+
dist/

plugins/readwise/.goreleaser.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
version: 2
3+
4+
before:
5+
hooks:
6+
# You may remove this if you don't use go modules.
7+
- go mod tidy
8+
9+
builds:
10+
- env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- windows
15+
- darwin
16+
binary: readwise
17+
id: anyquery
18+
ldflags: "-s -w"
19+
flags: # To ensure reproducible builds
20+
- -trimpath
21+
22+
goarch:
23+
- amd64
24+
- arm64
25+
26+
archives:
27+
- format: binary
28+
29+
changelog:
30+
sort: asc
31+
filters:
32+
exclude:
33+
- "^docs:"
34+
- "^test:"

plugins/readwise/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
files := $(wildcard *.go)
3+
4+
all: $(files)
5+
go build -o readwise.out $(files)
6+
7+
prod: $(files)
8+
go build -o readwise.out -ldflags "-s -w" $(files)
9+
10+
release: prod
11+
goreleaser build -f .goreleaser.yaml --clean --snapshot
12+
13+
clean:
14+
rm -f readwise.out
15+
16+
.PHONY: all clean

plugins/readwise/README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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

Comments
 (0)