Skip to content

Instantly share code, notes, and snippets.

@rwmyers
Last active September 9, 2025 19:34
Show Gist options
  • Select an option

  • Save rwmyers/896b49db4f29eed1fa739c146f8b0c09 to your computer and use it in GitHub Desktop.

Select an option

Save rwmyers/896b49db4f29eed1fa739c146f8b0c09 to your computer and use it in GitHub Desktop.
Raindrop / Obsidian Integration
// PUT YOUR TEST TOKEN IN QUOTES BELOW
// You can get one here by creating an app and copying the test token:
// https://app.raindrop.io/settings/integrations
// THIS GIVES YOU ACCESS TO YOUR ACCOUNT AND SHOULD NEVER BE SHARED
// WITH OTHERS
let authToken = "";
class raindrop {
static header = {
'Authorization': 'Bearer ' + authToken
};
static async collections() {
let url = "https://api.raindrop.io/rest/v1/collections";
const options = {
url: url,
headers: this.header
};
return request(options)
.then(result => {
let items = JSON.parse(result).items;
// Unsorted is a special non-collection that
// isn't returned, so add it.
items.push({
"_id": -1,
"title": "Unsorted"
})
return items;
});
}
static async raindrops(collectionId) {
// TODO: Not bothering with pagination at the moment
let url = "https://api.raindrop.io/rest/v1/raindrops/" + collectionId;
const options = {
url: url,
headers: this.header
};
return request(options)
.then(result => JSON.parse(result).items);
}
static async raindrop(id) {
let url = "https://api.raindrop.io/rest/v1/raindrop/" + id
console.log(url);
const options = {
url: url,
headers: this.header
};
return request(options).then(result => JSON.parse(result).item);
}
static async updateRaindrop(raindrop) {
let url = "https://api.raindrop.io/rest/v1/raindrop/" + raindrop._id
const options = {
url: url,
headers: {
'Authorization': 'Bearer ' + authToken,
"Content-Type": "application/json"
},
method: "PUT",
body: JSON.stringify(raindrop),
json: true
};
return request(options);
}
static splitText(text) {
return text.split(/\r?\n/);
}
};
module.exports = raindrop;
<%*
let raindrop = tp.user.raindrop;
let collections = await raindrop.collections();
let collection = await tp.system.suggester((item) => item.title, collections);
let raindrops = await raindrop.raindrops(collection._id);
let drop = await tp.system.suggester((item) => item.title, raindrops);
drop = await raindrop.raindrop(drop._id);
let title = drop.title
let url = drop.link
let raindropUrl = "https://app.raindrop.io/my/0/item/" + drop._id
tR += "---"
%>
tags: [document,raindrop,<% drop.tags.join(",") %>]
url: "<% url %>"
title: "<% title %>"
raindropUrl: "<% raindropUrl %>"
created: <% drop.created %>
---
# [<% title %>](<% url %>)
<%*
for (let i = 0; i < drop.highlights.length; i++) {
let highlight = drop.highlights[i];
let callout = "quote";
switch(highlight.color) {
case "red":
callout = "person"
break;
case "green":
callout = "reference"
break;
case "blue":
callout = "info"
break;
}
tR += "\n>[!" + callout + "]+";
let text = raindrop.splitText(highlight.text);
for (let i = 0; i < text.length; i++) {
tR += "\n>" + text[i];
}
tR += "\n ^" + i + "\n";
if (highlight.note == "") {
continue;
}
tR += "\n>[!note]+"
let note = raindrop.splitText(highlight.note);
for (let i = 0; i < note.length; i++) {
tR += "\n>" + note[i];
}
tR += "\n ^note"+1 + "\n";
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment