swiftimg

← Blog · · 4 min read

Upload images from your terminal, scripts & ShareX

The fastest way to share a screenshot or image is to never leave your keyboard. swiftimg's API makes that a one‑liner — here are three ways to wire it up, from a proper CLI to a single shell function to a ShareX custom uploader. Grab an API key from your account first.

1. The CLI (recommended)

@swiftimg/cli is a zero‑dependency command‑line tool (and JavaScript client). Install it, log in once, and upload anything:

Install & upload
npm install -g @swiftimg/cli

swiftimg login sk_live_xxx          # create a key at /account
swiftimg upload screenshot.png      # prints the direct link
swiftimg upload cat.gif --title "my cat" --tags funny,cat

It prints the direct link by default (pass --page for the share page, --json for everything). A handy macOS alias to upload your latest screenshot and copy the link:

~/.zshrc
shot() { swiftimg upload "$(ls -t ~/Desktop/Screenshot* | head -1)" | pbcopy; }

2. A one-line curl helper

No install needed — the API is just a multipart POST. Drop this in your shell profile:

Shell
export SWIFTIMG_KEY="sk_live_xxx"
simg() {
  curl -s -X POST https://swiftimg.com/v1/images \
    -H "Authorization: Bearer $SWIFTIMG_KEY" \
    -F file=@"$1" \
  | python3 -c 'import sys,json;print(json.load(sys.stdin)["directUrl"])'
}
# usage: simg shot.png

3. ShareX (Windows screenshots)

ShareX can upload straight to swiftimg after each capture. The developers page has a generator: paste your API key and download a ready‑made .sxcu custom‑uploader config (your key is written into the file in your browser — it never touches our servers). Open the file to add swiftimg to ShareX, set it as the active image uploader, and every screenshot becomes a swiftimg link.

Programmatic use

The same client works in any Node or browser app:

JavaScript
import { createClient } from "@swiftimg/cli";
import { readFile } from "node:fs/promises";

const swift = createClient({ apiKey: process.env.SWIFTIMG_KEY });
const data = await readFile("photo.jpg");
const { directUrl } = await swift.upload({ data, filename: "photo.jpg" });
console.log(directUrl);

Every upload is served fast worldwide with automatic WebP variants — see the full API.

Host your images globally

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