1. Kotlin
  2. AI Scanning APIs

Kotlin

AI Scanning APIs

The Vision SDK supports OCR via cloud-based APIs to extract structured data from various documents like shipping labels, BOLs (Bill of Lading), and item labels. This mode leverages RESTful APIs and requires a valid API key or token and environment to be configured before making any calls. All you need to do is, capture the image of a document and then send it to relevant API.

📌 You can obtain your API key and environment details from cloud.packagex.io.

Learn how to capture an image using Vision SDK.

☁️ Cloud-based APIs

The Vision SDK cloud OCR supports the following document types:

  • Shipping Labels (SL)
  • Bill of Lading (BOL)
  • Item Label (IL)

To access these cloud services, you need to create an instance of ApiManager. It has both, synchronous and asynchronous, methods that you can call to extract information from the supported document types.

Let's get deep into our cloud-based APIs.

📦 Shipping Labels ( SL )

Extracts structured data such as tracking numbers, courier names, addresses, etc. More details Here

To get logistic information from a shipping label, call the following method:

        suspend fun callShippingLabelAPI() {
  val stringResponse = apiManager.shippingLabelApiCallSync(
    apiKey: String? = null,
    token: String? = null,
    bitmap: Bitmap,
    shouldResizeImage: Boolean = true,
    barcodeList: List<String>,
    locationId: String? = null,
    recipient: Map<String, Any>? = null,
    sender: Map<String, Any>? = null,
    options: Map<String, Any> = emptyMap(),
    metadata: Map<String, Any> = emptyMap()
  )
  val jsonResponse = JSONObject(stringResponse)
}

      

🔍 Parameter Breakdown

Parameter Description
apiKey (Optional) API key for authenticating the request.
token (Optional) Bearer token for authenticated sessions (used as an alternative to apiKey).
bitmap The captured Bitmap of the shipping label to be scanned.
shouldResizeImage (Optional) Boolean flag to control if the image should be resized before upload. Default is true.
barcodeList A list of string barcode values (if detected beforehand) to include in the OCR request.
locationId (Optional) Location identifier where the scan is being performed. Leave null if not applicable.
recipient (Optional)
sender (Optional)
options (Optional) Additional settings to control scanning behavior. You can learn more here: Shipping Label Inference Options.
metaData (Optional) A dictionary of key-value pairs to associate custom metadata with the scan.

📄 Bill of Lading ( BOL )

Detects and extracts BOL-specific fields such as carrier information, consignee details, and reference numbers. More details Here

To get logistic information from a bill of lading, call the following method:

        suspend fun callBillOfLadingAPI() {
  val stringResponse = apiManager.billOfLadingApiCallSync(
    apiKey: String? = null,
    token: String? = null,
    bitmap: Bitmap,
    shouldResizeImage: Boolean = true,
    barcodeList: List<String>,
    locationId: String? = null,
    options: Map<String, Any> = emptyMap(),
  )
  val jsonResponse = JSONObject(stringResponse)
}

      

🔍 Parameter Breakdown

Parameter Description
apiKey (Optional) API key for authenticating the request.
token (Optional) Bearer token for authenticated sessions (used as an alternative to apiKey).
bitmap The captured Bitmap of the bill of lading to be scanned.
shouldResizeImage (Optional) Boolean flag to control if the image should be resized before upload. Default is true.
barcodeList A list of string barcode values (if detected beforehand) to include in the OCR request.
locationId (Optional) Location identifier where the scan is being performed. Leave null if not applicable.
options (Optional) Additional settings to control scanning behavior. You can learn more here: Bill of Lading Inference Options.

🏷️ Item Labels

Recognizes SKU, GTIN, price, brand, and other item-level information printed on labels. More details Here

To get logistic information from an item label, call the following method:

        suspend fun callItemLabelAPI() {
  val stringResponse = apiManager.itemLabelApiCallSync(
    apiKey: String? = null,
    token: String? = null,
    bitmap: Bitmap,
    shouldResizeImage: Boolean = true,
  )
  val jsonResponse = JSONObject(stringResponse)
}

      

🔍 Parameter Breakdown

Parameter Description
apiKey (Optional) API key for authenticating the request.
token (Optional) Bearer token for authenticated sessions (used as an alternative to apiKey).
bitmap The captured Bitmap of the item label to be scanned.
shouldResizeImage (Optional) Boolean flag to control if the image should be resized before upload. Default is true.