QR Code API
Generate + Decode
PNG + SVG
Custom Colors

QR codes. Both directions.

Generate PNG or SVG QR codes from any text with custom size, colors, and error correction, then decode QR content back out of images. Compute-only, no upstream calls.

4296 · max text chars64–2048 · pixel sizeL / M / Q / H · error correctionmulti-code · decode

Generate a QR code.

This calls the live QR Code API. Type any payload, tune the size, colors, and error correction, and render a real QR code you can scan.

Request builder
Encode text into a scannable PNG.
POST /qr-code/generate
320 px
#0f172a
Decoding too
POST /decode reads QR content back out of a base64 image, including multi-code scans with the all and maxCodes options.
Output preview
Live response from the API, plus the exact request to reproduce it.

Run the request to render your QR code here.

Why QR Code API

Encode and decode in one service.

PNG and SVG output

Generate raster PNG for sharing or crisp vector SVG for print and scaling, from the same generate endpoint.

Custom colors and sizing

Set dark and light hex colors, pixel width from 64 to 2048, and a quiet-zone margin of 0 to 16 modules.

Error correction levels

Pick L, M, Q, or H so codes stay scannable with logos, damage, or low-contrast printing.

Decode from images

POST a base64 image to read QR content back out, with location geometry and scan diagnostics.

Multi-code scanning

Set all=true with maxCodes to detect and return several QR codes from a single image in one call.

Compute-only, fast

No upstream dependencies means low latency and a generous 200 requests per 15-minute limit.

/api/v1/qr-code

Endpoints, at a glance.

Two POST endpoints: generate to encode, decode to read. POST is required for structured options and base64 image input.
POST/api/v1/qr-code/generate

Generate QR code

Encode text into a PNG or SVG QR image, returned as JSON, base64, or raw binary.

PRIMARY
POST/api/v1/qr-code/decode

Decode QR code

Read QR content from a base64 image, with optional multi-code scanning.

GET/health

Service health

Status, service name, version, timestamp, and correlationId.

GET/metrics

Prometheus metrics

Request counts and latency histograms in Prometheus exposition format.

ParameterTypeRequiredDescription
textstringgenerateText payload to encode, 1 to 4296 characters.
formatstringnoOutput format: png (default) or svg.
sizeintegernoGenerated width in pixels, 64 to 2048. Default 256.
marginintegernoQuiet-zone margin in modules, 0 to 16. Default 2.
errorCorrectionLevelstringnoL, M (default), Q, or H. Higher levels tolerate more damage.
darkColor / lightColorstringnoForeground and background hex colors (#RRGGBB). Default black on white.
responseTypestringnogenerate output mode: json (default), base64, or binary.
imageBase64stringdecodeBase64 image (optional data: prefix), minimum 16 characters, up to 5 MB.
all / maxCodesboolean / integernoMulti-code decode toggle and cap (1 to 10) when all=true. Default false, 5.

Error reference

Structured errors, always.

Validation and service failures return success: false with an error, an optional reason, and a correlationId.

400Validation Error

Invalid generate or decode body: empty or oversized text, bad hex color, or out-of-range size. The details array lists each issue.

400QR Service Error

Known generation or decode failure, such as an invalid image. The reason field is machine-readable, e.g. invalid-image.

401Authentication Error

Missing or invalid gateway API key. Send x-api-key or api_key with every request.

404Not Found

Unknown endpoint. Valid paths are /generate and /decode under /api/v1/qr-code.

429Rate Limit

More than 200 requests in 15 minutes. The response includes retryAfter seconds.

500Internal Error

Unexpected failure outside known QR service errors. Include the correlationId when reporting.

Example error response

{
  "success": false,
  "error": "Invalid input parameters",
  "details": [
    "\"text\" is required"
  ],
  "correlationId": "req_error123"
}

FAQ

API questions developers ask first.

Can this API both generate and read QR codes?

Yes. POST /generate encodes text into a PNG or SVG QR image, and POST /decode reads QR content back out of a base64 image, including its location geometry and scan diagnostics.

How much can I customize the generated code?

Set the output format (png or svg), pixel size from 64 to 2048, quiet-zone margin from 0 to 16, error correction level (L, M, Q, H), and both the dark and light hex colors.

What output formats are available?

responseType controls the shape: json (default) returns base64 data plus byteLength, base64 returns the encoded string, and binary streams raw image bytes as image/png or image/svg+xml.

Can I decode more than one QR code from an image?

Yes. Send all=true on /decode to attempt multi-code detection, and cap the results with maxCodes (1 to 10). The response reports codeCount and a codes array.

How do I authenticate requests?

Send your Datpaq API key as an x-api-key header or an api_key query parameter. Keys are created in the Datpaq dashboard and a free tier is included.

Add QR codes to anything.

Generate branded PNG or SVG codes and decode them back, from one compute-only API. No image libraries to install, no upstream services.