India API

Docs › Money and business

QR codes and barcodes API

QR codes, UPI payment QR codes and barcodes as SVG or PNG.

Generates codes; it does not read them. What you encode is never logged or kept, and the images are not cached by shared caches.

Base URL https://api.dharun.devNo API key600 requests a minuteThis page as Markdown

QR code for any text

GET/v1/qrPOST

Returns the image itself. Text up to about 2,900 bytes at error correction L.

Also takes POST: The text to encode. Send it as text/plain, or as JSON {"text": "..."} with the other options beside it, up to 256 KB.

What you send here is never written to the log, and the answer is not cached.

ParameterDescription
textqueryText to encode (or POST it).
eccqueryError correction: how much damage the code survives. Default M. One of: L, M, Q, H.
formatqueryImage format. Default svg. One of: svg, png.
sizequery2D codes: width in pixels to stay within, 32 to 2048. Default 256.
marginqueryLight border (quiet zone), in modules, 0 to 16. Default 4.
fgqueryDark colour, hex such as 000000. Default black.
bgqueryLight colour, hex, or transparent. Default white.

curl

curl -o picture.png "https://api.dharun.dev/v1/qr?text=https://api.dharun.dev&format=png&size=256"

HTML

<img src="https://api.dharun.dev/v1/qr?text=https://api.dharun.dev&amp;format=png&amp;size=256" alt="QR code for any text">

Result

Example: QR code for any text

UPI payment QR code

GET/v1/upi-qr

A QR code any UPI app can scan to pay, built to NPCI's upi://pay link format. format=json returns the link instead of the image. Nothing is checked with a bank.

What you send here is never written to the log, and the answer is not cached.

ParameterDescription
paquery, requiredPayee UPI ID, such as shop@okaxis.
pnqueryPayee name shown in the app.
amqueryAmount in rupees, up to two decimals. Leave out to let the payer type it.
tnqueryNote shown with the payment, up to 80 characters.
trqueryYour reference for the transaction.
mcqueryMerchant category code, four digits.
formatqueryImage format. Default svg. One of: svg, png.
sizequery2D codes: width in pixels to stay within, 32 to 2048. Default 256.
marginqueryLight border (quiet zone), in modules, 0 to 16. Default 4.
fgqueryDark colour, hex such as 000000. Default black.
bgqueryLight colour, hex, or transparent. Default white.

curl

curl -o picture.svg "https://api.dharun.dev/v1/upi-qr?pa=shop@okaxis&pn=Sri%20Murugan%20Stores&am=250&tn=Order%2042"

HTML

<img src="https://api.dharun.dev/v1/upi-qr?pa=shop@okaxis&amp;pn=Sri%20Murugan%20Stores&amp;am=250&amp;tn=Order%2042" alt="UPI payment QR code">

Result

Example: UPI payment QR code

Barcode

GET/v1/barcode/{type}POST

Linear barcodes (code128, code39, code93, ean13, ean8, itf, codabar) and 2D codes (datamatrix, pdf417, aztec). Linear codes are sized with scale and height, 2D codes with size. No human-readable text is printed under the bars.

Also takes POST: The text to encode. Send it as text/plain, or as JSON {"text": "..."} with the other options beside it, up to 256 KB.

What you send here is never written to the log, and the answer is not cached.

ParameterDescription
typepath, requiredKind of barcode. One of: code128, code39, code93, ean13, ean8, itf, codabar, datamatrix, pdf417, aztec.
textqueryText to encode (or POST it).
scalequeryLinear codes: pixels per bar module, 1 to 10. Default 2.
heightqueryLinear codes: bar height in pixels, 10 to 600. Default 80.
formatqueryImage format. Default svg. One of: svg, png.
sizequery2D codes: width in pixels to stay within, 32 to 2048. Default 256.
marginqueryLight border, in modules, 0 to 16. The default depends on the code.
fgqueryDark colour, hex such as 000000. Default black.
bgqueryLight colour, hex, or transparent. Default white.

curl

curl -o picture.svg "https://api.dharun.dev/v1/barcode/ean13?text=890123456789"

HTML

<img src="https://api.dharun.dev/v1/barcode/ean13?text=890123456789" alt="Barcode">

Result

Example: Barcode

Guides

Make a UPI payment QR code for an amount

Using an AI assistant? Connect the MCP server and it can call this API by itself.