Back to APIs list

Raindrop API examples & templates

Use these vals as a playground to view and fork Raindrop API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { bookmarksHtml } from "https://esm.town/v/ramkarthik/bookmarksHtml";
import process from "node:process";
import { raindropBookmarksSinceLastRun } from "https://esm.town/v/ramkarthik/raindropBookmarksSinceLastRun";
import { daysAgoFromToday } from "https://esm.town/v/ramkarthik/daysAgoFromToday";
export async function raindropBookmarksToEmail(interval: Interval) {
let lastRunAt = interval.lastRunAt?.toISOString() ||
daysAgoFromToday(7);
let bookmarks = await raindropBookmarksSinceLastRun(
lastRunAt,
process.env.raindrop,
);
if (bookmarks && bookmarks.length > 0) {
let emailHtml = bookmarksHtml(bookmarks);
console.email({
html: emailHtml,
subject: "[Raindrop] Your bookmarks since " + lastRunAt.split("T")[0],
});
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export const bookmarksHtml = (bookmarks: any[], header: string = "") => {
let emailHtml = "";
header = header || `<h3>Here are your bookmarks from Raindrop:</h3>`;
let footer =
`<p>Email from val.town. You can unsubscribe by clearing your interval here: https://val.town/@me.intervals</p>`;
emailHtml = header;
emailHtml += "<br /><ol>";
bookmarks.forEach((i, index) => {
emailHtml +=
`<li><a href='${i.link}'>${i.title}</a><p>${i.excerpt}</p></li>`;
});
emailHtml += "</ol>";
emailHtml += footer;
return emailHtml;
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export const raindropBookmarks = async (
page: Number,
raindropToken: String,
) => {
let options = {
"headers": { "Authorization": "Bearer " + raindropToken },
};
let data = await fetchJSON(
"https://api.raindrop.io/rest/v1/raindrops/0?perpage=20&page=" + page,
options,
);
return data;
};
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
29
30
31
import { raindropBookmarks } from "https://esm.town/v/ramkarthik/raindropBookmarks";
export const raindropBookmarksSinceLastRun = async (
lastRunAt: String,
raindropToken: String,
) => {
let bookmarks = [], reachedLastItem = false, page = 0;
while (!reachedLastItem) {
let data = await raindropBookmarks(
page,
raindropToken,
);
if (data.result && data.items.length > 0) {
data.items.every((item, index) => {
if (item.created >= lastRunAt) {
bookmarks.push(item);
return true;
}
else {
reachedLastItem = true;
return false;
}
});
}
else {
reachedLastItem = true;
}
page += 1;
}
return bookmarks;
};
1
Next