Use cURL with the LEADTOOLS Cloud Service

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

cURL

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.

Required Knowledge

Be sure to review the following sites for information about LEADTOOLS Cloud Services API.

Application ID and Password

Create an Account with LEADTOOLS Hosted Cloud Services to obtain both Application ID and Password strings.

Service Plans

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.

Ensure that cURL is Installed on the Machine

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
To see the version enter:
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.

Convert Application ID and Application Password to Encoded Base64

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"

Service Authorization Base64 String

The composite string ApplicationID:ApplicationPassword representing both the ID and Password for the registered application. This composite string will be refered to as the Service Authorization Base64 String.

Extract Text

Upload a File and Return a 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/ExtractText?firstPage=1&lastPage=-1&fileurl=http://demo.leadtools.com/images/cloud_samples/ocr1-4.tif"

Query Extracted Text from GUID

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>"

Extract Barcode

Upload a File and Return a 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"

Query Extracted Barcode from GUID

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>"

Extract All Barcodes

Upload a File and Return a 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"

Query Extracted Barcodes from GUID

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>"

Extract Check

Upload a File and return a 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"

Query Extracted Check from GUID

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>"

Extract Business Card

Upload a File and return a 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"

Query Extracted Business Card from GUID

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>"

Extract AAMVAID

Upload a File and return a 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"

Query Extracted Business Card from GUID

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>"

Convert a File

Upload a File and Return a 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"

Query Converted File from GUID

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>"

Convert Redact a File

Upload a File and Return a 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)"

Query Converted Redacted File from GUID

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>"

Convert and Split a File with Barcodes

Upload a File and Return a 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"

Query Converted File from GUID

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>"

Upload a File

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"

Delete a File

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>"

Check Remaining Pages

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"

Wrap-up

This tutorial showed how to use cURL with the LEADTOOLS Cloud Services API.

See Also

Help Version 22.0.2024.3.20
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.


Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.