swiftimg

← Blog · · 5 min read

A free image hosting API: upload & embed images programmatically

If your app lets users add images — avatars, listings, attachments — you need somewhere to put them and a fast way to serve them back. You can stand up your own storage + resizing + CDN, or you can call an image hosting API and move on. Here's how to do the latter for free.

The whole flow in one request

Create an API key in your account, then POST a file. You get back the asset URLs and metadata immediately:

Upload
curl -X POST https://swiftimg.com/v1/images \
  -H "Authorization: Bearer $SWIFTIMG_KEY" \
  -F file=@photo.jpg -F title="Sunset"

# {
#   "id": "9fK2", "pageUrl": "https://swiftimg.com/i/9fK2",
#   "directUrl": "https://i.swiftimg.com/originals/9fK2.jpg", ...
# }

Prefer JavaScript? The zero-dependency client is a few lines:

JavaScript
import { createClient } from "@swiftimg/cli";
const swift = createClient({ apiKey: process.env.SWIFTIMG_KEY });
const { directUrl } = await swift.upload(file, { title: "Avatar" });

What "free" includes

Embedding what you get back

Serve the optimized variant and let the browser pick the size it needs:

HTML
<img src="https://i.swiftimg.com/variants/9fK2/display.webp" alt="Sunset" loading="lazy" />

When you outgrow the free tier, paid plans add on-the-fly transforms, signed URLs, and custom domains — see the API docs and pricing, or how it compares to Cloudinary and ImgBB.

Host your images globally

Free to start — no account needed. Upgrade for the API, transforms, and a custom domain.