Skip to content

Commit 9933e0e

Browse files
authored
Refer to Unstructured docs in readme (#109)
Our docs page will be the source of truth, and the readme can have some general information from the autogenerated sections. Changes: * Link to our docs at the top * Remove the manually created usage snippet and swap out for the autogenerated one. This way, the readme stays up to date while we focus on the docs page. * Bring back autogenerated error handling - this will populate the next time the client regens
1 parent 2797cac commit 9933e0e

File tree

1 file changed

+32
-97
lines changed

1 file changed

+32
-97
lines changed

Diff for: README.md

+32-97
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
<p>Python SDK for the Unstructured API</p>
2424
</h2>
2525

26-
This is a Python client for the [Unstructured API](https://unstructured-io.github.io/unstructured/api.html).
26+
This is a Python client for the [Unstructured API](https://docs.unstructured.io/api-reference/api-services/overview).
27+
28+
Please refer to the [Unstructured docs](https://docs.unstructured.io/api-reference/api-services/sdk) for a full guide to using the client.
2729

2830
<!-- Start SDK Installation [installation] -->
2931
## SDK Installation
@@ -33,77 +35,40 @@ pip install unstructured-client
3335
```
3436
<!-- End SDK Installation [installation] -->
3537

36-
## Usage
37-
Only the `files` parameter is required.
38-
39-
```python
40-
from unstructured_client import UnstructuredClient
41-
from unstructured_client.models import shared
42-
from unstructured_client.models.errors import SDKError
43-
44-
s = UnstructuredClient(api_key_auth="YOUR_API_KEY")
38+
<!-- Start SDK Example Usage [usage] -->
39+
## SDK Example Usage
4540

46-
filename = "_sample_docs/layout-parser-paper-fast.pdf"
41+
### Example
4742

48-
with open(filename, "rb") as f:
49-
# Note that this currently only supports a single file
50-
files=shared.Files(
51-
content=f.read(),
52-
file_name=filename,
53-
)
43+
```python
44+
import unstructured_client
45+
from unstructured_client.models import operations, shared
5446

55-
req = shared.PartitionParameters(
56-
files=files,
57-
# Other partition params
58-
strategy='ocr_only',
59-
languages=["eng"],
47+
s = unstructured_client.UnstructuredClient(
48+
api_key_auth="YOUR_API_KEY",
6049
)
6150

62-
try:
63-
resp = s.general.partition(req)
64-
print(resp.elements[0])
65-
except SDKError as e:
66-
print(e)
67-
```
68-
69-
Result:
70-
71-
```
72-
{
73-
'type': 'UncategorizedText',
74-
'element_id': 'fc550084fda1e008e07a0356894f5816',
75-
'metadata': {
76-
'filename': 'layout-parser-paper-fast.pdf',
77-
'filetype': 'application/pdf',
78-
'languages': ['eng'],
79-
'page_number': 1
80-
}
81-
}
82-
```
83-
84-
### UnstructuredClient
85-
86-
#### Change the base URL
8751

88-
If you are self hosting the API, or developing locally, you can change the server URL when setting up the client.
52+
res = s.general.partition(request=operations.PartitionRequest(
53+
partition_parameters=shared.PartitionParameters(
54+
files=shared.Files(
55+
content='0x2cC94b2FEF'.encode(),
56+
file_name='your_file_here',
57+
),
58+
strategy=shared.Strategy.AUTO,
59+
),
60+
))
8961

90-
```python
91-
# Using a local server
92-
s = unstructured_client.UnstructuredClient(
93-
server_url="http://localhost:8000",
94-
api_key_auth=api_key,
95-
)
62+
if res.elements is not None:
63+
# handle response
64+
pass
9665

97-
# Using your own server
98-
s = unstructured_client.UnstructuredClient(
99-
server_url="https://your-server",
100-
api_key_auth=api_key,
101-
)
10266
```
67+
<!-- End SDK Example Usage [usage] -->
10368

104-
### PartitionParameters
69+
Refer to the [API parameters page](https://docs.unstructured.io/api-reference/api-services/api-parameters) for all available parameters.
10570

106-
See the [general partition](/docs/models/shared/partitionparameters.md) page for all available parameters. 
71+
### Configuration
10772

10873
#### Splitting PDF by pages
10974

@@ -122,10 +87,8 @@ req = shared.PartitionParameters(
12287
split_pdf_concurrency_level=8
12388
)
12489
```
125-
<!-- No SDK Available Operations -->
126-
<!-- No Pagination -->
127-
<!-- No Error Handling -->
128-
<!-- No Server Selection -->
90+
<!-- Start Retries -->
91+
<!-- End Retries -->
12992

13093
<!-- Start Custom HTTP Client [http-client] -->
13194
## Custom HTTP Client
@@ -143,40 +106,12 @@ s = unstructured_client.UnstructuredClient(client=http_client)
143106
```
144107
<!-- End Custom HTTP Client [http-client] -->
145108

146-
<!-- No Retries -->
109+
<!-- No SDK Available Operations -->
110+
<!-- No Pagination -->
111+
<!-- No Error Handling -->
112+
<!-- No Server Selection -->
147113
<!-- No Authentication -->
148114

149-
<!-- Start SDK Example Usage [usage] -->
150-
## SDK Example Usage
151-
152-
### Example
153-
154-
```python
155-
import unstructured_client
156-
from unstructured_client.models import operations, shared
157-
158-
s = unstructured_client.UnstructuredClient(
159-
api_key_auth="YOUR_API_KEY",
160-
)
161-
162-
163-
res = s.general.partition(request=operations.PartitionRequest(
164-
partition_parameters=shared.PartitionParameters(
165-
files=shared.Files(
166-
content='0x2cC94b2FEF'.encode(),
167-
file_name='your_file_here',
168-
),
169-
strategy=shared.Strategy.AUTO,
170-
),
171-
))
172-
173-
if res.elements is not None:
174-
# handle response
175-
pass
176-
177-
```
178-
<!-- End SDK Example Usage [usage] -->
179-
180115
<!-- Placeholder for Future Speakeasy SDK Sections -->
181116

182117
### Maturity

0 commit comments

Comments
 (0)