The short version
snapy's publish endpoint takes a JSON POST and returns a link. Here it is with fetch.
const res = await fetch("https://api.snapy.host/api/publish", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
content: "<!doctype html><h1>Hello from JavaScript</h1>",
name: "my-page", // optional
filename: "index.html", // optional
}),
});
const data = await res.json();
console.log(data.url); // https://my-page.snapy.page
Publishing a binary file
Read the file, base64 encode it, and send it as content_base64:
import { readFileSync } from "node:fs";
const b64 = readFileSync("report.pdf").toString("base64");
const res = await fetch("https://api.snapy.host/api/publish", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ content_base64: b64, filename: "report.pdf" }),
});
console.log((await res.json()).url);
What you get back
The response includes url (the live link), stats_url (your private analytics page), and token.
Good to know
- Up to 100MB per file, with fair-use rate limits.
- Same endpoint AI agents use. See the developer docs or the Python guide.
