curl -k https://reader.datasymbol.com/api/job \
-X POST \
-F "key=0CWWQhS9wo1f7AwlvVoA" \
-F "source_file=@/home/mike/Desktop/Images/linear-4.jpg" \
-F "target=barcode-reader" \
-F "out_format=xml" \
-F "lnum=2"
var request = require('request');
var fs = require('fs');
var req = request.post({url:"https://reader.datasymbol.com/api/job"}, function (err, resp, body) {
if (err) {
console.error('Unable to start conversion job', err);
} else {
//console.log(JSON.parse(body));
var respJSON = JSON.parse(body);
console.log(respJSON.error.code + ": " + respJSON.error.message);
console.log("Job ID: " + respJSON.job.id);
}
});
var form = req.form();
form.append("target", "barcode-reader");
form.append("key", "0CWWQhS9wo1f7AwlvVoA");
form.append("out_format", "json");
form.append("source_file", fs.createReadStream('/home/mike/Desktop/Images/linear-4.jpg'));
const uint ST_DATAMATRIX = 0x10000000;
const uint ST_PDF417 = 0x20000000;
//...
const string urlJob = "https://reader.datasymbol.com/api/job";
const string apiKey = "0CWWQhS9wo1f7AwlvVoA";
const string fileName = "c:\\tmp\\linear-4.jpg";
barcodeTypes = ST_PDF417|ST_DATAMATRIX;
//send job
string xmlString = Upload(apiKey, urlJob, fileName, barcodeTypes).Result;
//xml result
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString);
static async Task Upload(string apiKey, string url, string sourceFile, uint barcodeTypes)
{
using (HttpClientHandler handler = new HttpClientHandler())
using (HttpClient client = new HttpClient(handler))
{
var request = new MultipartFormDataContent();
request.Add(new StringContent(apiKey), "key");
request.Add(new StringContent("barcode-reader"), "target");
request.Add(new StringContent("xml"), "out_format");
//request.Add(new StringContent("5"), "lnum");
request.Add(new StringContent(barcodeTypes.ToString()), "types");
request.Add(new StreamContent(File.OpenRead(sourceFile)), "source_file", new FileInfo(sourceFile).Name);
using (HttpResponseMessage response = await client.PostAsync(url, request).ConfigureAwait(false))
using (HttpContent content = response.Content)
{
string data = await content.ReadAsStringAsync();
return data;
}
}
}
<?php
$apiUrl = 'https://reader.datasymbol.com/api/job';
$imagePath = '/home/mike/Desktop/Images/linear-4.jpg';
$apiKey = '0CWWQhS9wo1f7AwlvVoA';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
$post_array = array(
'key'=>$apiKey,
'target'=>'barcode-reader',
'source_file'=>curl_file_create($imagePath),
//'source_file'=>"@$imagePath",
//'out_format'=>'json',
'lnum'=>7,
'types'=>(0x00000008|0x00000001), //find only EAN-13 and Code-128
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
$data = curl_exec($ch);
$header_str = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
header("Content-type: " . $header_str);
echo $data;
?>
<BarcodeReader version='1.1'>
<error code='1001'>Info. in queue</error>
<job id='216288' key='0CWWQhS9wo1f7AwlvVoA' queue='1' start_time='2016-12-05-10-09-49' stop_time='' />
<source_file name='linear-4.jpg' />
</BarcodeReader>
{
version: '1.1',
error: { code: 1001, message: 'Info. in queue' },
job:
{ id: 216288,
key: '0CWWQhS9wo1f7AwlvVoA',
queue: 1,
start_time: '2016-12-05-10-15-54',
stop_time: '' },
source_file: { name: 'linear-4.jpg' }
}
curl -k https://reader.datasymbol.com/api/job \
-X POST \
-F "id=216288" \
-F "key=0CWWQhS9wo1f7AwlvVoA"
var request = require('request');
apiKey = "0CWWQhS9wo1f7AwlvVoA";
jobID = 216288;
var req = request.get({url:"https://reader.datasymbol.com/api/"+apiKey+"/"+jobID+"/json"}, function (err, resp, body) {
if (err) {
console.error('Unable to start conversion job', err);
} else {
var respJSON = JSON.parse(body);
console.log(respJSON);
if (respJSON.error.code == 0) {
for (i=0; i < respJSON.result.barcodes.length; ++i) {
console.log(respJSON.result.barcodes[i].text);
}
}
}
});
int jobID = 216288;
string endpoint = urlBase + apiKey + "/" + jobID.ToString() + "/xml";
string xmlString = Query(apiKey, endpoint).Result;
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString);
static async Task Query(string key, string url)
{
using (HttpClientHandler handler = new HttpClientHandler())
using (HttpClient client = new HttpClient())
using (HttpResponseMessage response = await client.GetAsync(url).ConfigureAwait(continueOnCapturedContext: false))
using (HttpContent content = response.Content)
{
string data = await content.ReadAsStringAsync();
return data;
}
}
<?php
$apiBase = 'https://reader.datasymbol.com/api/';
$apiKey = '0CWWQhS9wo1f7AwlvVoA';
$jobID = 216288;
$xml = file_get_contents($apiBase . $apiKey. "/" . $jobID . "/xml");
header('Content-Type: text/xml');
print $xml;
?>
<BarcodeReader version='1.1'>
<error code='0'>Ok</error>
<job id='216288' key='0CWWQhS9wo1f7AwlvVoA' queue='-1' start_time='2016-12-05-10-09-49' stop_time='2016-12-05-10-09-49' />
<source_file name='linear-4.jpg' />
<credit_cost cost='5' credit='1108925' />
<result>
<barcodes qty='4'>
<barcode type='4' page='1'>
<text><![CDATA[BarcodeTools.comt]]></text>
<data></data>
<coordinates x1='370' y1='356' x2='937' y2='327' x3='365' y3='234' x4='932' y4='205' />
</barcode>
<barcode type='4' page='1'>
<text><![CDATA[9781779100290]]></text>
<data></data>
<coordinates x1='145' y1='622' x2='403' y2='722' x3='218' y3='433' x4='476' y4='533' />
</barcode>
</barcodes>
</result>
</BarcodeReader>
{
"version":"1.1",
"error":{"code":0, "message":"Ok"},
"job":{"id":216288, "key":"0CWWQhS9wo1f7AwlvVoA", "queue":-1, "start_time":"2016-12-05-10-09-49", "stop_time":"2016-12-05-10-09-49"},
"source_file":{"name":"linear-4.jpg"},
"credit_cost":{"cost":5, "credit":1108920},
"result":
{
"barcodes":[
{"type":1, "page":1, "text":"BarcodeTools.comt", "data":"", "coordinates":[{"x":370, "y":356}, {"x":937, "y":327}, {"x":365, "y":234}, {"x":932, "y":205}]},
{"type":8, "page":1, "text":"9781779100290", "data":"", "coordinates":[{"x":145, "y":622}, {"x":403, "y":722}, {"x":218, "y":433}, {"x":476, "y":533}]}
]
}
}
Error Code | Description |
0 | Ok |
1 | incorrect key |
2 | cannot connect with DB |
3 | cannot find the key |
4 | key expired |
5 | not enought key credit |
6 | no source file |
7 | file size exceed limit |
8 | cannot move uploaded file |
9 | upload error |
10 | invalid file type |
11 | cannot add job |
12 | cannot get job |
13 | error |
14 | job id not found |
15 | incorrect job id |
16 | job id or key not found |
17 | file size exceeds server limit |
18 | wrong target |
19 | cannot find result |
20 | incorrect file ID |
21 | cannot find file ID |
22 | cannot open file |
23 | cannot read file |
24 | product/plan not found |
101 | processing. error |
102 | processing. cannot load config |
103 | processing. cannot parse config |
104 | processing. cannot load source file |
201 | decoding. cannot set barcode decoder params |
202 | decoding. error during decoding |
203 | decoding. cannot parse params |
1001 | info. in queue |
1002 | info. processing |
Parameter | Description |
Service Parameters | |
key | your API Key |
id | Job ID |
out_format | Required format of a response. Possible values: "xml", "json" Default value: "xml" |
del_result | Delete result after "Get Result Response". Possible values: "yes", "no" Default value: "no" |
page | Page for decoding (if multipage file). Default value: 0 (all pages) |
Barcode Decoder Parameters | |
types | types of barcodes should be decoded |
frameTime | Time to decode 1 frame in milliseconds. Default value: "0"(unlimited) |
inverse | what barcodes should be decoded (darks on light or lights on dark). Possible values: 0-dark, 1-light, 2-both Default value: "0" |
lnum | Linear. how many barcodes should be decoded Default value: "1" |
lshowid | Linear. add symbology ID to the barcode text Default value: "0" |
lverifycheck | Linear. verify the optional check digit in barcodes where this check digit is optional Default value: "0" |
lshowcheck | Linear. show the check Default value: "1" |
lshowstst | Linear. show the start/stop characters Default value: "0" |
lcode39ext | Linear. decode Code 39 as Code 39 Extended Default value: "0" |
lupceupca | Linear. convert a UPC-E barcode to UPC-A Default value: "0" |
lspeed | Linear. Decoding speed Possible values: 0-Normal, 1-Fast, 2-Slow Default value: "0" |
lverify | Linear. improves reliability linear barcode reading. Default value: "0" |
pdf417num | PDF417. how many barcodes should be decoded Default value: "1" |
pdf417speed | PDF417. Decoding speed Possible values: 0-Normal, 1-Fast, 2-Slow Default value: "0" |
pdf417symid | PDF417. add symbology ID to the barcode text Default value: "0" |
pdf417micro | PDF417. Finds Micro PDF417 barcodes. Default value: "0" |
pdf417supporteci | PDF417. support ECI (Extended Channel Interpretation). Default value: "0" |
pdf417robust | PDF417. Activates the robust PDF417 decoder mode. This property can help to decode high distorted PDF417 barcodes. Default value: "0" |
dmnum | DataMatrix. how many barcodes should be decoded Default value: "1" |
dmspeed | DataMatrix. Decoding speed Possible values: 0-Normal, 1-Fast, 2-Slow Default value: "0" |
dmsymid | DataMatrix. add symbology ID to the barcode text Default value: "0" |
dmsupporteci | DataMatrix. support ECI (Extended Channel Interpretation). Default value: "0" |
dminverse | DataMatrix. find inverse DataMatrix Default value: "0" |
qrnum | QRCode. how many barcodes should be decoded Default value: "1" |
qrspeed | QRCode. Decoding speed Possible values: 0-Normal, 1-Fast, 2-Slow Default value: "0" |
qrsymid | QRCode. add symbology ID to the barcode text Default value: "0" |
qrmicro | QRCode. Finds Micro QRCode barcodes. Default value: "0" |
aznum | AztecCode. how many barcodes should be decoded Default value: "1" |
azspeed | AztecCode. Decoding speed Possible values: 0-Normal, 1-Fast, 2-Slow Default value: "0" |
azsymid | AztecCode. add symbology ID to the barcode text Default value: "0" |
Value (hexadecimal) | Barcode Type |
0x00000001 | Code 128 |
0x00000002 | Code 39 |
0x00000004 | Interleaved 2/5 |
0x00000008 | EAN-13 |
0x00000010 | EAN-8 |
0x00000020 | Codabar |
0x00000040 | Code 11 |
0x00000080 | UPC-A |
0x00000100 | UPC-E |
0x00000200 | Industrial 2/5 |
0x00000400 | Code 93 |
0x00000800 | DataBar omnidirectional, DataBar Truncated |
0x00001000 | DataBar limited |
0x00002000 | DataBar stacked |
0x00004000 | DataBar Expanded |
0x00008000 | DataBar Expanded stacked |
0x01000000 | unrecognized linear |
0x02000000 | unrecognized PDF417 |
0x04000000 | unrecognized DataMatrix |
0x08000000 | unrecognized QRCode |
0x00100000 | unrecognized AztecCode |
0x10000000 | DataMatrix |
0x20000000 | PDF417 |
0x40000000 | QRCode |
0x80000000 | AztecCode |