You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatively, you can build from source and install the wheel file:
@@ -120,7 +120,7 @@ the changes aren't made through the automated pipeline, you may want to make rel
120
120
121
121
### Publish with a GitHub workflow
122
122
123
-
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/docstrange-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
123
+
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/NanoNets/docstrange-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
The Docstrange Python library provides convenient access to the Docstrange REST API from any Python 3.9+
7
7
application. The library includes type definitions for all request params and response fields,
@@ -11,18 +11,15 @@ It is generated with [Stainless](https://www.stainless.com/).
11
11
12
12
## Documentation
13
13
14
-
The full API of this library can be found in [api.md](api.md).
14
+
The REST API documentation can be found on [docs.nanonets.com](https://docs.nanonets.com). The full API of this library can be found in [api.md](api.md).
@@ -115,6 +112,67 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
115
112
116
113
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
117
114
115
+
## Pagination
116
+
117
+
List methods in the Docstrange API are paginated.
118
+
119
+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
120
+
121
+
```python
122
+
from docstrange import Docstrange
123
+
124
+
client = Docstrange()
125
+
126
+
all_results = []
127
+
# Automatically fetches more pages as needed.
128
+
for result in client.extract.results.list():
129
+
# Do something with result here
130
+
all_results.append(result)
131
+
print(all_results)
132
+
```
133
+
134
+
Or, asynchronously:
135
+
136
+
```python
137
+
import asyncio
138
+
from docstrange import AsyncDocstrange
139
+
140
+
client = AsyncDocstrange()
141
+
142
+
143
+
asyncdefmain() -> None:
144
+
all_results = []
145
+
# Iterate through items across all pages, issuing requests as needed.
146
+
asyncfor result in client.extract.results.list():
147
+
all_results.append(result)
148
+
print(all_results)
149
+
150
+
151
+
asyncio.run(main())
152
+
```
153
+
154
+
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
155
+
156
+
```python
157
+
first_page =await client.extract.results.list()
158
+
if first_page.has_next_page():
159
+
print(f"will fetch next page using these details: {first_page.next_page_info()}")
160
+
next_page =await first_page.get_next_page()
161
+
print(f"number of items we just fetched: {len(next_page.results)}")
162
+
163
+
# Remove `await` for non-async usage.
164
+
```
165
+
166
+
Or just work directly with the returned data:
167
+
168
+
```python
169
+
first_page =await client.extract.results.list()
170
+
for result in first_page.results:
171
+
print(result.record_id)
172
+
173
+
# Remove `await` for non-async usage.
174
+
```
175
+
118
176
## File uploads
119
177
120
178
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
@@ -125,7 +183,7 @@ from docstrange import Docstrange
125
183
126
184
client = Docstrange()
127
185
128
-
client.api.v1.extract.sync(
186
+
client.extract.sync(
129
187
output_format="markdown",
130
188
file=Path("/path/to/file"),
131
189
)
@@ -149,7 +207,7 @@ from docstrange import Docstrange
extract = response.parse() # get the object that `api.v1.extract.sync()` would have returned
328
+
extract = response.parse() # get the object that `extract.sync()` would have returned
271
329
print(extract.record_id)
272
330
```
273
331
274
-
These methods return an [`APIResponse`](https://github.com/stainless-sdks/docstrange-python/tree/main/src/docstrange/_response.py) object.
332
+
These methods return an [`APIResponse`](https://github.com/NanoNets/docstrange-python/tree/main/src/docstrange/_response.py) object.
275
333
276
-
The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/docstrange-python/tree/main/src/docstrange/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
334
+
The async client returns an [`AsyncAPIResponse`](https://github.com/NanoNets/docstrange-python/tree/main/src/docstrange/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
277
335
278
336
#### `.with_streaming_response`
279
337
@@ -282,7 +340,7 @@ The above interface eagerly reads the full response body when you make the reque
282
340
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
283
341
284
342
```python
285
-
with client.api.v1.extract.with_streaming_response.sync(
343
+
with client.extract.with_streaming_response.sync(
286
344
output_format="markdown",
287
345
) as response:
288
346
print(response.headers.get("X-My-Header"))
@@ -379,7 +437,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
379
437
380
438
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
381
439
382
-
We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/docstrange-python/issues) with questions, bugs, or suggestions.
440
+
We are keen for your feedback; please open an [issue](https://www.github.com/NanoNets/docstrange-python/issues) with questions, bugs, or suggestions.
0 commit comments