Skip to content

Commit e06d3e7

Browse files
authored
Platform API operations added to the Unstructured Python SDK (#477)
1 parent e7073f4 commit e06d3e7

File tree

95 files changed

+1912
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1912
-217
lines changed

api-reference/api-services/accessing-unstructured-api.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Choose your preferred method:
1414

1515
The API parameters for all these methods are documented on the [API parameters](/api-reference/api-services/api-parameters) page.
1616

17-
import UseIngestInstead from '/snippets/general-shared-text/use-ingest-instead.mdx';
17+
import UseIngestOrPlatformInstead from '/snippets/general-shared-text/use-ingest-or-platform-instead.mdx';
1818

19-
<UseIngestInstead />
19+
<UseIngestOrPlatformInstead />
2020

2121
If you'd like to try out the Unstructured API interactively by using the Free Unstructured API to process a single file, you can do so by using the [Swagger UI](https://api.unstructured.io/general/docs#/default/pipeline_1_general_v0_general_post).
2222

api-reference/api-services/examples.mdx

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serv
1313

1414
<NoURLForServerlessAPI/>
1515

16-
import UseIngestInstead from '/snippets/general-shared-text/use-ingest-instead.mdx';
16+
import UseIngestOrPlatformInstead from '/snippets/general-shared-text/use-ingest-or-platform-instead.mdx';
1717

1818
### Changing partition strategy for a PDF
1919

@@ -82,7 +82,7 @@ The `hi_res` strategy supports different models, and the default is `layout_v1.1
8282
```
8383
</Accordion>
8484
<Accordion title="POST">
85-
<UseIngestInstead />
85+
<UseIngestOrPlatformInstead />
8686
```bash POST
8787
curl -X 'POST' $UNSTRUCTURED_API_URL \
8888
-H 'accept: application/json' \
@@ -94,7 +94,7 @@ The `hi_res` strategy supports different models, and the default is `layout_v1.1
9494
```
9595
</Accordion>
9696
<Accordion title="Python SDK">
97-
<UseIngestInstead />
97+
<UseIngestOrPlatformInstead />
9898
```python Python
9999
import asyncio
100100
import os
@@ -103,8 +103,7 @@ The `hi_res` strategy supports different models, and the default is `layout_v1.1
103103
from unstructured_client.models import shared
104104

105105
client = unstructured_client.UnstructuredClient(
106-
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY"),
107-
server_url=os.getenv("UNSTRUCTURED_API_URL"),
106+
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")
108107
)
109108

110109
async def call_api(filename, input_dir, output_dir):
@@ -123,7 +122,10 @@ The `hi_res` strategy supports different models, and the default is `layout_v1.1
123122
}
124123

125124
try:
126-
res = await client.general.partition_async(request=req)
125+
res = await client.general.partition_async(
126+
request=req,
127+
server_url=os.getenv("UNSTRUCTURED_API_URL")
128+
)
127129
element_dicts = [element for element in res.elements]
128130
json_elements = json.dumps(element_dicts, indent=2)
129131

@@ -159,7 +161,7 @@ The `hi_res` strategy supports different models, and the default is `layout_v1.1
159161
```
160162
</Accordion>
161163
<Accordion title="JavaScript/TypeScript SDK">
162-
<UseIngestInstead />
164+
<UseIngestOrPlatformInstead />
163165
```typescript TypeScript
164166
import { UnstructuredClient } from "unstructured-client";
165167
import * as fs from "fs";
@@ -300,7 +302,7 @@ For better OCR results, you can specify what languages your document is in using
300302
```
301303
</Accordion>
302304
<Accordion title="POST">
303-
<UseIngestInstead />
305+
<UseIngestOrPlatformInstead />
304306
```bash POST
305307
curl -X 'POST' $UNSTRUCTURED_API_URL \
306308
-H 'accept: application/json' \
@@ -312,7 +314,7 @@ For better OCR results, you can specify what languages your document is in using
312314
```
313315
</Accordion>
314316
<Accordion title="Python SDK">
315-
<UseIngestInstead />
317+
<UseIngestOrPlatformInstead />
316318
```python Python
317319
import asyncio
318320
import os
@@ -321,8 +323,7 @@ For better OCR results, you can specify what languages your document is in using
321323
from unstructured_client.models import shared
322324

323325
client = unstructured_client.UnstructuredClient(
324-
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY"),
325-
server_url=os.getenv("UNSTRUCTURED_API_URL"),
326+
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")
326327
)
327328

328329
async def call_api(filename, input_dir, output_dir):
@@ -341,7 +342,10 @@ For better OCR results, you can specify what languages your document is in using
341342
}
342343

343344
try:
344-
res = await client.general.partition_async(request=req)
345+
res = await client.general.partition_async(
346+
request=req,
347+
server_url=os.getenv("UNSTRUCTURED_API_URL")
348+
)
345349
element_dicts = [element for element in res.elements]
346350
json_elements = json.dumps(element_dicts, indent=2)
347351

@@ -377,7 +381,7 @@ For better OCR results, you can specify what languages your document is in using
377381
```
378382
</Accordion>
379383
<Accordion title="JavaScript/TypeScript SDK">
380-
<UseIngestInstead />
384+
<UseIngestOrPlatformInstead />
381385
```typescript TypeScript
382386
import { UnstructuredClient } from "unstructured-client";
383387
import * as fs from "fs";
@@ -515,7 +519,7 @@ Set the `coordinates` parameter to `true` to add this field to the elements in t
515519
```
516520
</Accordion>
517521
<Accordion title="POST">
518-
<UseIngestInstead />
522+
<UseIngestOrPlatformInstead />
519523
```bash POST
520524
curl -X 'POST' $UNSTRUCTURED_API_URL \
521525
-H 'accept: application/json' \
@@ -527,7 +531,7 @@ Set the `coordinates` parameter to `true` to add this field to the elements in t
527531
```
528532
</Accordion>
529533
<Accordion title="Python SDK">
530-
<UseIngestInstead />
534+
<UseIngestOrPlatformInstead />
531535
```python Python
532536
import asyncio
533537
import os
@@ -536,8 +540,7 @@ Set the `coordinates` parameter to `true` to add this field to the elements in t
536540
from unstructured_client.models import shared
537541

538542
client = unstructured_client.UnstructuredClient(
539-
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY"),
540-
server_url=os.getenv("UNSTRUCTURED_API_URL"),
543+
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")
541544
)
542545

543546
async def call_api(filename, input_dir, output_dir):
@@ -556,7 +559,10 @@ Set the `coordinates` parameter to `true` to add this field to the elements in t
556559
}
557560

558561
try:
559-
res = await client.general.partition_async(request=req)
562+
res = await client.general.partition_async(
563+
request=req,
564+
server_url=os.getenv("UNSTRUCTURED_API_URL")
565+
)
560566
element_dicts = [element for element in res.elements]
561567
json_elements = json.dumps(element_dicts, indent=2)
562568

@@ -592,7 +598,7 @@ Set the `coordinates` parameter to `true` to add this field to the elements in t
592598
```
593599
</Accordion>
594600
<Accordion title="JavaScript/TypeScript SDK">
595-
<UseIngestInstead />
601+
<UseIngestOrPlatformInstead />
596602
```typescript TypeScript
597603
import { UnstructuredClient } from "unstructured-client";
598604
import * as fs from "fs";
@@ -734,7 +740,7 @@ This can be helpful if you'd like to use the IDs as a primary key in a database,
734740
```
735741
</Accordion>
736742
<Accordion title="POST">
737-
<UseIngestInstead />
743+
<UseIngestOrPlatformInstead />
738744
```bash POST
739745
curl -X 'POST' $UNSTRUCTURED_API_URL \
740746
-H 'accept: application/json' \
@@ -745,7 +751,7 @@ This can be helpful if you'd like to use the IDs as a primary key in a database,
745751
```
746752
</Accordion>
747753
<Accordion title="Python SDK">
748-
<UseIngestInstead />
754+
<UseIngestOrPlatformInstead />
749755
```python Python
750756
import asyncio
751757
import os
@@ -754,8 +760,7 @@ This can be helpful if you'd like to use the IDs as a primary key in a database,
754760
from unstructured_client.models import shared
755761

756762
client = unstructured_client.UnstructuredClient(
757-
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY"),
758-
server_url=os.getenv("UNSTRUCTURED_API_URL"),
763+
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")
759764
)
760765

761766
async def call_api(filename, input_dir, output_dir):
@@ -774,7 +779,10 @@ This can be helpful if you'd like to use the IDs as a primary key in a database,
774779
}
775780

776781
try:
777-
res = await client.general.partition_async(request=req)
782+
res = await client.general.partition_async(
783+
request=req,
784+
server_url=os.getenv("UNSTRUCTURED_API_URL")
785+
)
778786
element_dicts = [element for element in res.elements]
779787
json_elements = json.dumps(element_dicts, indent=2)
780788

@@ -810,7 +818,7 @@ This can be helpful if you'd like to use the IDs as a primary key in a database,
810818
```
811819
</Accordion>
812820
<Accordion title="JavaScript/TypeScript SDK">
813-
<UseIngestInstead />
821+
<UseIngestOrPlatformInstead />
814822
```typescript TypeScript
815823
import { UnstructuredClient } from "unstructured-client";
816824
import * as fs from "fs";
@@ -956,7 +964,7 @@ By default, the `chunking_strategy` is set to `None`, and no chunking is perform
956964
```
957965
</Accordion>
958966
<Accordion title="POST">
959-
<UseIngestInstead />
967+
<UseIngestOrPlatformInstead />
960968
```bash POST
961969
curl -X 'POST' $UNSTRUCTURED_API_URL \
962970
-H 'accept: application/json' \
@@ -969,7 +977,7 @@ By default, the `chunking_strategy` is set to `None`, and no chunking is perform
969977
```
970978
</Accordion>
971979
<Accordion title="Python SDK">
972-
<UseIngestInstead />
980+
<UseIngestOrPlatformInstead />
973981
```python Python
974982
import asyncio
975983
import os
@@ -978,8 +986,7 @@ By default, the `chunking_strategy` is set to `None`, and no chunking is perform
978986
from unstructured_client.models import shared
979987

980988
client = unstructured_client.UnstructuredClient(
981-
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY"),
982-
server_url=os.getenv("UNSTRUCTURED_API_URL"),
989+
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")
983990
)
984991

985992
async def call_api(filename, input_dir, output_dir):
@@ -999,7 +1006,10 @@ By default, the `chunking_strategy` is set to `None`, and no chunking is perform
9991006
}
10001007

10011008
try:
1002-
res = await client.general.partition_async(request=req)
1009+
res = await client.general.partition_async(
1010+
request=req,
1011+
server_url=os.getenv("UNSTRUCTURED_API_URL")
1012+
)
10031013
element_dicts = [element for element in res.elements]
10041014
json_elements = json.dumps(element_dicts, indent=2)
10051015

@@ -1035,7 +1045,7 @@ By default, the `chunking_strategy` is set to `None`, and no chunking is perform
10351045
```
10361046
</Accordion>
10371047
<Accordion title="JavaScript/TypeScript SDK">
1038-
<UseIngestInstead />
1048+
<UseIngestOrPlatformInstead />
10391049
```typescript TypeScript
10401050
import { UnstructuredClient } from "unstructured-client";
10411051
import * as fs from "fs";

api-reference/api-services/partition-via-api.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ would like to leverage the advanced capabilities of Unstructured API services, y
88
Whether you're using the Free Unstructured API, the Unstructured Serverless API,
99
the Unstructured API on Azure/AWS, or your local deployment of the Unstructured API, you can use the open source library to send an individual file through `partition_via_api` for processing with Unstructured API services.
1010

11-
import UseIngestInstead from '/snippets/general-shared-text/use-ingest-instead.mdx';
11+
import UseIngestOrPlatformInstead from '/snippets/general-shared-text/use-ingest-or-platform-instead.mdx';
1212

13-
<UseIngestInstead />
13+
<UseIngestOrPlatformInstead />
1414

1515
To use the open source library, you'll also need:
1616

api-reference/api-services/post-requests.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ sidebarTitle: POST request
66
Whether you're using the free Unstructured API, the Unstructured Serverless API, Unstructured API on Azure/AWS, or your local
77
deployment of Unstructured API, you can work with the API by sending single-file POST requests to it.
88

9-
import UseIngestInstead from '/snippets/general-shared-text/use-ingest-instead.mdx';
9+
import UseIngestOrPlatformInstead from '/snippets/general-shared-text/use-ingest-or-platform-instead.mdx';
1010

11-
<UseIngestInstead />
11+
<UseIngestOrPlatformInstead />
1212

1313
To make POST requests, you will need:
1414

api-reference/api-services/sdk-jsts.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ The [Unstructured JavaScript/TypeScript SDK](https://github.com/Unstructured-IO/
77
Free Unstructured API, the Unstructured Serverless API, the Unstructured API on Azure/AWS, or your local
88
deployment of the Unstructured API, you can access the API using the JavaScript/TypeScript SDK.
99

10-
import UseIngestInstead from '/snippets/general-shared-text/use-ingest-instead.mdx';
10+
import UseIngestOrPlatformInstead from '/snippets/general-shared-text/use-ingest-or-platform-instead.mdx';
1111

12-
<UseIngestInstead />
12+
<UseIngestOrPlatformInstead />
1313

1414
To use the JavaScript/TypeScript SDK, you'll need:
1515

0 commit comments

Comments
 (0)