Barcode Generation & Decoding API
Generate and decode barcodes in QR Code, PDF417, Code 39, and Code 128 formats via a simple REST API.
Overview
The Barcode Generation & Decoding API lets you create and read barcodes programmatically. Generate images in multiple popular formats or upload existing barcodes for decoding. All responses include image dimensions, format metadata, and decoded values.
- Generate QR Code, PDF417, Code 39, and Code 128 barcodes
- Decode barcodes from image uploads
- PNG output ready for printing and display
- Bulk generation support for high-volume workflows
Authentication
All API requests require a RapidAPI key passed via the request header. Subscribe to any plan on RapidAPI to receive your API key.
X-RapidAPI-Key: your-api-key
Endpoints
/v1/barcode/generate
Generates a barcode image from the provided data string and format.
/v1/barcode/decode
Decodes a barcode from an uploaded image and returns the encoded data.
Request
Send a POST request with a JSON body containing the data and format for generation.
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | string | Yes | Data to encode in the barcode |
| format | string | Yes | Barcode format: qr, pdf417, code39, or code128 |
| width | number | No | Image width in pixels (default: 400) |
| height | number | No | Image height in pixels (default: 120) |
{
"data": "123456789012",
"format": "code128"
}
Response
A successful generation returns a 200 status with image details and metadata.
| Field | Type | Description |
|---|---|---|
| format | string | Canonical format name (e.g. CODE128, CODE39, PDF417, QR) |
| value | string | The encoded data value |
| encoded_length | number | Length of the encoded barcode pattern |
| image_width | number | Width of the generated image in pixels |
| image_height | number | Height of the generated image in pixels |
| image_data | string | Base64-encoded PNG image data |
| status | string | Request status: success or error |
{
"format": "CODE128",
"value": "123456789012",
"encoded_length": 155,
"image_width": 400,
"image_height": 120,
"image_data": "iVBORw0KGgo...",
"status": "success"
}
Error Codes
| Status | Code | Message | Description |
|---|---|---|---|
| 400 | MISSING_PARAM | Missing required parameter | Required field (data or format) is missing |
| 400 | INVALID_FORMAT | Unsupported barcode format | Format must be code39, code128, pdf417, or qr |
| 400 | INVALID_DATA | Data too long or contains invalid chars | The data string exceeds format limits or has invalid characters |
| 401 | UNAUTHORIZED | Invalid or missing API key | The X-RapidAPI-Key header is missing or invalid |
| 429 | RATE_LIMIT | Rate limit exceeded | Request limit for your plan has been reached |
| 500 | INTERNAL_ERROR | Internal server error | An unexpected error occurred. Please try again. |
Code Examples
cURL
curl --request POST \
--url https://frapi-barcode-v1.p.rapidapi.com/v1/barcode/generate \
--header 'X-RapidAPI-Key: your-api-key' \
--header 'Content-Type: application/json' \
--data '{"data": "123456789012", "format": "code128"}'
Python
import requests
url = "https://frapi-barcode-v1.p.rapidapi.com/v1/barcode/generate"
headers = {
"X-RapidAPI-Key": "your-api-key",
"Content-Type": "application/json"
}
data = { "data": "123456789012", "format": "code128" }
response = requests.post(url, json=data, headers=headers)
print(response.json())
JavaScript
const url = 'https://frapi-barcode-v1.p.rapidapi.com/v1/barcode/generate';
const options = {
method: 'POST',
headers: {
'X-RapidAPI-Key': 'your-api-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({ data: '123456789012', format: 'code128' })
};
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
Rate Limits
Request limits depend on your subscription tier. Exceeding your limit returns a 429 status.
| Tier | Requests / Month | Rate Limit |
|---|---|---|
| Starter (Free) | 500 | 10 req/min |
| Pro | 10,000 | 60 req/min |
| Enterprise | 100,000 | 300 req/min |
Try It Out
Test the API right in your browser. No API key required.