Making Requests

The Unstructured API takes multipart form requests. There are currently two types of requests one can make with the Unstructured4s client:

partition

The partition request is used to send one file to be partitioned by Unstructured.io. The request takes three parameters, only one of which does not have a default value:

  • file - The file to be partitioned, of type UnstructuredFile, just an opaque type for java.io.File
  • request - Unstructured4sRequestFields The request fields to be sent to Unstructured.io. These can be of two types:
    • GeneralRequestFields
    • HiResRequestFields
  • customHeaders - List[Header] - A list of custom sttp headers to be sent with the request. These will override any default headers including the unstructured-api-key header.

A hopefully sensible default with all necessary parameters for each is provided in api client.


GeneralRequestFields

sourceoutputFormat: OutputFormat = OutputFormat.Json,
xmlKeepTags: Boolean = false,
coordinates: Boolean = false,
encoding: Encoding = `UTF-8`,
skipInferTableTypes: Option[Vector[String]] = None,
ocrLanguages: Option[Seq[String]] = None,
includePageBreaks: Boolean = false,
ocrStrategy: OCRStrategy = OCRStrategy.Auto

HiResRequestFields

sourceoutputFormat: OutputFormat = OutputFormat.Json,
encoding: Encoding = `UTF-8`,
coordinates: Boolean = false,
pdfInferTableStructure: Boolean = false,
skipInferTableTypes: Option[Vector[String]] = None,
includePageBreaks: Boolean = false,
hiResModelName: Option[HiResModelName] = None,
ocrLanguages: Option[Seq[String]] = None

Then to make the request:

response = client.partition(file) // can provide a request and headers here as well

partitionMultiple

The partitionMultiple request is used to send many files to be partitioned by Unstructured.io. It is the same as the partition request except that

  • files - The files to be partitioned, of type Seq[UnstructuredFile]

Similarly:

response = client.partitionMultiple(files) // can provide a request and headers here as well