This page was recently updated. What do you think about it? Let us know!.
- A Google Cloud account.
- The Google Drive API enabled in the account. Learn how.
-
Within the account, a Google Cloud service account and its related
credentials.jsonkey file or its contents in JSON format. Create a service account. Create credentials for a service account. To ensure maximum compatibility across Unstructured service offerings, you should give the service account key information to Unstructured as a single-line string that contains the contents of the downloaded service account key file (and not the service account key file itself). To print this single-line string without line breaks, suitable for copying, you can run one of the following commands from your Terminal or Command Prompt. In this command, replace<path-to-downloaded-key-file>with the path to thecredentials.jsonkey file that you downloaded by following the preceding instructions.-
For macOS or Linux:
-
For Windows:
-
For macOS or Linux:
- A Google Drive folder.
- Give the service account access to the folder. To do this, share the folder with the service account’s email address. Learn how. Learn more.
-
Get the folder’s ID. This is a part of the URL for your Google Drive folder represented in the following URL as
{folder_id}:https://drive.google.com/drive/folders/{folder-id}.
CLI, Python
-
GOOGLE_DRIVE_FOLDER_ID- The folder ID, represented by--drive-id(CLI) ordrive_id(Python). -
One of the following:
GCP_SERVICE_ACCOUNT_KEY_FILEPATH- The path to thecredentials.jsonkey file, represented by--service-account-key-path(CLI) orservice_account_key_path(Python).GCP_SERVICE_ACCOUNT_KEY_STRING- The contents of thecredentials.jsonkey file as a string, represented by--service-account-key(CLI) orservice_account_key(Python).
To use
--extensions with a comma-separated list (CLI) or extensions with an array of strings (Python) to process files with only those extensions,
do not include the leading dot in the file extensions. For example, use pdf or docx instead of .pdf or .docx.--partition-by-api option (CLI) or partition_by_api (Python) parameter to specify where files are processed:
-
To do local file processing, omit
--partition-by-api(CLI) orpartition_by_api(Python), or explicitly specifypartition_by_api=False(Python). Local file processing does not use an Unstructured API key or API URL, so you can also omit the following, if they appear:--api-key $UNSTRUCTURED_API_KEY(CLI) orapi_key=os.getenv("UNSTRUCTURED_API_KEY")(Python)--partition-endpoint $UNSTRUCTURED_API_URL(CLI) orpartition_endpoint=os.getenv("UNSTRUCTURED_API_URL")(Python)- The environment variables
UNSTRUCTURED_API_KEYandUNSTRUCTURED_API_URL
-
To send files to the Unstructured Partition Endpoint for processing, specify
--partition-by-api(CLI) orpartition_by_api=True(Python). Unstructured also requires an Unstructured API key and API URL, by adding the following:--api-key $UNSTRUCTURED_API_KEY(CLI) orapi_key=os.getenv("UNSTRUCTURED_API_KEY")(Python)--partition-endpoint $UNSTRUCTURED_API_URL(CLI) orpartition_endpoint=os.getenv("UNSTRUCTURED_API_URL")(Python)- The environment variables
UNSTRUCTURED_API_KEYandUNSTRUCTURED_API_URL, representing your API key and API URL, respectively.
You must specify the API URL only if you are not using the default API URL for Unstructured Ingest, for example, if you are using a version of the Unstructured API that is hosted on your own compute infrastructure.The default API URL for Unstructured Ingest ishttps://api.unstructuredapp.io/general/v0/general, which is the API URL for the Unstructured Partition Endpoint.If you do not have an API key, get one now.If the Unstructured API is hosted on your own compute infrastructure, the process for generating Unstructured API keys, and the Unstructured API URL that you use, are different. For details, contact Unstructured Sales at sales@unstructured.io.
Output a key file’s contents as a string
If you need to convert the contents of acredentials.json file into a string, you could use a Python script such as the following.
This script takes the local path to the key file as input and outputs the key file’s contents as a string.
Python

