The QRCode API generates custom QR codes for any content. It supports custom colors, size, and several image formats.
https://api.api-ninjas.com/v1/qrcode
Returns a QRCode image binary specified by input parameters.
data
requiredData to encode in the QR code.
format
requiredImage format to return. Must be one of the following: png
, jpg
, jpeg
, eps
, svg
.
size
optionalSize of the QR code image to generate. The output will be a square image with (size x size) dimensions.
fg_color
optionalForeground color of the QR code. Must be a 6-digit hex color (e.g. 00ff00
for green). Default is 000000
(black).
bg_color
optionalBackground color of the QR code. Must be a 6-digit hex color (e.g. 00ff00
for green). Default is ffffff
(white).
X-Api-Key
requiredAPI Key associated with your account.
Accept
may be requiredDepending 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
https://api.api-ninjas.com/v1/qrcode?format=png&data=https://api-ninjas.com
Headers
X-Api-Key
Log in or sign up to get your API Key
1
2
3
4
5
6
7
8
9
10
11
12
import requests
import shutil
data = 'https://api-ninjas.com'
fmt = 'png'
api_url = 'https://api.api-ninjas.com/v1/qrcode?data={}&format={}'.format(data, fmt)
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY', 'Accept': 'image/png'}, stream=True)
if response.status_code == requests.codes.ok:
with open('img.jpg', 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
else:
print("Error:", response.status_code, response.text)
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.