Integration

Publish to snapy with JavaScript

Turn content into a live link from Node, a script, or an AI agent in a few lines.

Publish to snapy with JavaScript

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

Share your file in seconds

Drop a file, get a link. Free, no signup.

Upload a file