Integration

Publish to Snapy with Python

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

Publish to Snapy with Python

The short version

Snapy's publish endpoint takes a JSON POST and returns a link. Here is all it takes in Python with the standard requests library.

import requests

r = requests.post("https://api.snapy.host/api/publish", json={
    "content": "<!doctype html><h1>Hello from Python</h1>",
    "name": "my-page",          # optional
    "filename": "index.html",   # optional
})
data = r.json()
print(data["url"])              # https://my-page.snapy.page

Publishing a file from disk

import requests, base64

raw = open("report.pdf", "rb").read()
r = requests.post("https://api.snapy.host/api/publish", json={
    "content_base64": base64.b64encode(raw).decode(),
    "filename": "report.pdf",
})
print(r.json()["url"])

What you get back

The response includes url (the live link), stats_url (your private analytics page), and token. Open the link right away.

data = r.json()
print(data["url"])        # the public link
print(data["stats_url"])  # your private analytics page
print(data["token"])      # keep this to manage the link later

Pass a name to choose the subdomain. A free name gives you name.snapy.page. If the name is already taken the request fails, so pick another name or leave name out to get a random address. Add a filename such as index.html or report.pdf so Snapy treats the content as that file type.

A small helper

Wrapping the call keeps scripts clean and gives you one place to handle errors:

import requests

def publish(content, name=None):
    r = requests.post("https://api.snapy.host/api/publish", json={
        "content": content,
        "name": name,
        "filename": "index.html",
    })
    r.raise_for_status()
    return r.json()["url"]

print(publish("<!doctype html><h1>Hi</h1>", name="demo"))

Common uses

Snapy serves static files. Self-contained HTML, CSS, and client-side JavaScript work well. Anything that needs a live server, a database, or server-side login is out of scope, so publish finished static output rather than an app expecting a backend.

Troubleshooting

The token in the response is your handle for a link after it is live. Store it alongside the url if your script needs to manage the page later. Treat it like a secret, since anyone with the token can manage that link. A simple approach is to keep a small record per publish:

data = r.json()
record = {"url": data["url"], "stats_url": data["stats_url"], "token": data["token"]}
# save record to a file or database for later reference

If you publish on a schedule and want a stable address, pass the same name each run. Snapy keeps the address predictable, and you always know where the latest version lives.

Working inside an agent or web app

The publish call is plain HTTP, so it drops into almost any Python context: a FastAPI or Flask route, a Celery task, a Jupyter cell, or an LLM tool function. A common agent pattern is to let the model generate HTML, publish it, and return the url so the user gets a real link instead of a wall of code. Because there is no key to manage, the function stays a single request with no setup.

Good to know

A few lines of Python turn any string or file into a link you can share.

Share your file in seconds

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

Upload a file
Go Pro · $50/year, save ~$10 vs monthly · launch price for the first 100 members.