-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathapi.html
executable file
·566 lines (514 loc) · 17.8 KB
/
api.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
<html>
<!--
api.html
BarcodeAPI.org, 2017-2025
-->
<head>
<title>BarcodeAPI.org - API Usage</title>
<meta name="keywords"
content="barcode, barcode api, barcode app, barcode generator, download barcode, free barcodes, custom barcodes">
<meta name="description"
content="Free online barcode generator! Scan barcodes in the web browser or download the images for free!">
<link rel="icon" type="image/png" href="/ext/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="/ext/3p/flexboxgrid.min.css" />
<link rel="stylesheet" type="text/css" href="/ext/css/layout.css" />
<script src="/ext/js/ui.js"></script>
</head>
<body>
<div class="wrapper container-fluid">
<div class="header row between-sm start-sm center-xs">
<div class="header-logo start-sm center-xs col-xs-12 col-sm-5"></div>
<div class="header-contact col-sm-5 middle-xs end-xs">
<h4>
<div class="header-support">FEEDBACK & SUPPORT</div>
<div class="header-email">[email protected]</div>
</h4>
<div class="action-icon action-email icon-email"></div>
</div>
</div>
<a name="top"></a>
<div class="help-entry row center-xs middle-xs">
<div class="col-sm-8 col-xs-12">
<h2>API Documentation</h2>
</div>
</div>
<div class="help-entry row center-xs middle-xs">
<div class="col-sm-8 col-xs-12">
<p class="start-xs">
Welcome to <b>BarcodeAPI.org</b>,
<br />
<br />
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.
<br />
<br />
Our API supports a wide array of barcode formats and offers extensive customization
options to meet your specific needs.
<br />
<br />
Join the many who rely on BarcodeAPI.org for their barcode needs.
</p>
</div>
<div class="col-sm-4 col-xs-12 center-xs end-sm row">
<div class="col-xs-12 row help-toc-title">
<h3>Sections</h3>
</div>
<div class="col-xs-12 row help-toc-table">
<div class="col-xs-12 start-xs">
<a class="toc-link" href="#tokens">
§1 - Tokens and Rate Limits
</a>
</div>
<div class="col-xs-12 start-xs">
<a class="toc-link" href="#usage">
§2 - Basic API Usage
</a>
</div>
<div class="col-xs-12 start-xs">
<a class="toc-link" href="#formats">
§3 - Barcode Formats
</a>
</div>
<div class="col-xs-12 start-xs">
<a class="toc-link" href="#custom">
§4 - Barcode Customization
</a>
</div>
<div class="col-xs-12 start-xs">
<a class="toc-link" href="#bulk">
§5 - Bulk Barcode Generation
</a>
</div>
<div class="col-xs-12 start-xs">
<a class="toc-link" href="#headers">
§6 - Response Headers
</a>
</div>
<div class="col-xs-12 start-xs">
<a class="toc-link" href="#session">
§7 - User Session Info
</a>
</div>
<div class="col-xs-12 start-xs">
<a class="toc-link" href="#support">
§8 - Technical Support
</a>
</div>
</div>
</div>
</div>
<a name="tokens"></a><br />
<div class="help-entry row center-xs top-xs">
<div class="col-xs-11">
<h2><a href="#tokens">§1</a> Tokens and Rate Limits</h2>
<p class="start-xs">
To ensure optimal service for all users, we implement <b>rate limiting</b> and offer
tiered <b>pricing plans</b> 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.
</p>
</div>
<br />
<br />
<div class="col-sm-6 col-xs-12">
<div>
<b>Pricing Plans</b>
<p class="start-xs">
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.
</p>
<p>
For additional details, visit <a href="/limits.html" class="text-link anim icon-chevron">Rate
Limits</a>
</p>
</div>
<div>
<b>Requesting a Token</b>
<p class="start-xs">
API tokens are used to manage your rate limits and are issued to paying customers.
These tokens ensure that your usage is tracked and that rate limits are properly enforced.
</p>
<p>
To upgrade your account, visit <a href="/contracts.html"
class="text-link anim icon-chevron">Usage
Contracts</a>
</p>
</div>
</div>
<div class="col-sm-6 col-xs-12">
<div>
<b>IP-Based Rate Limiting</b>
<p class="start-xs">
Rate limits are enforced based on the IP address of the client making the request.
If you plan to generate a large number of barcodes from a central server or location, you will
need an API key to manage your rate limits effectively.
</p>
</div>
<div>
<b>Using A Token</b>
<p class="start-xs">
If you have an API token, include it in the Authorization header with each request.
The token should be passed as follows:
<pre>
Authorization: Token=xxxxxxxxxxxx
</pre>
</p>
<p class="start-xs">
<b>Note</b>: When embedding barcodes in an application accessed by end users, do not include the
API key in client-side requests. Rate limits will be managed at the IP level instead, so no API
key is needed for each user.
</p>
</div>
</div>
</div>
<a name="usage"></a><br />
<div class="help-entry row center-xs top-xs">
<div class="col-sm-8 col-xs-12">
<h2><a href="#usage">§2</a> Basic API Usage</h2>
<p class="start-xs">
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.
</p>
</div>
<div class="col-sm-4 col-help-image">
<img class="help-image" src="/api/aztec/Aztec%20Barcode" />
</div>
<div class="col-sm-6 col-xs-12">
<div>
<p class="start-xs">
<span class="example-code-title">HTML</span>
<br />
To embed a barcode in an HTML page:
</p>
<pre class="example-code">
<img src="https://barcodeapi.org/api/auto/test" />
</pre>
</div>
<div>
<p class="start-xs">
<span class="example-code-title">JavaScript</span>
<br />
Use <b>fetch</b> to request a barcode and display it on the current page, while printing
the remaining token count to the console.
</p>
<pre class="example-code">
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);
});
});
</pre>
</div>
</div>
<div class="col-sm-6 col-xs-12">
<div>
<p class="start-xs">
<span class="example-code-title">curl</span>
<br />
Request and save a barcode using curl
</p>
<pre class="example-code">
curl https://barcodeapi.org/api/A_Barcode > test.png
</pre>
</div>
<div>
<p class="start-xs">
<span class="example-code-title">wget</span>
<br />
Request and save a barcode using wget
</p>
<pre class="example-code">
wget -o test.png https://barcodeapi.org/api/A_Barcode
</pre>
</div>
<div>
<p class="start-xs">
<span class="example-code-title">PowerShell</span>
<br />
Request and save a barcode using PowerShell
</p>
<pre class="example-code">
Invoke-WebRequest `
https://barcodeapi.org/api/auto/test -OutFile test.png
</pre>
</div>
<div>
<p class="start-xs">
<span class="example-code-title">Python</span>
<br />
Request and save a barcode using Python
</p>
<pre class="example-code">
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)
</pre>
</div>
</div>
</div>
<a name="formats"></a><br />
<div class="help-entry row center-xs top-xs">
<div class="col-sm-8 col-xs-12">
<h2><a href="#formats">§3</a> Barcode Formats</h2>
<p class="start-xs">
BarcodeAPI supports a wide range of barcode formats, 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 formats, please refer to <a class="text-link anim icon-chevron"
href="/types.html">Barcode Types</a>
</p>
</div>
<div class="col-sm-4 col-help-image">
<img class="help-image" src="/api/qr/QR%20Barcode" />
</div>
<div class="col-xs-12">
<h3>Type Selection</h3>
<p class="start-xs">
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.
</p>
<br />
</div>
<div class="col-sm-6 col-xs-12">
<b>Manual Type Selection</b>
<p class="start-xs">
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.
<br />
<a href="/api/128/abc123">/api/128/abc123</a>
<br />
<a href="/api/qr/abc123">/api/qr/abc123</a>
</p>
</div>
<div class="col-sm-6 col-xs-12">
<b>Automatic Type Detection</b>
<p class="start-xs">
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.
<br />
<a href="/api/auto/abc123">/api/auto/abc123</a>
</p>
</div>
</div>
<a name="custom"></a><br />
<div class="help-entry row center-xs top-xs">
<div class="col-xs-12">
<h2><a href="#custom">§4</a> Barcode Customization</h2>
<p class="start-xs">
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 <a href="/types.html" class="text-link anim icon-chevron">Barcode Types</a> page.
</p>
</div>
<div class="col-sm-6 col-xs-12">
<h3>Customization Options</h3>
<p class="start-xs">
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.
<br />
Example
</p>
<pre>
/api/qr/test?fg=ff0000&bg=ffffff&height=200
</pre>
</div>
<div class="col-sm-6 col-xs-12">
<h3>Control Characters</h3>
<p class="start-xs">
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.
</p>
<p>
Visit <a href="/nonprinting.html" class="text-link anim icon-chevron">NonPrinting</a>
</p>
</div>
</div>
<a name="bulk"></a><br />
<div class="help-entry row center-xs top-xs">
<div class="col-xs-12">
<h2><a href="#bulk">§5</a> Bulk Barcode Generation</h2>
<p class="center-xs">
Some users need to generate a lot of barcodes.
<br />
For this we provide two different tools.
</p>
</div>
<div class="col-sm-6 col-xs-12">
<h3>Bulk Generator</h3>
<p class="start-xs">
Users wishing to generate a large number of barcodes may wish to use the Bulk Barcode
generator. This utility will allow the upload of a CSV containing the barcode requests, and will
return a ZIP file containing each of the barcodes.
</p>
<p>
Visit <a href="/bulk.html" class="text-link anim icon-chevron">Bulk Generator</a>
</p>
</div>
<div class="col-sm-6 col-xs-12">
<h3>Multis Utility</h3>
<p class="start-xs">
Some users may wish to generate a large number of barcodes with one request - a basic
JavaScript utility is provided at /multi.html which will generate as many images as requested then
prepare the file to be printed.
</p>
<p>
Visit <a href="/multi.html" class="text-link anim icon-chevron">Multi Generator</a>
</p>
</div>
</div>
<a name="headers"></a><br />
<div class="help-entry row center-xs top-xs">
<div class="col-xs-12">
<h2><a href="#headers">§6</a> Response Headers</h2>
<p class="center-xs">
The server makes a number of headers available which describe the result of the request.
</p>
</div>
<div class="col-sm-6 col-xs-12">
<div>
<h3>Barcode Headers</h3>
<p class="start-xs">
The server will add several headers related to the barcode including the type and
encoded contents.
</p>
<pre class="example-code">
$ 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
</pre>
</div>
<div>
<h3>Cache Control</h3>
<p class="start-xs">
In an attempt to minimize the number of requests, barcodes requested outside of the
webapp will have a cache expiration time set.
</p>
<pre class="example-code">
$ 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
</pre>
</div>
<div>
<h3>Rate Limit Headers</h3>
<p class="start-xs">
The server will add several headers related to the rate limiter applied to the
client.
</p>
<pre class="example-code">
$ curl --head https://barcodeapi.org/api/auto/abc123
...
X-RateLimit-Cost: 2
X-RateLimit-Tokens: 2032.40
</pre>
<p class="start-xs">
Should a client become rate limited, requests will result in a 429. Users must wait until new
tokens are generated before additional requests will be served.
</p>
<pre class="example-code">
$ 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.
</pre>
</div>
</div>
<div class="col-sm-6 col-xs-12">
<div>
<h3>API Redirect</h3>
<p class="start-xs">
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.
</p>
<pre class="example-code">
$ curl --head https://barcodeapi.org/abc123
HTTP/1.1 302 Found
...
Location: https://barcodeapi.org/api/auto/abc123
</pre>
</div>
<div>
<h3>Error Headers</h3>
<p class="start-xs">
In the event of a render error, an additional header [<span
class="text-link">X-Error-Message</span>] will be available containing details about the
exception.
</p>
<pre class="example-code">
$ curl --head https://barcodeapi.org/api/8/00000009
HTTP/1.1 409 Conflict
...
X-Error-Message: Expected checksum: 0
</pre>
<p class="start-xs">
Each type of application failure will result in a unique error code.
</p>
<pre class="example-code">
400 EMPTY The request was empty.
400 INVALID Invalid data for selected code type.
403 BLACKLIST The request was rejected.
409 CHECKSUM Expected checksum: 0
429 LIMITED Client is rate limited, try again later.
500 FAILED Failed to render barcode.
503 BUSY Server is busy, please try again.
</pre>
</div>
</div>
</div>
<a name="session"></a><br />
<div class="help-entry row center-xs middle-xs">
<div class="col-xs-12">
<h2><a href="#session">§7</a> User Session Info</h2>
<p class="start-xs">
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.
<br />
<br />
To view the details of your current session, visit <a href="/session.html"
class="text-link anim icon-chevron">Session Info</a>
</p>
</div>
</div>
<a name="support"></a><br />
<div class="help-entry row center-xs middle-xs">
<div class="col-xs-12">
<h2><a href="#support">§8</a> Technical Support</h2>
<p class="center-xs">
Did we miss something?
<br />
Please send us an email.
<br />
We will respond as soon as possible.
<br />
<br />
<a href="mailto:[email protected]" class="text-link">[email protected]</a>
</p>
</div>
</div>
</div>
</body>
</html>