CodingMantra LogoCodingMantra
GamesPortfolioProductsServicesAboutContact
  1. Home
  2. API Documentation
  3. QR Code API

QR Code API

Endpoints for generating and decoding custom QR Codes.

GET
/api/qr-code/generate/{apiKey}/{text}

A simple endpoint to quickly generate a QR code for any text or URL. Returns a PNG image directly.

Example Request

# Embed directly in HTML:
<img src="https://codingmantra.com/api/qr-code/generate/YOUR_API_KEY/hello%20world" alt="QR Code" />

# Or use with curl:
curl -X GET 'https://codingmantra.com/api/qr-code/generate/YOUR_API_KEY/hello%20world' -o qr.png

Example Response

The API returns a direct `image/png` response, not JSON.

GET
/api/qr-code/generate-base64/{apiKey}/{text}

A simple endpoint to quickly generate a QR code for any text or URL. Returns a JSON object containing a Base64 data URI of the PNG image.

Example Request

curl -X GET 'https://codingmantra.com/api/qr-code/generate-base64/YOUR_API_KEY/hello%20world' \
     -H 'Authorization: Bearer YOUR_API_KEY'

Example Response

{
  "data": {
    "qrCodeDataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  }
}

POST
/api/qr-code/generate

Generate a custom QR code for various data types like URLs, text, Wi-Fi credentials, and more. Requires authentication. The response will be a JSON object containing a Base64 data URI of the generated PNG image.

Request Body

The request body must include a `type` field which determines the other required fields. Below are the schemas for each type.

Shared Design Parameters (Optional)
FieldTypeDescription
sizenumberSize of the QR code in pixels (e.g., 512). Default: 512.
fgColorstringForeground color in hex format (e.g., "#0A66C2"). Default: #000000.
bgColorstringBackground color in hex format. Default: #FFFFFF.
logoUrlstringURL of a logo to embed in the center.
logoSizeRationumberRatio of the logo size to the QR code size (0.1 to 0.4). Default: 0.2.
isTransparentbooleanIf true, background will be transparent. Default: false.
Type: `url`
FieldTypeDescription
valuestringThe URL to encode (e.g., "https://codingmantra.com").
Type: `text`
FieldTypeDescription
valuestringThe plain text to encode.
Type: `wifi`
FieldTypeDescription
ssidstringThe name of the Wi-Fi network.
passwordstringThe network password.
encryptionstringEncryption type: 'WPA', 'WEP', or 'nopass'.
Type: `email`
FieldTypeDescription
tostringRecipient email address.
subjectstringEmail subject. (Optional)
bodystringEmail body. (Optional)
Type: `vcard`
FieldTypeDescription
firstNamestringFirst name.
lastNamestringLast name.
organizationstringCompany name. (Optional)
phoneWorkstringWork phone number. (Optional)
emailstringEmail address. (Optional)
websitestringWebsite URL. (Optional)
Type: `upi`
FieldTypeDescription
upiIdstringThe UPI ID (VPA) of the payee.
payeeNamestringThe name of the payee.
amountnumberThe payment amount. Optional.
notestringA note for the transaction. Optional.

Example Request (URL type)

curl -X POST 'https://codingmantra.com/api/qr-code/generate' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer YOUR_API_KEY' \
     -d '{
          "type": "url",
          "value": "https://codingmantra.com",
          "size": 512,
          "fgColor": "#0A66C2",
          "logoUrl": "https://codingmantra.com/assets/icons/logo-1024.png"
        }'

Example Request (UPI type)

curl -X POST 'https://codingmantra.com/api/qr-code/generate' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer YOUR_API_KEY' \
     -d '{
          "type": "upi",
          "upiId": "example@upi",
          "payeeName": "John Doe",
          "amount": 150.50,
          "note": "Payment for services"
        }'

Example Response (All POST types)

{
  "data": {
    "qrCodeDataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  }
}

POST
/api/qr-code/decode

Decode a QR code from a provided image URL or Base64 data URI. Requires authentication. The response will be a JSON object containing the decoded text.

Request Body

Provide exactly one of the following fields:

FieldTypeDescription
urlstringA publicly accessible URL of the QR code image.
base64stringA Base64 data URI of the QR code image.

Example Request

# By URL
curl -X POST 'https://codingmantra.com/api/qr-code/decode' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer YOUR_API_KEY' \
     -d '{
          "url": "https://example.com/path/to/your/qrcode.png"
        }'

# By Base64
curl -X POST 'https://codingmantra.com/api/qr-code/decode' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer YOUR_API_KEY' \
     -d '{
          "base64": "data:image/png;base64,iVBORw0KGgo..."
        }'

Example Response

{
  "data": {
    "decodedText": "https://codingmantra.com"
  }
}

On This Page

GET /generate/{apiKey}/{text}GET /generate-base64/{apiKey}/{text}POST /generatePOST /decode
CodingMantra LogoCodingMantra

Providing business solutions for small and medium-sized businesses and helping them to grow.

X / TwitterLinkedInInstagramFacebookGitHub

Company

  • About Us
  • Services
  • Products
  • Portfolio
  • Pricing
  • Blog
  • API Docs
  • Contact Us

Top Tools

  • All Tools
  • Image Tools
  • Digital Marketing
  • Financial Tools
  • Games
  • SEO Tools

Legal

  • Privacy Policy
  • Terms & Conditions
  • Return Policy
  • Deals
  • Sitemap

© 2025 CodingMantra. All Rights Reserved.