This tutorial shows how to use cURL with the LEADTOOLS Cloud Services.
Overview | |
---|---|
Summary | This tutorial covers how to use cURL with the LEADTOOLS Cloud Services in the Command Prompt |
Completion Time | 30 minutes |
Platform | LEADTOOLS Cloud Services API |
Development License | Download LEADTOOLS |
A command-line tool to transfer data using URL syntax. In the context of this tutorial, the cURL tool is used to access LEADTOOLS Cloud Services.
Be sure to review the following sites for information about LEADTOOLS Cloud Services API.
Create an Account with LEADTOOLS Hosted Cloud Services to obtain both Application ID and Password strings.
LEADTOOLS Service Plan offerings:
Service Plan | Description |
---|---|
Free Trial | Free Evaluation |
Page Packages | Prepaid Page Packs |
Subscriptions | Prepaid Monthly Processed Pages |
To further explore the offerings, refer to the LEADTOOLS Hosted Cloud Services page.
To obtain the necessary Application ID and Application Password, refer to Create an Account and Application with the LEADTOOLS Hosted Cloud Services.
Most versions of Windows 10 and 11 will have cURL installed by default. Ensure your machine has cURL installed by opening the Command Prompt and running this command:
where curl
curl --version
If these commands return any errors, the machine likely does not have cURL installed. Go to cURL's download page and install the version for your platform.
Encode your Application ID and Password to Base64 format which can be done online through sites such as: base64encode.org or from your own tool.
The format of the input string before Base64 conversion should be: ApplicationID:ApplicationPassword
. Where ApplicationID
and ApplicationPassword
are strings obtained from the LEADTOOLS Hosted Cloud Services portal when registering your application.
When the option "Perform URL-safe encoding" is checked before encoding the string on the base64encode.org page, some characters are converted with alternate values. A character Base64 renders /
, =
, and others with alternate characters and depending on the application ID and password, this could make the Base64 conversion string as unauthorized on the LEADTOOLS Cloud Service. To determine whether to use this option, add the -i
switch in the cURL command prompt. The service's response message will then include a protocol header in the output with the authorization status.
As an example, set ApplicationID
= TestApp1
and ApplicationPassword
= 1234567890
. Then, the composite string ApplicationID:ApplicationPassword
is TestApp1:1234567890
. Use this composite string as the input string in the Base64 conversion tool. After the conversion, using the "Perform URL-safe encoding", it returns VGVzdEFwcDE6MTIzNDU2Nzg5MA
.
Change this example command-line:
curl -X POST -i -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Recognition/ExtractText?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/images/cloud_samples/ocr1-4.tif"
By replacing <ApplicationID:ApplicationPassword>
with VGVzdEFwcDE6MTIzNDU2Nzg5MA
:
curl -X POST -i -d "" -H "Authorization: Basic VGVzdEFwcDE6MTIzNDU2Nzg5MA=" "https://azure.leadtools.com/api/Recognition/ExtractText?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/images/cloud_samples/ocr1-4.tif"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Recognition/ExtractText?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/images/cloud_samples/ocr1-4.tif"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Recognition/ExtractBarcode?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/images/tiff/barcode1.tif"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Recognition/ExtractAllBarcodes?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/images/tiff/barcode1.tif"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Recognition/ExtractCheck?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/JavaScript/BankCheckReader/Resources/Samples/BankCheck.jpg"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Recognition/ExtractBusinessCard?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/images/cloud_samples/business_card_sample.jpg"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Recognition/ExtractAAMVAID?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/images/lcs/aamva.png"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Conversion/Convert?firstPage=1&lastPage=-1&fileurl=https://demo.leadtools.com/images/pdf/leadtools.pdf&format=3"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Conversion/ConvertRedact?firstPage=1&lastPage=-1&fileurl=https://demo.leadtools.com/images/pdf/leadtools.pdf&format=3&pattern=(LEAD|LEADTOOLS)"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
To upload a file to the Cloud Services and return the GUID enter the following in the Command Prompt:
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Conversion/ConvertBarcodeSplit?firstPage=1&lastPage=-1&fileurl=https://demo.leadtools.com/images/lcs/barcode_split.tif&format=3"
Replace the <Returned GUID>
with the GUID string response from the previous section.
curl -X GET -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/Query?id=<Returned GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
This will return a GUID for the uploaded file.
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/UploadFile?ImageUrl=https://demo.leadtools.com/images/pdf/leadtools.pdf"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
Replace the <Valid GUID>
with a GUID string response from a previous command.
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword>=" "https://azure.leadtools.com/api/DeleteRequest?id=<Valid GUID>"
Replace the <ApplicationID:ApplicationPassword>
with the Service Authorization Base64 String .
curl -X POST -d "" -H "Authorization: Basic <ApplicationID:ApplicationPassword> =" "https://azure.leadtools.com/api/CheckPages"
This tutorial showed how to use cURL with the LEADTOOLS Cloud Services API.