FEEDBACK & SUPPORT
support@barcodeapi.org

API Documentation

Welcome to BarcodeAPI.org,

  By simply hitting our HTTP/S endpoint you can quickly add barcodes to virtually any application using an intuitive and easy to use barcode generation API, no signup required!

Our API supports a wide array of barcode formats and offers extensive customization options to meet your specific needs.

Join the thousands of businesses who rely on BarcodeAPI.org!

§1 Basic API Usage

  The BarcodeAPI server can generate barcodes for virtually any content passed to the API endpoint. As a RESTful HTTP service, you can make requests using a web browser, command line tools, or other methods, depending on your application’s needs.

HTML
 Embed barcode images directly in an HTML page:

<img src="https://barcodeapi.org/api/auto/test" />
					

JavaScript
 Use fetch to request a barcode and display it on the current page, while printing the remaining token count to the console:

let url = 'https://barcodeapi.org/api/auto/Try%20Me'
fetch(url, { cache: "no-store" })
  .then(response => {

    var tokens = response.headers.get('X-RateLimit-Tokens');
    console.log("Tokens remaining: " + tokens);

    response.blob().then(blob => {
      var img = document.createElement("img");
      img.src = URL.createObjectURL(blob);
      document.body.appendChild(img);
    });
});
					

Excel
 Render barcode images directly into Excel, referencing data which exists in the document:

Using:	https://barcodeapi.org/api/
Config:	fg=ff0000&bg=0000ff
Barcode Text	Type
TryMe	128	=IMAGE(B1&B4&"/"&A4&"?"&B2)
TryMe	qr	=IMAGE(B1&B5&"/"&A5&"?"&B2)
TryMe	dm	=IMAGE(B1&B6&"/"&A6&"?"&B2)

=IMAGE("https://barcodeapi.org/api/TryMe")
					

Markdown
 Add barcode images to markdown documents:

![BarcodeAPI Image](https://barcodeapi.org/api/auto/test)
					

curl / wget
 Download barcodes in a linux command line environment:

curl https://barcodeapi.org/api/A_Barcode > test.png
wget -o test.png https://barcodeapi.org/api/A_Barcode
					

PowerShell
 Generate barcodes using Windows PowerShell automation:

Invoke-WebRequest `
  https://barcodeapi.org/api/auto/test -OutFile test.png
					

Python
 Request and save a barcode to disk using Python:

import shutil
import requests

url = 'https://barcodeapi.org/api/auto/Try%20Me'
response = requests.get(url, stream=True)
with open('test.png', 'wb') as out_file:
  shutil.copyfileobj(response.raw, out_file)
					

§2 Supported Barcode Types

  BarcodeAPI supports a wide range of barcode types, allowing you to generate barcodes for different use cases, such as inventory tracking, product labeling, or QR codes for marketing. For a complete list of available types, please refer to Barcode Types

Type Selection

  You have two methods for selecting the barcode format: manual type selection and automatic type detection. Each approach offers distinct benefits, with manual selection giving you precise control over the format, while automatic detection offers convenience and flexibility by letting the API choose the most appropriate format for your data.


Manual Type Selection

  If you know exactly which barcode format you need, you can specify it directly in the URL. This gives you full control over the barcode type, ensuring that you get the format that best fits your requirements.
/api/128/abc123
/api/qr/abc123

Automatic Type Detection

  If you don’t want to specify a barcode format, you can let the API automatically determine the best format based on the data you provide. The API will analyze the content and choose the most suitable format.
/api/auto/abc123

§3 Barcode Customization

  BarcodeAPI allows you to customize various aspects of your barcodes to fit your specific needs. Whether you're adjusting the size, color, or other visual properties, the API provides a range of customization options for each barcode type. For a full list of available options, check the Barcode Types page.

Customization Options

  Customization options are added to your request as GET parameters. By appending these parameters to your request URL, you can modify the appearance and behavior of the generated barcode. These options can include things like barcode foreground color, background color, height, width, and more.
Example

/api/128/RED?fg=ff0000&bg=ffffff&height=12
				

Control Characters

  Some barcodes support the encoding of NonPrinting ASCII characters. With a supported barcode type selected, click to open the character keyboard which will assist in inserting non-printing characters.

Visit NonPrinting

§4 Bulk Barcode Generation

  Some users need to generate a lot of barcodes; and for this we provide two different tools for the job!

Bulk Generator

  This utility will allow users to upload a simple CSV file containing a list of barcode requests. The server will render the images in bulk and return a single ZIP file of all barcode images.

Each ZIP archive will additionally contain a text file called _debug.txt which will help

Visit Bulk Generator

Multis Utility

  This utility will allow users to generate a large number of barcodes on a single page. Simply paste your text list and see all the barcodes! Optionally print them too! Click the share button to get a simple link you can bookmark or share with a colleague.

Visit Multi Generator

§5 Barcode Response Headers

  The server makes a number of headers available which describe the result of the request.

Barcode Information

  The server will add several headers related to the barcode including the type and encoded contents.

$ curl --head https://barcodeapi.org/api/auto/abc123
...
Content-Type: image/png
X-Barcode-Type: Code128
X-Barcode-Content: abc123
Content-Disposition: filename=abc123.png
					

Cache Control

  In an attempt to minimize the number of requests, barcodes requested outside of the webapp will have a cache expiration time set.

$ curl --head https://barcodeapi.org/api/auto/abc123
...
Access-Control-Max-Age: 86400
Cache-Control: max-age=86400, public
Expires: Sat, 04 Jan 2025 06:57:14 GMT
					

Rate Limits

  The server will add several headers related to the rate limiter applied to the client.

$ curl --head https://barcodeapi.org/api/auto/abc123
...
X-RateLimit-Cost: 2
X-RateLimit-Tokens: 2032.40
					

  Should a client become rate limited, requests to the server will result in a 429 error code indicating their rate limit is enforced. The caller must wait until new tokens are generated before additional requests will be served.

$ curl --head https://barcodeapi.org/api/auto/abc123
HTTP/1.1 429 Too Many Requests
...
X-Error-Message: Client is rate limited, try again later.
					

API Redirect

  The server provides a set of static resources served from the root url of the server, in the event a request is made which is not targeted directly at the API nor references a known resources, a 403 redirect will be provided to send the send request to the API handler.

$ curl --head https://barcodeapi.org/abc123
HTTP/1.1 302 Found
...
Location: https://barcodeapi.org/api/auto/abc123
					

Generation Errors

  Each type of barcode generation failure will result in a unique HTTP status code.

200	OKAY		Barcode generated sucessfully.
400	INVALID		Invalid data for selected code type.
403	ABUSE		The IP is blocked for abuse.
406	EMPTY		The request was empty.
409	CHECKSUM	Expected checksum: #
412	BLACKLIST	The request was rejected.
429	LIMITED		Client is rate limited, try again later.
500	FAILED		Failed to render barcode.
503	BUSY		Server is busy, please try again.
					

  In the event of a render error, an additional header [X-Error-Message] will be available containing details about the exception.


$ curl --head https://barcodeapi.org/api/8/00000009
HTTP/1.1 409 Conflict
...
X-Error-Message: Expected checksum: 0
					

§6 Tokens and Rate Limits

  To ensure optimal service for all users, we implement rate limiting and offer tiered pricing plans for high-volume users. While the FREE tier should meet basic usage needs, some users may require higher limits for larger volumes of barcode requests.

Pricing Plans

  If you need higher rate limits, you can upgrade to one of our paid plans. Each plan is flexible and can accommodate varying token usage levels to suit your needs.

Don't worry, none of the barcodes we show you in the docs count against your rate limit!

For additional details, visit Rate Limits

IP-Based Rate Limiting

  Rate limits are enforced based on the IP address of the client making the request. Multiple IPs may be assigned to the same rate limiter for users with more then one public facing IP address.

API Keys

  If your application runs in an environment where the public IP address of the caller changes often, your API key should be included in each request.

Using An API Key

  If you have an API key, include it in the Authorization header with each request. The token should be passed as follows:

Authorization: Token=xxxxxxxxxxxx
					

Embedded Barcodes

  When embedding barcodes in an application accessed by end users, rate limits are tracked by the HTTP Referer value.

§7 User Session Info

  Users of the web interface are assigned a session token for basic history tracking. By default, your browser will pass this token along with each request. Sessions will generally expire several days after last use, but may also be deleted from the server cache on request.

To view the details of your current session, visit Session Info

§8 Technical Support

Still looking for additional information or support?
Send us an email! Our team will respond as soon as possible.

Please refer to Contact & Support

support@barcodeapi.org