Readme

https://readwise.io/api_deets

Not sure how to convert from a reader ID (string) to a readwise ID (number)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
export async function readwiseHighlights(token: string, ids?: number[]) {
let fullData = [];
let nextPageCursor = null;
while (true) {
const queryParams = new URLSearchParams();
if (ids) {
queryParams.append("ids", ids.join(","));
}
if (nextPageCursor) {
queryParams.append("pageCursor", nextPageCursor);
}
console.log("Making export api request with params " + queryParams.toString());
const response = await fetch("https://readwise.io/api/v2/export/?" + queryParams.toString(), {
method: "GET",
headers: {
Authorization: `Token ${token}`,
},
});
const responseJson = await response.json();
fullData.push(...responseJson["results"]);
nextPageCursor = responseJson["nextPageCursor"];
if (!nextPageCursor) {
break;
}
}
return fullData;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
June 20, 2024