Barcode API
The Barcode API generates custom barcodes for any text. It supports multiple barcode types, custom dimensions, and several image formats.
From 3,021 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 314ms | 334ms | 371ms | 521ms | 1173ms |
Similar APIs
Didn't find what you were looking for? Suggest an improvement
/v1/barcodegenerate GET
https://api.api-ninjas.com/v1/barcodegenerate
Returns a barcode image binary specified by input parameters.
Parameters
textrequiredText to encode in the barcode.
typeoptionalType of barcode to generate. Must be one of:
code39,code128,ean,ean13,ean8,gs1,gtin,isbn,isbn10,isbn13,issn,jan,pzn,upc,upca. Default isupc.formatoptionalImage format to return. Must be one of:
png,svg. Default ispng.include_textoptionalWhether to include the text below the barcode. Must be
trueorfalse. Default istrue.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Acceptmay 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 yourformatparameter:png:image/pngsvg:image/svg+xml
Response
Returns the barcode image as binary data in the requested format (PNG or SVG), or an error if the request is unsuccessful.
Sample Request Live Demo!
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/barcodegenerate?format=png&type=upc&text=123456789012Headers
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
3
4
curl -X GET "https://api.api-ninjas.com/v1/barcodegenerate?text=123456789012&type=upc" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Accept: image/png" \
--output barcode.pngIf 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
Can I use the Barcode API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Barcode API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Barcode API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
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.What happens if a request to the Barcode API fails?
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.What barcode types does the Barcode API support?
Thetypeparameter acceptscode39,code128,ean,ean13,ean8,gs1,gtin,isbn,isbn10,isbn13,issn,jan,pzn,upc, andupca, defaulting toupcif omitted. See the full API list for related tools.What image formats can the Barcode API return?
Set theformatparameter to eitherpng(the default) orsvg, and match it with anAcceptheader ofimage/pngorimage/svg+xmlrespectively. If you need QR codes instead, try the QR Code API.What does the /v1/barcodegenerate response contain?
The endpoint returns the barcode image as raw binary data in your requested format (PNG or SVG) rather than JSON, or an error if the request is unsuccessful. The requiredtextparameter sets the value encoded in the barcode.Can I generate a barcode without the human-readable text below it?
Yes, set theinclude_textparameter tofalseto omit the text caption rendered beneath the barcode; it defaults totrue. Sign up on the registration page to get an API key and start generating barcodes.