If you’ve ever had to generate barcodes on the fly — for invoices, labels, stock items, tickets, or internal systems — you’ll know that most libraries are either language-specific, awkward to deploy, or inconsistent across environments.
That’s exactly why I built the Barcode API on myapi.rest.
It’s a simple, fast, hosted API that generates barcodes in common formats and returns them as Base64, ready to embed anywhere.
Why an API for barcodes?
In real systems, barcodes are rarely just “static images”.
You often need to:
- Generate them dynamically
- Control size, margins, and output format
- Embed them into PDFs, emails, labels, or web apps
- Avoid bundling barcode libraries into every project
With an API, you generate once — and consume everywhere.
Supported features
The Barcode API currently supports:
- Multiple barcode formats (e.g.
code_128) - SVG or raster output
- Custom width, height, and margins
- Clean Base64 output for easy embedding
- Stateless, fast requests
Example request
Here’s a real example using curl:
curl --location 'https://api.myapi.rest/api/barcode/generate' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API_KEY>' \
--data '{
"data": "DEC25-45PC",
"barcode_format": "code_128",
"output_format": "SVG",
"width": 200,
"height": 50,
"margin": 0
}'
Request fields explained
| Field | Description |
|---|---|
data |
The value encoded in the barcode |
barcode_format |
Barcode type (e.g. code_128) |
output_format |
SVG or image format |
width |
Output width in pixels |
height |
Output height in pixels |
margin |
Margin around the barcode |
Example response
{
"id": 5,
"barcode": "<BASE_64_DATA>"
}
The barcode value is a Base64-encoded representation of the generated barcode.
This makes it easy to:
- Embed directly into an
<img>tag - Insert into a PDF generator
- Store temporarily or cache
- Convert to a file if needed
Common use cases
This API works well for:
- Invoices & packing slips
- Warehouse & inventory systems
- Tickets and vouchers
- Membership cards
- Internal tooling & admin dashboards
Anywhere you’d normally think “I need a barcode library”, this API fits neatly.
Why I built myapi.rest
myapi.rest is a growing collection of APIs I’ve built from real-world needs while engineering production systems over the years.
Instead of re-implementing the same utilities in every project, the idea is:
- One subscription
- Multiple useful APIs
- Clear documentation
- Predictable behaviour
The Barcode API is just one of many in the platform.
Feedback welcome
If you’re building something that needs barcode generation, I’d love feedback — especially around:
- Additional barcode formats
- Output options
- Performance or batching needs
You can explore the API and docs at https://myapi.rest.
Top comments (0)