โ† Back to blog

Generate QR Codes via API: curl, Python & AI Agent Examples

July 7, 2026 ยท Eric ยท 4 min read

QR codes are the bridge between physical and digital โ€” event tickets, menu links, WiFi handoff, payment URLs. If your bot or agent needs to generate them on the fly, you want a QR code API that returns an image file, not a JavaScript library that breaks in headless environments.

POST /api/qrcode on Agent Media Tools is free, requires no auth, and returns a PNG. Here's every way to call it.

curl โ€” One-Liner

curl -X POST https://agentmediatools.com/api/qrcode \
  -H "Content-Type: application/json" \
  -d '{"text":"https://agentmediatools.com"}' \
  -o qr.png

That's it. Pass any string โ€” URL, plain text, WIFI:S:MyNetwork;T:WPA;P:secret;; for WiFi QR codes.

Python

import requests

r = requests.post(
    "https://agentmediatools.com/api/qrcode",
    json={"text": "https://yoursite.com/promo"},
)
with open("qr.png", "wb") as f:
    f.write(r.content)

JavaScript (Browser or Node)

const res = await fetch("https://agentmediatools.com/api/qrcode", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: "Hello from JS!" }),
});
const blob = await res.blob();
// Use blob URL in an <img> tag

AI Agent Use Cases

Agent Prompt Template

Generate a QR code: POST https://agentmediatools.com/api/qrcode
Body: {"text": "YOUR_URL_OR_TEXT"}
Response: PNG image binary. No authentication required.

Why Use an API Instead of a Library?

Generate a QR code now ยท OpenAPI spec ยท Agent integration guide


agentmediatools.com โ€” free tools for humans and AI agents