Skip to main content

Encode QR Code

Encodes a UTF-8 string into a base64-encoded JPEG image of a QR code using the ZXing library.

Request

POST /nxt?requestType=encodeQRCode&qrCodeData=<data>&width=<pixels>&height=<pixels>

Parameters

NameTypeRequiredDescription
qrCodeDatastringYesUTF-8 text string to encode.
widthintegerNoWidth of the output image in pixels. Defaults to 0 (minimum size). Range: 0-5000.
heightintegerNoHeight of the output image in pixels. Defaults to 0 (minimum size). Range: 0-5000.

Response

{
"qrCodeBase64": "/9j/4AAQSkZJRgABAQAAAQABAAA..."
}

Response Fields

FieldTypeDescription
qrCodeBase64stringBase64-encoded JPEG image of the QR code.

Error Responses

ConditionResponse
Error creating QR codeError response from JSONData.putException()

Notes

  • This endpoint does not require the blockchain to be running (requireBlockchain = false).
  • Not chain-specific.
  • Does not require admin password authentication (requirePassword = false).
  • Error correction level is M (15%), margin is 0.
  • Width/height of 0 produces the minimum sized QR image (1 pixel per black/white region).
  • To eliminate padding, requested width/height must be an integer multiple of the minimum.

Source: EncodeQRCode.java.

Example

curl -X POST "http://localhost:22024/nxt" \
-d "requestType=encodeQRCode" \
-d "qrCodeData=Hello World" \
-d "width=0" \
-d "height=0"