Skip to content

Commit defd636

Browse files
Revert back to original API behavior for default API URLs, server_url need and placement (#490)
Co-authored-by: Austin Walker <[email protected]>
1 parent 1dc5c3d commit defd636

File tree

12 files changed

+127
-331
lines changed

12 files changed

+127
-331
lines changed

api-reference/api-services/examples.mdx

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@ import SharedAPIKeyURL from '/snippets/general-shared-text/api-key-url.mdx';
1111

1212
import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serverless-api.mdx';
1313

14-
<Warning>
15-
**Important**: Beginning with Python SDK 0.30.0, note the following:
16-
17-
- For the Unstructured Serverless API URL, do not use `https://api.unstructuredapp.io/general/v0/general`, or else calls made by
18-
the Python SDK will fail. Use `https://api.unstructuredapp.io` instead.
19-
- For the Free Unstructured API URL, do not use `https://api.unstructured.io/general/v0/general`, or else calls made by
20-
the Python SDK will fail. Use `https://api.unstructured.io` instead.
21-
- If your Python code previously used the `server_url` parameter inside of your `UnstructuredClient` constructor to specify your Unstructured API URL, you must move this `server_url` parameter into
22-
your code's `partition` or `partition_async` function calls instead, or else calls made by the Python SDK will fail. To learn how, see the following code examples.
23-
24-
[Learn more](/api-reference/api-services/sdk-python#migration-guide).
25-
</Warning>
26-
2714
<NoURLForServerlessAPI/>
2815

2916
import UseIngestOrPlatformInstead from '/snippets/general-shared-text/use-ingest-or-platform-instead.mdx';
@@ -136,8 +123,7 @@ The `hi_res` strategy supports different models, and the default is `layout_v1.1
136123

137124
try:
138125
res = await client.general.partition_async(
139-
request=req,
140-
server_url=os.getenv("UNSTRUCTURED_API_URL")
126+
request=req
141127
)
142128
element_dicts = [element for element in res.elements]
143129
json_elements = json.dumps(element_dicts, indent=2)
@@ -356,8 +342,7 @@ For better OCR results, you can specify what languages your document is in using
356342

357343
try:
358344
res = await client.general.partition_async(
359-
request=req,
360-
server_url=os.getenv("UNSTRUCTURED_API_URL")
345+
request=req
361346
)
362347
element_dicts = [element for element in res.elements]
363348
json_elements = json.dumps(element_dicts, indent=2)
@@ -573,8 +558,7 @@ Set the `coordinates` parameter to `true` to add this field to the elements in t
573558

574559
try:
575560
res = await client.general.partition_async(
576-
request=req,
577-
server_url=os.getenv("UNSTRUCTURED_API_URL")
561+
request=req
578562
)
579563
element_dicts = [element for element in res.elements]
580564
json_elements = json.dumps(element_dicts, indent=2)
@@ -793,8 +777,7 @@ This can be helpful if you'd like to use the IDs as a primary key in a database,
793777

794778
try:
795779
res = await client.general.partition_async(
796-
request=req,
797-
server_url=os.getenv("UNSTRUCTURED_API_URL")
780+
request=req
798781
)
799782
element_dicts = [element for element in res.elements]
800783
json_elements = json.dumps(element_dicts, indent=2)
@@ -1020,8 +1003,7 @@ By default, the `chunking_strategy` is set to `None`, and no chunking is perform
10201003

10211004
try:
10221005
res = await client.general.partition_async(
1023-
request=req,
1024-
server_url=os.getenv("UNSTRUCTURED_API_URL")
1006+
request=req
10251007
)
10261008
element_dicts = [element for element in res.elements]
10271009
json_elements = json.dumps(element_dicts, indent=2)

api-reference/api-services/free-api.mdx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@ The Free Unstructured API requires authentication via an API key. Here's how you
1919
5. Click **Submit**. You will receive a Free Unstructured API key at the **Email** you provided. Store your API key in a secure location. Do not share it with others.
2020
6. For the Free Unstructured API, the API URL is `https://api.unstructured.io/general/v0/general`
2121

22-
<Warning>
23-
**Important**: This article shows how to use Free Unstructured API with the Unstructured CLI and the
24-
Unstructured Ingest Python library. While you can also use this API URL with the Unstructured Python SDK,
25-
beginning with Python SDK 0.30.0, note the following:
26-
27-
- Do not use https://api.unstructured.io/general/v0/general, or else calls made by
28-
the Python SDK will fail. Use https://api.unstructured.io` instead.
29-
- If your Python code uses the `server_url` parameter inside of your `UnstructuredClient` constructor to specify this URL, you must move this `server_url` parameter into
30-
your code's `partition` or `partition_async` function calls instead, or else calls made by the Python SDK will fail.
31-
</Warning>
32-
3322
import FreeKeyNoServerlessURL from '/snippets/general-shared-text/free-api-key-no-serverless-access.mdx';
3423

3524
<FreeKeyNoServerlessURL />

api-reference/api-services/saas-api-development-guide.mdx

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This page describes how to get started with the Unstructured Serverless API. Lea
1313

1414
## Get started
1515

16-
To call the Unstructured Serverless API, you need an Unstructured account, API key, and API URL:
16+
To call the Unstructured Serverless API, you need an Unstructured account and an Unstructured API key:
1717

1818
<Steps>
1919
<Step title="Sign up">
@@ -64,7 +64,7 @@ To call the Unstructured Serverless API, you need an Unstructured account, API k
6464
</Tip>
6565

6666
</Step>
67-
<Step title="Get your API key and API URL">
67+
<Step title="Get your API key">
6868

6969
<img src="https://unstructured-tech-docs.s3.amazonaws.com/Unstructured-Platform-APIKeyURL.gif" alt="Unstructured API key how-to" width="500" />
7070

@@ -76,27 +76,9 @@ To call the Unstructured Serverless API, you need an Unstructured account, API k
7676
2. On the **API Keys** tab, click **Generate New Key**.
7777
3. Enter some descriptive name for the API key, and then click **Save**.
7878
4. Click the **Copy** icon for your new API key. The API key's value is copied to your system's clipboard.
79-
5. Note the Unstructured **Serverless API URL**, which is `https://api.unstructuredapp.io/general/v0/general`
80-
81-
![Unstructured Serverless API URL](/img/platform/ServerlessAPIURL.png)
82-
83-
<Warning>
84-
Do not use the Unstructured **Platform API URL**, which is separate from the Unstructured Serverless API URL.
85-
</Warning>
86-
87-
<Note>
88-
If you signed up through the [For Enterprise](https://unstructured.io/enterprise) page, your API URL
89-
might be different. For API URL guidance, email Unstructured Sales at [[email protected]](mailto:[email protected]).
90-
If your API URL is different, be sure to substitute `https://api.unstructuredapp.io/general/v0/general` for your
91-
API URL throughout the following examples.
92-
</Note>
9379
</Step>
9480
</Steps>
9581

96-
import ServerlessKeyNoFreeURL from '/snippets/general-shared-text/serverless-api-key-no-free-access.mdx';
97-
98-
<ServerlessKeyNoFreeURL />
99-
10082
[Try the quickstart](#quickstart).
10183

10284
## Set up billing
@@ -137,6 +119,10 @@ import SharedPagesBilling from '/snippets/general-shared-text/pages-billing.mdx'
137119

138120
These examples use your local machine. They send source (input) files from your local machine to the Unstructured Serverless API which delivers the processed data to a destination (output) location, also on your local machine. Data is processed on Unstructured-hosted compute resources.
139121

122+
import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serverless-api.mdx';
123+
124+
<NoURLForServerlessAPI/>
125+
140126
### Unstructured Ingest CLI
141127

142128
To work with the Unstructured Serverless API by using the [Unstructured Ingest CLI](/ingestion/overview#unstructured-ingest-cli), you will need to:
@@ -147,12 +133,11 @@ To work with the Unstructured Serverless API by using the [Unstructured Ingest C
147133
pip install unstructured-ingest
148134
```
149135

150-
- Set the following environment variables:
136+
- Set the following environment variable:
151137

152138
- Set `UNSTRUCTURED_API_KEY` to your API key.
153-
- Set `UNSTRUCTURED_API_URL` to your API URL.
154139

155-
[Get your API key and API URL](#get-started).
140+
[Get your API key](#get-started).
156141

157142
- Have some compatible files on your local machine to be processed. [See the list of supported file types](/api-reference/api-services/supported-file-types). If you do not have any files available, you can download some from the [example-docs](https://github.com/Unstructured-IO/unstructured-ingest/tree/main/example-docs) folder in the Unstructured repo on GitHub.
158143

@@ -168,7 +153,6 @@ unstructured-ingest \
168153
--output-dir <path/to/output> \
169154
--partition-by-api \
170155
--api-key $UNSTRUCTURED_API_KEY \
171-
--partition-endpoint $UNSTRUCTURED_API_URL \
172156
--strategy hi_res \
173157
--additional-partition-args="{\"split_pdf_page\":\"true\", \"split_pdf_allow_failed\":\"true\", \"split_pdf_concurrency_level\": 15}"
174158
```
@@ -188,9 +172,8 @@ To work with the Unstructured Serverless API by using the [Unstructured Python l
188172
- Set the following environment variables:
189173

190174
- Set `UNSTRUCTURED_API_KEY` to your API key.
191-
- Set `UNSTRUCTURED_API_URL` to your API URL.
192175

193-
[Get your API key and API URL](#get-started).
176+
[Get your API key](#get-started).
194177

195178
- Have some compatible files on your local machine to be processed. [See the list of supported file types](/api-reference/api-services/supported-file-types). If you do not have any files available, you can download some from the [example-docs](https://github.com/Unstructured-IO/unstructured-ingest/tree/main/example-docs) folder in the Unstructured repo on GitHub.
196179

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

Lines changed: 9 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@ import SharedAPIKeyURL from '/snippets/general-shared-text/api-key-url.mdx';
1818

1919
<SharedAPIKeyURL />
2020

21-
<Warning>
22-
**Important**: Beginning with Python SDK 0.30.0, note the following:
23-
24-
- For the Unstructured Serverless API URL, do not use `https://api.unstructuredapp.io/general/v0/general`, or else calls made by
25-
the Python SDK will fail. Use `https://api.unstructuredapp.io` instead.
26-
- For the Free Unstructured API URL, do not use `https://api.unstructured.io/general/v0/general`, or else calls made by
27-
the Python SDK will fail. Use `https://api.unstructured.io` instead.
28-
- If your Python code previously used the `server_url` parameter inside of your `UnstructuredClient` constructor to specify your Unstructured API URL, you must move this `server_url` parameter into
29-
your code's `partition` or `partition_async` function calls instead, or else calls made by the Python SDK will fail. To learn how, see the following code examples.
30-
31-
[Learn more](#migration-guide).
32-
</Warning>
33-
3421
import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serverless-api.mdx';
3522

3623
<NoURLForServerlessAPI/>
@@ -80,8 +67,7 @@ import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serv
8067

8168
try:
8269
res = client.general.partition(
83-
request=req,
84-
server_url=os.getenv("UNSTRUCTURED_API_URL")
70+
request=req
8571
)
8672
element_dicts = [element for element in res.elements]
8773

@@ -124,8 +110,7 @@ import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serv
124110

125111
try:
126112
res = client.general.partition(
127-
request=req,
128-
server_url=os.getenv("UNSTRUCTURED_API_URL")
113+
request=req
129114
)
130115
element_dicts = [element for element in res.elements]
131116

@@ -171,8 +156,7 @@ import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serv
171156

172157
try:
173158
res = await client.general.partition_async(
174-
request=req,
175-
server_url=os.getenv("UNSTRUCTURED_API_URL")
159+
request=req
176160
)
177161
element_dicts = [element for element in res.elements]
178162
json_elements = json.dumps(element_dicts, indent=2)
@@ -246,8 +230,7 @@ import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serv
246230
)
247231
)
248232
res = client.general.partition(
249-
request=req,
250-
server_url=os.getenv("UNSTRUCTURED_API_URL")
233+
request=req
251234
)
252235
```
253236

@@ -263,8 +246,7 @@ import NoURLForServerlessAPI from '/snippets/general-shared-text/no-url-for-serv
263246
import os
264247

265248
client = UnstructuredClient(
266-
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY"),
267-
server_url=os.getenv("UNSTRUCTURED_API_URL"),
249+
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")
268250
retry_config=RetryConfig(
269251
strategy="backoff",
270252
retry_connection_errors=True,
@@ -322,49 +304,7 @@ the names used in the SDKs are the same across all methods.
322304

323305
## Migration guide
324306

325-
There are breaking changes beginning with Python SDK version 0.26.0 and again in 0.30.0. If you encounter any errors when upgrading, please find the solution below.
326-
327-
**If you see the error: `404 Not Found`**
328-
329-
Before 0.30.0, you could specify the following Unstructured API URL for the `server_url` parameter:
330-
331-
- For the Unstructured Serverless API: `https://api.unstructuredapp.io/general/v0/general`
332-
- For the Free Unstructured API: `https://api.unstructured.io/general/v0/general`
333-
334-
Beginning with 0.30.0, these Unstructured API URLs have changed as follows:
335-
336-
- For the Unstructured Serverless API: `https://api.unstructuredapp.io` (remove `/general/v0/general`)
337-
- For the Free Unstructured API: `https://api.unstructured.io` (remove `/general/v0/general`)
338-
339-
Also, before 0.30.0, the `server_url` parameter was part of the `UnstructuredClient` constructor. Beginning with 0.30.0, the `server_url`
340-
parameter has been moved into the `partition` and `partition_async` functions.
341-
342-
```python
343-
# Instead of:
344-
client = unstructured_client.UnstructuredClient(
345-
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY"),
346-
server_url=os.getenv("UNSTRUCTURED_API_URL")
347-
)
348-
349-
# Switch to:
350-
client = unstructured_client.UnstructuredClient(
351-
api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")
352-
)
353-
354-
# And...
355-
356-
# For partition:
357-
res = client.general.partition(
358-
request=req,
359-
server_url=os.getenv("UNSTRUCTURED_API_URL")
360-
)
361-
362-
# For partition_async:
363-
res = await client.general.partition_async(
364-
request=req,
365-
server_url=os.getenv("UNSTRUCTURED_API_URL")
366-
)
367-
```
307+
There are breaking changes beginning with Python SDK version 0.26.0. If you encounter any errors when upgrading, please find the solution below.
368308

369309
**If you see the error: `AttributeError: 'PartitionParameters' object has no attribute 'partition_parameters'`**
370310

@@ -379,8 +319,7 @@ req = shared.PartitionParameters(
379319
)
380320

381321
resp = s.general.partition(
382-
request=req,
383-
server_url=os.getenv("UNSTRUCTURED_API_URL") # Beginning with 0.30.0
322+
request=req
384323
)
385324

386325
# Switch to:
@@ -393,8 +332,7 @@ req = operations.PartitionRequest(
393332
)
394333

395334
resp = s.general.partition(
396-
request=req,
397-
server_url=os.getenv("UNSTRUCTURED_API_URL") # Beginning with 0.30.0
335+
request=req
398336
)
399337
```
400338

@@ -428,7 +366,6 @@ resp = s.general.partition(req)
428366

429367
# Switch to:
430368
resp = s.general.partition(
431-
request=req,
432-
server_url=os.getenv("UNSTRUCTURED_API_URL") # Beginning with 0.30.0
369+
request=req
433370
)
434371
```

0 commit comments

Comments
 (0)