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
Naming the link
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
- Publishing the HTML a script generates and getting a link to share.
- Turning an AI agent's answer into a hosted page, then returning the link in chat.
- Posting a daily report from a cron job to a fresh link and emailing or Slacking it.
- Hosting an exported PDF, chart, or image by base64 encoding the file.
- Sharing a single-file demo or dashboard built with a templating library.
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
- No
urlin the response. Use thejson=argument (as above) so requests sets the JSON content-type for you. Sending a raw string without that header can stop the API from parsing the body. - Publishing a binary file. Do not pass bytes in
content. Base64 encode them and sendcontent_base64with a matchingfilename, as in the disk example above. namerejected. That subdomain is taken. Choose another name or omitnamefor a random one.- Large file fails. Files can be up to 100MB, and fair-use rate limits apply. Slow down a tight loop if requests start getting throttled.
Updating and managing a link
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
- Up to 100MB per file, with fair-use rate limits.
- This is the same endpoint AI agents use. See the developer docs, the JavaScript guide, or browse all integrations. For agent setups, the MCP guide wires it into Claude and other tools.
A few lines of Python turn any string or file into a link you can share.
