-
Notifications
You must be signed in to change notification settings - Fork 12
/
api.html
executable file
·409 lines (368 loc) · 12.3 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
<html>
<!--
api.html
BarcodeAPI.org, 2017-2024
-->
<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-xs-10">
<h2>BarcodeAPI.org</h2>
<p class="center-xs">
The heart of our system is an intuitive barcode generation API that prioritizes ease of use and
flexibility. With a straightforward HTTP endpoint, you can quickly integrate our barcodes into
virtually any application, requiring nothing more than an internet connection.
<br />
<br />
Our API supports a wide array of barcode formats and offers extensive customization options to meet
your specific needs. To ensure fair usage and reliable performance, we implement rate limits based
on the complexity of your requests.
<br />
<br />
Join the thousands who rely on BarcodeAPI.org for their barcode generation needs.
</p>
</div>
</div>
<a name="tokens"></a><br />
<div class="help-entry row center-xs middle-xs">
<div class="col-xs-11">
<h2><a href="#tokens">§1</a> Tokens and Rate Limits</h2>
<p class="center-xs">
To ensure that we are able to provide the best service for all users we have implemented Rate
Limiting and tiered pricing plans for our power users.
<br />
<br />
Our FREE tier should be sufficient for basic use, however some users may not find this limit
sufficient for their needs. Please visit <a href="/limits.html" class="text-link">Rate Limits</a>
for additional details on our pricing plans.
</p>
<br />
</div>
<div class="col-xs-6">
<b>Requesting a Token</b>
<p>
API tokens are granted to our paying customers and are used when demand exceedes our FREE tier.
<br />
<br />
To upgrade your account, visit <a href="/contracts.html" class="text-link">Usage Contracts</a>
</p>
</div>
<div class="col-xs-6">
<b>Using A Token</b>
<p>
If you have been issued an API token, it should be attached to each request as an Authorization
header.
<pre>
Authorization: Token=xxxxxxxxxxxx
</pre>
</p>
</div>
</div>
<a name="usage"></a><br />
<div class="help-entry row center-xs middle-xs">
<div class="col-xs-12">
<h2><a href="#usage">§2</a> Basic API Usage</h2>
<p class="center-xs">
The server will generate a barcode for nearly any content passed to the API
endpoint.
<br />
<br />
Based on a RESTful HTTP server, requests can be made using a web browser, on the command
line, or a number of other methods depending on the needs of your application.
</p>
<br />
</div>
<div class="col-sm-6 col-xs-12">
<div>
<span class="example-code-title">curl</span>
<pre class="example-code">
curl https://barcodeapi.org/api/A_Barcode > test.png
</pre>
</div>
<div>
<span class="example-code-title">wget</span>
<pre class="example-code">
wget -o test.png https://barcodeapi.org/api/A_Barcode
</pre>
</div>
<div>
<span class="example-code-title">PowerShell</span>
<pre class="example-code">
Invoke-WebRequest `
https://barcodeapi.org/api/auto/test -OutFile test.png
</pre>
</div>
<div>
<span class="example-code-title">Python</span>
<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 class="col-sm-6 col-xs-12">
<div>
<span class="example-code-title">HTML</span>
<pre class="example-code">
<img src="https://barcodeapi.org/api/auto/test" />
</pre>
</div>
<div>
<span class="example-code-title">JavaScript</span>
<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');
document.getElementById("token_count").innerHTML = tokens;
response.blob().then(blob => {
var imgBlob = URL.createObjectURL(blob);
document.getElementById('barcode_image').src = imgBlob;
});
});
</pre>
</div>
</div>
</div>
<a name="formats"></a><br />
<div class="help-entry row center-xs middle-xs">
<div class="col-xs-12">
<h2><a href="#formats">§3</a> Barcode Formats</h2>
<p class="center-xs">
A detailed list of barcode formats available to be rendered by this server can
be viewed at the <a class="text-link" href="/types.html">Barcode Types</a> page. This
page is a graphical representation of the [/types] API endpoint.
<br />
<br />
Each barcode type will provide it's token cost for both basic and custom barcodes
generated in the given format.
</p>
</div>
<div class="col-xs-12">
<h3>Type Selection</h3>
<p class="center-xs">
The API offers two types of barcode type selection, automatic or manual;
users of the web-based interface might prefer the barcode type be selected based on what
they type, while direct callers of the API might want to have control over which barcode
format they will receive back from the server.
</p>
<br />
</div>
<div class="col-sm-6 col-xs-12">
<b>Manual Type Selection</b>
<p class="start-xs">
A specific barcode type may be requested by using the type string in
the request URL.
</p>
<pre class="example-code">
https://barcodeapi.org/api/128/abc123
https://barcodeapi.org/api/qr/abc123
</pre>
</div>
<div class="col-sm-6 col-xs-12">
<b>Automatic Type Detection</b>
<p class="start-xs">
When calling the API endpoint without specifying an explicit code
type the server will make its best judgment as to which code type will be best
suited for the supplied data.
</p>
<pre class="example-code">
https://barcodeapi.org/api/abc123
https://barcodeapi.org/api/auto/abc123
</pre>
</div>
</div>
<a name="custom"></a><br />
<div class="help-entry row center-xs middle-xs">
<div class="col-xs-12">
<h2><a href="#custom">§4</a> Barcode Customization</h2>
<p class="center-xs">
Each barcode type provides a number of customization options that may be passed along with the
request. The supported options for each barcode can be viewed on the associated <a
href="types.html">Types</a> page.
</p>
</div>
<div class="col-sm-5 col-xs-12">
<h3>Options</h3>
<p class="center-xs">
Barcode options are simply added to each request as a GET parameter.
</p>
<pre>
/api/dm/test?fg=ff0000
</pre>
</div>
<div class="col-sm-5 col-xs-12">
<h3>Control Characters</h3>
<p class="center-xs">
Some barcodes support the encoding of NonPrinting ASCII characters.
<br />
<br />
Visit <a href="/nonprinting.html" class="text-link">NonPrinting</a>
</p>
</div>
</div>
<a name="bulk"></a><br />
<div class="help-entry row center-xs middle-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="center-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.
<br />
<br />
Visit <a href="/bulk.html" class="text-link">Bulk Generator</a>
</p>
</div>
<div class="col-sm-6 col-xs-12">
<h3>Multis Utility</h3>
<p class="center-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.
<br />
<br />
Visit <a href="/multi.html" class="text-link">Multi Generator</a>
</p>
</div>
</div>
<a name="headers"></a><br />
<div class="help-entry row center-xs middle-xs">
<div class="col-xs-12">
<h2><a href="#headers">§6</a> Server Headers</h2>
<p class="center-xs">
The server makes a number of headers available.
</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>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
...
Location: https://barcodeapi.org/api/auto/abc123
</pre>
</div>
</div>
<div class="col-sm-6 col-xs-12">
<div>
<h3>Rate Limit Headers</h3>
<p class="start-xs">
The server will add several headers related to the rate limit.
</p>
<pre class="example-code">
$ curl --head https://barcodeapi.org/api/auto/abc123
...
X-RateLimit-Cost: 2
X-RateLimit-Tokens: 2032.40
</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">
Cache-Control: max-age=86400, public
</pre>
</div>
<div>
<h3>Error Headers</h3>
<p class="start-xs">
In the event of a render error, an additional header will be available
containing details about the exception.
</p>
<pre class="example-code">
X-Error-Message: (exception.toString())
</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</h2>
<p class="center-xs">
Users of the web interface are assigned a session token for basic history tracking.
<br />
<br />
To view the details of your current session, visit the <a href="/session/">/session/</a> endpoint.
</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>