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
## Summary
Addresses review feedback on the v3 docs:
- **Error handling concept page** — adds an *Error subclasses* section
with the status-to-class table and updates the code examples to
demonstrate catching a specific subclass (`NotFoundError`) alongside the
generic `ApifyApiError`.
- **Pagination concept page** — removes stale references to the v2
`ListPage` class; list methods now return Pydantic page models like
`ListOfActors` / `ListOfDatasets` / `ListOfRequests` (or the
`DatasetItemsPage` dataclass for unstructured items).
- **v3 upgrade guide** — adds a warning that `apify_client._models`,
`apify_client._typeddicts`, and `apify_client._literals` are internal
modules with no public-API stability guarantee, and replaces the
duplicated error-subclass table with a cross-link to the concept page so
the mapping has a single source of truth.
Copy file name to clipboardExpand all lines: docs/02_concepts/04_error_handling.mdx
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,22 @@ import ErrorSyncExample from '!!raw-loader!./code/04_error_sync.py';
14
14
15
15
When you use the Apify client, it automatically extracts all relevant data from the endpoint and returns it in the expected format. Date strings, for instance, are seamlessly converted to Python `datetime.datetime` objects. If an error occurs, the client raises an <ApiLinkto="class/ApifyApiError">`ApifyApiError`</ApiLink>. This exception wraps the raw JSON errors returned by the API and provides additional context, making it easier to debug any issues that arise.
16
16
17
+
## Error subclasses
18
+
19
+
The Apify client provides dedicated error subclasses based on the HTTP status code of the failed response, so you can branch on error kind without inspecting `status_code` or `type`:
All subclasses inherit from <ApiLinkto="class/ApifyApiError">`ApifyApiError`</ApiLink>, so an existing `except ApifyApiError` handler still catches every API error. Catch a specific subclass when you want to react differently to, for example, a missing resource or a rate-limit:
Most methods named `list` or `list_something` in the Apify client return a <ApiLinkto="class/ListPage">`ListPage`</ApiLink> object. This object provides a consistent interface for working with paginated data and includes the following properties:
20
+
Most methods named `list` or `list_something` in the Apify client return a page model — a [Pydantic](https://docs.pydantic.dev/latest/) model such as <ApiLinkto="class/ListOfActors">`ListOfActors`</ApiLink>, <ApiLinkto="class/ListOfDatasets">`ListOfDatasets`</ApiLink>, or <ApiLinkto="class/ListOfRequests">`ListOfRequests`</ApiLink>. Unstructured dataset items use the <ApiLinkto="class/DatasetItemsPage">`DatasetItemsPage`</ApiLink> dataclass instead. All page models share a consistent interface for working with paginated data and expose the following fields:
21
21
22
22
-`items` - The main results you're looking for.
23
23
-`total` - The total number of items available.
24
24
-`offset` - The starting point of the current page.
25
25
-`count` - The number of items in the current page.
26
26
-`limit` - The maximum number of items per page.
27
27
28
-
Some methods, such as `list_keys` or `list_head`, paginate differently. Regardless, the primary results are always stored under the items property, and the limit property can be used to control the number of results returned.
28
+
Some methods, such as `list_keys` or `list_head`, paginate differently. Regardless, the primary results are always stored under the `items` field, and the `limit` field can be used to control the number of results returned.
29
29
30
30
The following example shows how to fetch all items from a dataset using pagination:
31
31
@@ -42,7 +42,7 @@ The following example shows how to fetch all items from a dataset using paginati
42
42
</TabItem>
43
43
</Tabs>
44
44
45
-
The <ApiLinkto="class/ListPage">`ListPage`</ApiLink> interface offers several key benefits. Its consistent structure ensures predictable results for most `list` methods, providing a uniform way to work with paginated data. It also offers flexibility, allowing you to customize the `limit` and `offset` parameters to control data fetching according to your needs. Additionally, it provides scalability, enabling you to efficiently handle large datasets through pagination. This approach ensures efficient data retrieval while keeping memory usage under control, making it ideal for managing and processing large collections.
45
+
The page model interface offers several key benefits. Its consistent structure ensures predictable results for most `list` methods, providing a uniform way to work with paginated data. It also offers flexibility, allowing you to customize the `limit` and `offset` parameters to control data fetching according to your needs. Additionally, it provides scalability, enabling you to efficiently handle large datasets through pagination. This approach ensures efficient data retrieval while keeping memory usage under control, making it ideal for managing and processing large collections.
Copy file name to clipboardExpand all lines: docs/04_upgrading/upgrading_to_v3.mdx
+5-13Lines changed: 5 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,10 @@ status = run.status
46
46
47
47
All model classes are generated from the Apify OpenAPI specification and live in `apify_client._models` module. They are configured with `extra='allow'`, so any new fields added to the API in the future are preserved on the model instance. Fields are accessed using their Python snake_case names:
48
48
49
+
:::warning
50
+
The `apify_client._models`, `apify_client._typeddicts`, and `apify_client._literals` modules are internal. The examples below import from them for convenience, but use them at your own risk — their contents are regenerated from the OpenAPI specification and the public API of these modules is not stable across minor versions of `apify-client`.
51
+
:::
52
+
49
53
```python
50
54
run.default_dataset_id # ✓ use snake_case attribute names
51
55
run.id
@@ -191,19 +195,7 @@ If your code relied on the previous global timeout behavior, review the timeout
191
195
192
196
## Exception subclasses for API errors
193
197
194
-
<ApiLinkto="class/ApifyApiError">`ApifyApiError`</ApiLink> now dispatches to a dedicated subclass based on the HTTP status code of the failed response. Instantiating `ApifyApiError` directly still works — it returns the most specific subclass for the status — so existing `except ApifyApiError` handlers are unaffected.
The Apify client now provides dedicated error subclasses based on the HTTP status code of the failed response. Instantiating <ApiLinkto="class/ApifyApiError">`ApifyApiError`</ApiLink> directly still works — it returns the most specific subclass for the status — so existing `except ApifyApiError` handlers are unaffected. See the [Error handling](/docs/concepts/error-handling#error-subclasses) concept page for the full status-to-subclass mapping.
207
199
208
200
You can now branch on error kind without inspecting `status_code` or `type`:
0 commit comments