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
| Name | Type | Required | Description |
|---|---|---|---|
qrCodeData | string | Yes | UTF-8 text string to encode. |
width | integer | No | Width of the output image in pixels. Defaults to 0 (minimum size). Range: 0-5000. |
height | integer | No | Height of the output image in pixels. Defaults to 0 (minimum size). Range: 0-5000. |
Response
{
"qrCodeBase64": "/9j/4AAQSkZJRgABAQAAAQABAAA..."
}
Response Fields
| Field | Type | Description |
|---|---|---|
qrCodeBase64 | string | Base64-encoded JPEG image of the QR code. |
Error Responses
| Condition | Response |
|---|---|
| Error creating QR code | Error 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 is0. - Width/height of
0produces 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"