NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server

QRCode API

The QRCode API generates custom QR codes for any content. It supports custom colors, size, and several image formats.

(4.7)

From 4,752 users

2,400+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
277ms315ms371ms560ms1201ms

Didn't find what you were looking for? Suggest an improvement


/v1/qrcode GET

https://api.api-ninjas.com/v1/qrcode

Returns a QRCode image binary specified by input parameters.

Parameters

  • data  required

    Data to encode in the QR code.

  • format  required

    Image format to return. Must be one of the following: png, jpg, jpeg, eps, svg.

  • size  optional

    Size of the QR code image to generate (e.g. 200). The output will be a square image with (size x size) dimensions. The default size is 250.

  • fg_color  optional

    Foreground color of the QR code. Must be a 6-digit hex color (e.g. 00ff00 for green). Default is 000000 (black).

  • bg_color  optional

    Background color of the QR code. Must be a 6-digit hex color (e.g. 00ff00 for green). Default is ffffff (white).

Headers

  • X-Api-Key  required

    API Key associated with your account.

  • Accept  may be required

    Depending on the programming language and HTTP request library (e.g. Python's requests), you may need to add a header indicating the content type(s) to accept in the result. Set the value according to your format parameter:

    • png: image/png
    • jpg: image/jpg
    • jpeg: image/jpeg
    • eps: application/postscript
    • svg: image/svg+xml

Response

Returns the generated QR code image in the format specified by the format parameter (for example PNG, JPG, SVG). The response body is binary image data (or text for SVG/EPS). Returns an error if the request is unsuccessful.

Sample Request Live Demo!

data
format
size
fg_color
bg_color

Try our APIs in the API playground

Sign up for a free API key to get started — no credit card required.

https://api.api-ninjas.com/v1/qrcode?data=https%3A%2F%2Fapi-ninjas.com&format=png

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

IMAGE
Sample QR code encoding https://api-ninjas.com

Code Examples

1 2 3 4 curl -X GET "https://api.api-ninjas.com/v1/qrcode?data=https://api-ninjas.com&format=png" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Accept: image/png" \ --output qrcode.png

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.

Frequently Asked Questions

  • Yes, but you must have a premium subscription. Commercial use of the QR Code API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.
  • The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.
  • You can generate QR codes that encode any content via the data parameter, such as website URLs, contact details, Wi-Fi credentials, or payment links for product packaging, posters, and digital tickets. See the full API catalog for related tools like the Barcode API.
  • Use the optional size parameter to set the square dimensions in pixels (default 250), and the optional fg_color and bg_color parameters with 6-digit hex values (e.g. 00ff00) to set the foreground and background colors, which default to 000000 and ffffff. Full details are on the API documentation.
  • The required format parameter accepts png, jpg, jpeg, eps, and svg, and you may need to set a matching Accept header (such as image/png or image/svg+xml) depending on your HTTP library. If a request is unsuccessful, see the error codes.
  • The response is the generated QR code image returned in the format specified by the format parameter, delivered as binary image data for raster formats like PNG and JPG or as text for SVG and EPS. For image-related needs you can also explore the Random Image API.