The image proxy
GET /api/img/{handle}/{name} is a permanent public URL for a named image, with no key in it.
<img src="https://pixloom.dev/api/img/acme/hero" alt="Hero image" />This is the URL to put on a public page. There is no key in it: your account handle identifies you, and the permalink name identifies the image. Give it to a CMS, an email template, a designer, anyone.
You create the name in the dashboard under Permalinks, where you also set its prompt, size, style and how often it refreshes.
The URL
https://pixloom.dev/api/img/{handle}/{name}
https://pixloom.dev/api/img/{handle}/{name}/{style}
https://pixloom.dev/api/img/{handle}/{name}/{style}?age=kids| Part | Notes |
|---|---|
handle | Your account handle. Set it in Settings. |
name | The permalink name. |
style | Optional. A style slug. Ignored if the permalink is style locked, and an unknown slug falls back to its default. |
?age= | Optional. Comma-separated kids, bigkids, adults. Overrides the permalink's audience. |
The same name with different styles gives you a set of matched images: one prompt, many looks, each cached on its own.
Keeping it to your own site
Add domains to the key behind your handle and we check the browser's Referer on every load. A request from anywhere else gets a 403 and no image. Leave the domain list empty and the URL works anywhere, which is what you want for email.
Localhost always passes, so this works in development without any setup.
The rule it follows
Never make a visitor wait when any image exists.
- If you pinned images for this permalink, one of those is served, rotating on the refresh window. Nothing is generated.
- If images exist for the style asked for, one is served, and if the refresh window has passed a fresh one is generated in the background for next time.
- If a specific style was asked for and nothing matches it, the image is generated on the spot rather than serving the wrong look. If that fails and anything else exists, you get that instead and a retry is queued.
- If nothing exists at all, the image is generated on the spot. This is the only request anyone ever waits on, and it happens once per permalink and style.
Background regeneration is locked to one at a time per permalink and style, so a busy page cannot start a hundred generations at once. A permalink set to never refresh serves what it has and does not burn generations.
Responses
| Status | Body |
|---|---|
302 | Redirect to the image. |
403 | The page's domain is not on your key. |
404 | { "error": "Account not found" } for an unknown handle, { "error": "Shortcut not found" } for an unknown name. |
Compared to render
Render takes a prompt in the URL and needs a secret key. The proxy takes a name and needs no key. Use render for private, one-off, machine-generated URLs. Use the proxy for anything a visitor's browser will request.