Docs🛠️ DeveloperQR Code Generator
POST/api/qrcode$0.001

🛠️ QR Code Generator

Generate high-quality QR codes from any text, URL, or data string. Returns both a base64 PNG data URL and a CDN URL for easy embedding. Customizable size and error correction levels.

Request Body

ParameterTypeRequiredDescriptionDefault
datastringrequiredContent to encode in the QR code (URL, text, etc.)

Response Fields

FieldTypeDescription
urlstringCDN URL of the QR code PNG
base64stringBase64 encoded PNG data URL
datastringOriginal data encoded

Code Examples

cURL
bash
curl -X POST https://sparkforge.sh/api/qrcode \
  -H "Content-Type: application/json" \
  -H "X-PAYMENT: <x402-payment-token>" \
  -d '{"data": "https://sparkforge.sh"}'
Python
python
import requests, base64

response = requests.post(
    "https://sparkforge.sh/api/qrcode",
    headers={"Content-Type": "application/json", "X-PAYMENT": "<token>"},
    json={"data": "https://sparkforge.sh"}
)

data = response.json()
# Save QR code to file
img_data = base64.b64decode(data["base64"].split(",")[1])
with open("qrcode.png", "wb") as f:
    f.write(img_data)
TypeScript / Node.js
typescript
const res = await fetch402("https://sparkforge.sh/api/qrcode", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ data: "https://sparkforge.sh" }),
});

const { url, base64 } = await res.json();
// Use base64 directly in <img src={base64} />

Example Response

json
{
  "url": "https://cdn.sparkforge.sh/qr/abc123.png",
  "base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
  "data": "https://sparkforge.sh"
}

💳 Payment via x402

This endpoint costs $0.001 per call, paid in USDC on Base, Polygon, or Solana. Use the @x402/fetch library to handle payments automatically, or implement the x402 handshake manually.

bash
# Free demo mode (no payment)
curl https://sparkforge.sh/api/qrcode?demo=true

# Or try via MCP (Claude Desktop, Cursor, Windsurf)
# Add to mcp config: { "url": "https://sparkforge.sh/api/mcp" }
Previous
URL Metadata
Next
JSON Validator