Using Napkin API with Drafts

I have recently started using Napkins app for a part of my notes. They have launched their API
Is there a way to use the API to send my drafts to Napkin? Sorry but I have no knowledge on coding and APIs, hence requesting for help here.

I don’t have access to Napkin, and that page you linked to seems to be the only available documentation regarding an API – so lots of caveats, but simply speaking the Drafts version of the curl post example in that link would look something like the below. You would need to modify to add your account email and token from Napkin - and maybe a way to provide a sourceUrl value if that is a required field.

const email = "my@email.com"
const token = "my-napkin-token"

// assume you want to post the whole current draft...
let thought = draft.processTemplate("[[draft]]")
// don't know if a URL is required? No docs?
let sourceUrl = ""

let http = HTTP.create(); // create HTTP object

var response = http.request({
    "url": "https://app.napkin.one/api/createThought",
    "method": "POST",
    "data": {
        "email": email,
        "token": token,
        "thought": thought,
        "sourceUrl": sourceUrl
    }
});

if (!response.success) {
    console.log(response.statusCode);
    console.log(response.error);
    context.fail()
}
3 Likes

Thank you so much! This is very helpful

[Steve Troughton-Smith](https://twitter.com/stroughtonsmith/status/1582415499694346240?s=12&t=zr76DNJQ7x6-PlhFXCMSRA):

> Not once in 12 years have I wanted macOS on an iPad, but even *I’m* starting to want macOS on iPad after all this 🫤 They wouldn’t have to do much at all to provide an IPSW of macOS for M-series iPads that advanced users might flash if they want it — a pressure valve for iPadOS

Is there a way to use the tweet url in the format above as sourceUrl? And the text after > as the thought in the script above?

Can confirm, I’ve just used this successfully as is.

(leaving sourceUrl as “” is fine for the way I want to send from Drafts to Napkin)

1 Like