What Is a QR Code API — and Do You Need One?

Short answer: a QR code API is a web address that takes some text (usually a URL) and returns a QR code image. You do not have to rent one. Install a free open-source library (qrcode for Node, segno for Python, chillerlan/php-qrcode for PHP), wrap it in one route on your own server, and you have a private QR code API with no key, quota or bill.

Search for “QR code API” and you will find hosted services that turn an HTTP request into a QR image, usually with API keys, monthly quotas and paid tiers. For most developers there is a simpler answer: generating a QR code is a small, deterministic computation that any language can do locally with a free open-source library. The same input always gives the same image, there is no secret sauce, and nothing needs to leave your server — or even the user’s browser.

To be clear up front: GenerateOnlineQR.com does not offer a public API. This guide shows how to get everything a QR API gives you — codes on demand, PNG or SVG, chosen error correction — in your own code, and how to wrap it in your own tiny HTTP endpoint if other services need one.

QR code generator API flow: an application sends data to a REST API and receives a QR code image for documents and emails
The “API” pattern — send data, get an image back — is easy to run yourself with an open-source library.
ApproachWhere the code is madeGood forWatch out for
Library in the browserUser’s deviceWeb apps, previews, private data (Wi-Fi passwords, contacts)Needs JavaScript; set UTF-8 encoding
Library on your serverYour backendEmails, PDFs, tickets, invoices, batch jobsNothing beyond normal input validation
Your own HTTP endpointYour backend, exposed via URLSeveral apps or teams sharing one service; <img src> embeddingAuth, rate limits, size caps
Native OS APIsiOS / macOS / Android appApps; works offlineScale the image without smoothing
Third-party hosted APISomeone else’s serverOnly if you need their extra featuresYour data leaves your system; quotas; the service can change or shut down
Rule of thumb

If you are sending your data to a remote server only to get a QR image back, you are adding latency, a dependency and a privacy question to a job a 50 KB library can do locally. Self-host unless a hosted service gives you something you genuinely need.

Generate QR Codes in the Browser (Client-Side)

Our own free generator works this way: it uses the open-source qrcode-generator JavaScript library, so the code is built on the visitor’s device and the text is never uploaded. You can do the same in a few lines:

JavaScript — browser (qrcode-generator)
// <script src="https://cdn.jsdelivr.net/npm/qrcode-generator@1.4.4/qrcode.min.js"></script>
qrcode.stringToBytes = qrcode.stringToBytesFuncs['UTF-8']; // correct non-ASCII text

const qr = qrcode(0, 'M');   // 0 = pick the smallest version; M = 15% error correction
qr.addData('https://example.com/order/1234');
qr.make();

// SVG markup with a 4-module quiet zone
document.getElementById('out').innerHTML =
  qr.createSvgTag({ cellSize: 8, margin: 4 });

That is the whole “API call”. For styled output, canvas rendering and Node usage, see our full guide to generating QR codes in JavaScript.

Generate QR Codes on the Server

Server-side generation suits anything you send or store: order confirmations, PDF tickets, invoices, labels. Every mainstream language has a mature, free library.

LanguageOpen-source libraryOutput
Node.jsqrcode (npm)PNG buffer, SVG string, data URL, terminal
Pythonsegno, qrcodePNG, SVG, PDF, EPS and more (segno); PNG/SVG (qrcode)
PHPchillerlan/php-qrcode, endroid/qr-codeSVG, PNG and others
Java / KotlinZXing (core + javase)BitMatrix → PNG
SwiftCore Image CIQRCodeGenerator (built in)CIImage → PNG

Node.js

JavaScript — Node.js (npm install qrcode)
import QRCode from 'qrcode';

const png = await QRCode.toBuffer('https://example.com', {
  errorCorrectionLevel: 'M', margin: 4, width: 512
});
const svg = await QRCode.toString('https://example.com', { type: 'svg' });

Python

Python 3 (pip install segno)
import segno

qr = segno.make_qr("https://example.com", error="m")
qr.save("code.svg", scale=10, border=4)
qr.save("code.png", scale=10, border=4)

More options — colours, Pillow styling, the qrcode package — are in generating QR codes in Python.

PHP

PHP 8 (composer require chillerlan/php-qrcode)
use chillerlan\QRCode\{QRCode, QROptions};
use chillerlan\QRCode\Common\EccLevel;
use chillerlan\QRCode\Output\QROutputInterface;

$options = new QROptions([
    'outputType'   => QROutputInterface::MARKUP_SVG,
    'eccLevel'     => EccLevel::M,
    'outputBase64' => false,   // return raw <svg> markup, not a data: URI
]);
header('Content-Type: image/svg+xml');
echo (new QRCode($options))->render('https://example.com');

The option names above are from version 5 of the library; check the README of the version you install, because option names have changed between major releases. endroid/qr-code is a popular alternative if you prefer a builder-style interface. Both are free.

Java (ZXing)

Java — ZXing core + javase
Map<EncodeHintType, Object> hints = Map.of(
    EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M,
    EncodeHintType.CHARACTER_SET, "UTF-8",
    EncodeHintType.MARGIN, 4);
BitMatrix m = new QRCodeWriter().encode(
    "https://example.com", BarcodeFormat.QR_CODE, 512, 512, hints);
MatrixToImageWriter.writeToPath(m, "PNG", Path.of("code.png"));

Swift (iOS and macOS, no dependencies)

Swift — Core Image
import CoreImage.CIFilterBuiltins

let filter = CIFilter.qrCodeGenerator()
filter.message = Data("https://example.com".utf8)
filter.correctionLevel = "M"          // L, M, Q or H
let scaled = filter.outputImage!
    .transformed(by: CGAffineTransform(scaleX: 10, y: 10))  // crisp, no blur
let cg = CIContext().createCGImage(scaled, from: scaled.extent)

SwiftUI integration, colouring with CIFalseColor and export are covered in CIQRCodeGenerator in Swift.

Build Your Own QR Code API Endpoint

If several apps need QR images, or you want to drop codes into HTML emails with a plain <img src>, wrap one of these libraries in a small HTTP route. Keep the surface area small: one generate endpoint usually covers everything.

Core QR code API REST endpoints: POST and GET /v1/qr/generate, POST /v1/qr/batch and GET /v1/qr/{id}
An illustration of a typical endpoint layout (not an API we offer). For your own service, a single GET generate route is usually enough.
Python — Flask + segno
import io, segno
from flask import Flask, request, abort, Response

app = Flask(__name__)

@app.get("/qr")
def qr():
    data = request.args.get("data", "")
    level = request.args.get("ec", "m").lower()
    fmt = request.args.get("format", "svg")
    if not data or len(data) > 1000 or level not in ("l", "m", "q", "h") or fmt not in ("svg", "png"):
        abort(400)
    buf = io.BytesIO()
    segno.make_qr(data, error=level).save(buf, kind=fmt, scale=10, border=4)
    mime = "image/svg+xml" if fmt == "svg" else "image/png"
    return Response(buf.getvalue(), mimetype=mime,
                    headers={"Cache-Control": "public, max-age=31536000, immutable"})

Prefer Node? The same endpoint in Express looks like this:

JavaScript — Node.js + Express (npm install express qrcode)
import express from 'express';
import QRCode from 'qrcode';
const app = express();

app.get('/qr', async (req, res) => {
  const { data = '', ec = 'M', format = 'svg' } = req.query;
  if (typeof data !== 'string' || !data || data.length > 1000
      || !['L', 'M', 'Q', 'H'].includes(ec)
      || !['svg', 'png'].includes(format)) {
    return res.sendStatus(400);
  }
  res.set('Cache-Control', 'public, max-age=31536000, immutable');
  if (format === 'svg') {
    res.type('image/svg+xml').send(await QRCode.toString(data, { type: 'svg', errorCorrectionLevel: ec, margin: 4 }));
  } else {
    res.type('image/png').send(await QRCode.toBuffer(data, { errorCorrectionLevel: ec, margin: 4, width: 512 }));
  }
});
app.listen(3000);

Call it like any QR code API: GET /qr?data=https%3A%2F%2Fexample.com%2Fp%3Fid%3D42&ec=M&format=svg. Remember to URL-encode the data value, otherwise characters such as & and # in your own URL will be read as part of the API request. In an HTML email or page you embed it as <img src="https://yourdomain.com/qr?data=..." alt="QR code">.

Design notes that matter in production:

Download

QR Code Apps for Mac & Safari

Prefer generating codes without opening a browser tab? These two native Apple apps cover both habits — a full generator on the desktop, and a one-click share button inside Safari.

Gen QR Fast QR code generator for links, text, Wi-Fi and vCards. Works fully offline, exports PNG and SVG.
Mac App Get
Tab to QR Turn the current tab into a QR code to scan or share, straight from the Safari toolbar.
Safari Extension Get

Securing a Public QR Endpoint

An internal endpoint behind your firewall needs little more than validation. If you expose it on the internet, treat it like any other API.

QR code API authentication examples: Bearer token header, X-API-Key header and the less secure query parameter
Send keys in a header, not the query string, and keep them in environment variables — never in a repository.
QR code API rate limit headers X-RateLimit-Limit, Remaining and Reset, and a 429 Too Many Requests response with Retry-After
If you rate-limit your endpoint, return 429 with a Retry-After header so clients can back off politely.

Caching, Signed URLs and Rate Limits

A QR code is a pure function of its input: the same data, error-correction level and format always produce the same image. That makes caching almost free to get right.

Python — HMAC signature for /qr URLs
import hmac, hashlib
SECRET = b"load-me-from-an-environment-variable"

def sign(data, ec, fmt):
    msg = f"{data}|{ec}|{fmt}".encode()
    return hmac.new(SECRET, msg, hashlib.sha256).hexdigest()

# in the route, after reading the query string:
if not hmac.compare_digest(request.args.get("sig", ""), sign(data, level, fmt)):
    abort(403)

Your backend builds the URL with &sig=... when it renders the page or email; visitors cannot change data without invalidating the signature, so the endpoint cannot be used as a free QR printer for other people’s links.

Rate limits still matter for any endpoint that is not signed. Limit per IP or key in your reverse proxy or framework, and return 429 Too Many Requests with a Retry-After header. Cached responses served by a CDN never reach your server, so they do not count against the limit.

Payload Formats: Wi-Fi, vCard, Email, Phone

A QR library encodes whatever string you give it. The “type” of code is just a text convention that phones recognise, so building these strings correctly is your job:

TypeString to encodeGotcha
URLhttps://example.com/p?id=42Percent-encode query values
Wi-FiWIFI:T:WPA;S:name;P:pass;;Backslash-escape \ ; , : " (Wi-Fi format)
ContactBEGIN:VCARD … END:VCARDLine breaks matter; no PHOTO (vCard format)
Emailmailto:hi@example.com?subject=HelloEncode spaces as %20
Phonetel:+15551234567Use international format

“Dynamic QR Code API”: Build the Redirect Yourself

A “dynamic” QR code is a static QR code that points to a short redirect URL; the service behind it lets you change the destination and counts the visits. You can build this with the tools above and your own domain:

  1. Encode a short URL you control, such as https://yourdomain.com/r/spring24, as a normal static code.
  2. Add a route that looks up spring24 in your database and returns a 302 redirect to the current destination.
  3. Append UTM parameters to the destination (or log the hit in the redirect route) to see scans in your own analytics.

You keep the data, there is no subscription, and the printed code works for as long as your domain does. The trade-offs are explained in static vs dynamic QR codes.

Common Integrations

QR code API integration scenarios: e-commerce product and order codes, CRM contact and campaign codes, signed event ticket tokens
The same generator function serves e-commerce, CRM and ticketing workflows.

What About Hosted QR Code APIs?

Hosted QR code API services exist, and some are worth using for specific reasons. Before you pick one, check what you would actually be paying for, because the core job (turning text into an image) is the part you can do yourself:

If you do use one, prefer a service that can export plain static codes, so you are never locked in. For the full picture of redirect-based codes, read static vs dynamic QR codes.

Troubleshooting Your QR Endpoint

Not a Developer? No Code Needed

If you only need a handful of codes, skip the code entirely. Our free web generator makes URL, Text, Wi-Fi, Email and Phone codes in your browser and downloads PNG or SVG. On a Mac, Gen QR – Code Maker adds colours, a logo overlay, L/M/Q/H error correction and contact-card codes, fully offline, for a one-time purchase. And Tab to QR turns the current Safari tab into a QR code with one click — handy for testing a page on your phone during development.

Need a Code Right Now?

Generate a static QR code in your browser — no API key, no sign-up, no upload.

Frequently Asked Questions

You don't need one. Open-source libraries such as qrcode-generator and qrcode for JavaScript, segno for Python, ZXing for Java and Core Image on Apple platforms generate QR codes free, locally and without rate limits. If other services need an HTTP endpoint, wrap a library in a small route on your own server.

No. GenerateOnlineQR.com offers a free browser-based generator and two Mac apps, but no public API. The generator itself uses the open-source qrcode-generator JavaScript library, which you can use in your own projects.

Install a QR library for your language, pass it the text or URL, choose an error-correction level such as M, and save the result as SVG or PNG with a four-module quiet zone. In Python, for example, segno.make_qr(data).save('code.svg') is enough.

Generate in the browser when the data is private or only shown on screen, because nothing is uploaded. Generate on the server when the code goes into an email, PDF, ticket or label, or when other systems need it.

Encode a short URL on your own domain as a static QR code, and add a server route that looks up the code's ID and returns a 302 redirect to the current destination. Change the destination in your database whenever you like, and track scans with UTM tags or your redirect logs.

Use M for most codes. Use Q or H if the code will carry a logo or be printed on surfaces that get scratched or dirty. Higher levels make the code denser, so keep the encoded data short.

Yes, but you don't need a hosted one: the open-source ZXing library generates QR codes in Java. Use QRCodeWriter to create a BitMatrix and MatrixToImageWriter from the javase module to write it as PNG.

A QR code API is an HTTP endpoint that receives text or a URL and returns a QR code image, usually PNG or SVG. You can use a third-party service or run your own by wrapping an open-source library such as qrcode (Node), segno (Python) or chillerlan/php-qrcode (PHP) in a single route.

Write one route that reads a data parameter, validates it (length, error-correction level, format), generates the code with an open-source library and returns the image with a long Cache-Control header. The Flask and Express examples in this guide are about twenty lines each.

Cap the input length and image size, allow-list the options, rate-limit with 429 responses, and for public use sign the URL with an HMAC so only codes your backend created are rendered.