Python Client SDK Generated by Speakeasy
Project description
Python SDK for the Unstructured API
This is a Python client for the Unstructured API.
SDK Installation
pip install unstructured-client
Usage
Only the files
parameter is required. See the general partition page for all available parameters.
from unstructured_client import UnstructuredClient
from unstructured_client.models import shared
# Note - in an upcoming release, the Security object is removed
# You'll pass the api key directly
s = UnstructuredClient(
security=shared.Security(
api_key_auth="YOUR_API_KEY",
),
)
filename = "sample-docs/layout-parser-paper.pdf"
with open(filename, "rb") as f:
req = shared.PartitionParameters(
files=shared.PartitionParametersFiles(
content=f.read(),
files=filename,
)
)
res = s.general.partition(req)
print(res.elements[0])
# {
# 'type': 'Title',
# 'element_id': '015301d4f56aa4b20ec10ac889d2343f',
# 'metadata': {'filename': 'layout-parser-paper.pdf', 'filetype': 'application/pdf', 'page_number': 1},
# 'text': 'LayoutParser: A Unified Toolkit for Deep Learning Based Document Image Analysis'
# }
Change the base URL
If you are self hosting the API, or developing locally, you can change the server URL when setting up the client.
s = UnstructuredClient()
# Using a local server
s.general.sdk_configuration.server_url = "http://localhost:8000"
# Using your own server
s.general.sdk_configuration.server_url = "https://your-server"
SDK Example Usage
import unstructured_client
from unstructured_client.models import shared
s = unstructured_client.UnstructuredClient(
security=shared.Security(
api_key_auth="YOUR_API_KEY",
),
)
req = shared.PartitionParameters(
coordinates=False,
encoding='utf-8',
files=shared.PartitionParametersFiles(
content='distinctio'.encode(),
files='quibusdam',
),
gz_uncompressed_content_type='application/pdf',
hi_res_model_name='yolox',
include_page_breaks=False,
ocr_languages=[
'eng',
],
output_format='application/json',
pdf_infer_table_structure=False,
skip_infer_table_types=[
'pdf',
],
strategy='hi_res',
xml_keep_tags=False,
)
res = s.general.partition(req)
if res.elements is not None:
# handle response
Available Resources and Operations
general
- partition - Pipeline 1
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
returned response object will have a Next
method that can be called to pull down the next group of results. If the
return value of Next
is None
, then there are no more pages to be fetched.
Here's an example of one such pagination call:
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!
SDK Created by Speakeasy
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for unstructured-client-0.6.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef9ae38af3ea0e67745d58d343a96d8426728694990e60d40cbb26d4da4a88b8 |
|
MD5 | 67067dc79502d34d09ee59f2e142c111 |
|
BLAKE2b-256 | 374e2f2cb98057c2f59c2c5c1a61f372e04fe014b86025dfe5a8412837e99772 |
Hashes for unstructured_client-0.6.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab1e66c38c675aa6728e515050ead020fbc1fccacb200bea1ab760910d8cf78d |
|
MD5 | d693311e5363999b15357dfe02d2bc11 |
|
BLAKE2b-256 | a5875ebdd042b87c8918b56ecfd911abac98dbe4e8dab3b910691a96d9495596 |