Skip to content

Commit a7f33d1

Browse files
committed
Merge branch 'master' into docs/add-missing-concept-content
# Conflicts: # docs/02_concepts/08_pagination.mdx
2 parents dc12f42 + 905ab7c commit a7f33d1

21 files changed

+211
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
1010
- [**breaking**] Make HTTP client pluggable with abstract base classes ([#641](https://github.com/apify/apify-client-python/pull/641)) ([5ae33a0](https://github.com/apify/apify-client-python/commit/5ae33a0a801fdacd0c456a8630fea053f9df6550)) by [@vdusek](https://github.com/vdusek), closes [#416](https://github.com/apify/apify-client-python/issues/416)
1111
- [**breaking**] Introduce tiered timeout system with per-endpoint configuration ([#653](https://github.com/apify/apify-client-python/pull/653)) ([723ec6e](https://github.com/apify/apify-client-python/commit/723ec6e5954474767a5ecbf4902d9b62f7d214f8)) by [@vdusek](https://github.com/vdusek)
1212
- Accept Pydantic models as alternatives to dicts in resource client methods ([#663](https://github.com/apify/apify-client-python/pull/663)) ([b778c20](https://github.com/apify/apify-client-python/commit/b778c2040228ff9f5a97765de10535cec3f0353e)) by [@vdusek](https://github.com/vdusek), closes [#421](https://github.com/apify/apify-client-python/issues/421)
13+
- Add ownership parameter to storage collection listing methods ([#696](https://github.com/apify/apify-client-python/pull/696)) ([51a92a3](https://github.com/apify/apify-client-python/commit/51a92a31dac5dd433acfaea76155011d0892d8c8)) by [@nmanerikar](https://github.com/nmanerikar)
1314

1415
### 🚜 Refactor
1516

docs/01_introduction/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pip install apify-client
3939

4040
## Quick example
4141

42-
Here's an example showing how to run an Actor and retrieve its results:
42+
The following example shows how to run an Actor and retrieve its results:
4343

4444
<Tabs>
4545
<TabItem value="AsyncExample" label="Async client" default>

docs/01_introduction/quick-start.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99
import CodeBlock from '@theme/CodeBlock';
1010

11+
import ApiLink from '@site/src/components/ApiLink';
12+
1113
import AuthAsyncExample from '!!raw-loader!./code/02_auth_async.py';
1214
import AuthSyncExample from '!!raw-loader!./code/02_auth_sync.py';
1315
import InputAsyncExample from '!!raw-loader!./code/03_input_async.py';
@@ -44,9 +46,9 @@ The API token is used to authorize your requests to the Apify API. You can be ch
4446

4547
## Step 2: Run an Actor
4648

47-
To start an Actor, call the [`apify_client.actor()`](/reference/class/ActorClient) method with the Actor's ID (e.g., `john-doe/my-cool-actor`). The Actor's ID is a combination of the Actor owner's username and the Actor name. You can run both your own Actors and Actors from [Apify Store](https://apify.com/store).
49+
To start an Actor, call the <ApiLink to="class/ActorClient">`apify_client.actor()`</ApiLink> method with the Actor's ID (e.g., `john-doe/my-cool-actor`). The Actor's ID is a combination of the Actor owner's username and the Actor name. You can run both your own Actors and Actors from [Apify Store](https://apify.com/store).
4850

49-
To define the Actor's input, pass a dictionary to the [`call()`](/reference/class/ActorClient#call) method that matches the Actor's [input schema](https://docs.apify.com/platform/actors/development/actor-definition/input-schema). The input can include URLs to scrape, search terms, or other configuration data.
51+
To define the Actor's input, pass a dictionary to the <ApiLink to="class/ActorClient#call">`call()`</ApiLink> method that matches the Actor's [input schema](https://docs.apify.com/platform/actors/development/actor-definition/input-schema). The input can include URLs to scrape, search terms, or other configuration data.
5052

5153
<Tabs>
5254
<TabItem value="AsyncExample" label="Async client" default>
@@ -63,7 +65,7 @@ To define the Actor's input, pass a dictionary to the [`call()`](/reference/clas
6365

6466
## Step 3: Get results from the dataset
6567

66-
To get the results from the dataset, call the [`apify_client.dataset()`](/reference/class/DatasetClient) method with the dataset ID, then call [`list_items()`](/reference/class/DatasetClient#list_items) to retrieve the data. You can get the dataset ID from the Actor's run dictionary (represented by `defaultDatasetId`).
68+
To get the results from the dataset, call the <ApiLink to="class/DatasetClient">`apify_client.dataset()`</ApiLink> method with the dataset ID, then call <ApiLink to="class/DatasetClient#list_items">`list_items()`</ApiLink> to retrieve the data. You can get the dataset ID from the Actor's run dictionary (represented by `defaultDatasetId`).
6769

6870
<Tabs>
6971
<TabItem value="AsyncExample" label="Async client" default>

docs/02_concepts/01_async_support.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import TabItem from '@theme/TabItem';
99
import CodeBlock from '@theme/CodeBlock';
1010
import ApiLink from '@site/src/components/ApiLink';
1111

12+
import ApiLink from '@site/src/components/ApiLink';
13+
1214
import AsyncSupportExample from '!!raw-loader!./code/01_async_support.py';
1315

14-
The package provides an asynchronous version of the client, [`ApifyClientAsync`](/reference/class/ApifyClientAsync), which allows you to interact with the Apify API using Python's standard async/await syntax. This enables you to perform non-blocking operations, see the Python [asyncio documentation](https://docs.python.org/3/library/asyncio-task.html) for more information.
16+
The package provides an asynchronous version of the client, <ApiLink to="class/ApifyClientAsync">`ApifyClientAsync`</ApiLink>, which allows you to interact with the Apify API using Python's standard async/await syntax. This enables you to perform non-blocking operations, see the Python [asyncio documentation](https://docs.python.org/3/library/asyncio-task.html) for more information. This is useful for applications that need to perform multiple API operations concurrently or integrate with other async frameworks.
1517

16-
The following example demonstrates how to run an Actor asynchronously and stream its logs while it is running:
18+
The following example shows how to run an Actor asynchronously and stream its logs while it is running:
1719

1820
<CodeBlock className="language-python">
1921
{AsyncSupportExample}

docs/02_concepts/02_single_collection_clients.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99
import CodeBlock from '@theme/CodeBlock';
1010

11+
import ApiLink from '@site/src/components/ApiLink';
12+
1113
import CollectionAsyncExample from '!!raw-loader!./code/02_collection_async.py';
1214
import CollectionSyncExample from '!!raw-loader!./code/02_collection_sync.py';
1315
import SingleAsyncExample from '!!raw-loader!./code/02_single_async.py';
1416
import SingleSyncExample from '!!raw-loader!./code/02_single_sync.py';
1517

16-
The Apify client interface is designed to be consistent and intuitive across all of its components. When you call specific methods on the main client, you create specialized clients to manage individual API resources. There are two main types of clients:
18+
The Apify client provides two types of resource clients: single-resource clients for managing an individual resource, and collection clients for listing or creating resources.
1719

18-
- [`ActorClient`](/reference/class/ActorClient) - Manages a single resource.
19-
- [`ActorCollectionClient`](/reference/class/ActorCollectionClient) - Manages a collection of resources.
20+
- <ApiLink to="class/ActorClient">`ActorClient`</ApiLink> - Manages a single resource.
21+
- <ApiLink to="class/ActorCollectionClient">`ActorCollectionClient`</ApiLink> - Manages a collection of resources.
2022

2123
<Tabs>
2224
<TabItem value="AsyncExample" label="Async client" default>

docs/02_concepts/03_nested_clients.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99
import CodeBlock from '@theme/CodeBlock';
1010

11+
import ApiLink from '@site/src/components/ApiLink';
12+
1113
import NestedAsyncExample from '!!raw-loader!./code/03_nested_async.py';
1214
import NestedSyncExample from '!!raw-loader!./code/03_nested_sync.py';
1315

14-
In some cases, the Apify client provides nested clients to simplify working with related collections. For example, you can easily manage the runs of a specific Actor without having to construct multiple endpoints or client instances manually.
16+
Nested clients let you access related resources directly from a parent resource client, without manually constructing new client instances.
1517

1618
<Tabs>
1719
<TabItem value="AsyncExample" label="Async client" default>
@@ -26,4 +28,4 @@ In some cases, the Apify client provides nested clients to simplify working with
2628
</TabItem>
2729
</Tabs>
2830

29-
This direct access to [Dataset](https://docs.apify.com/platform/storage/dataset) (and other storage resources) from the [`RunClient`](/reference/class/RunClient) is especially convenient when used alongside the [`ActorClient.last_run`](/reference/class/ActorClient#last_run) method.
31+
This direct access to [Dataset](https://docs.apify.com/platform/storage/dataset) (and other storage resources) from the <ApiLink to="class/RunClient">`RunClient`</ApiLink> is especially convenient when used alongside the <ApiLink to="class/ActorClient#last_run">`ActorClient.last_run`</ApiLink> method.

docs/02_concepts/04_error_handling.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import TabItem from '@theme/TabItem';
99
import CodeBlock from '@theme/CodeBlock';
1010
import ApiLink from '@site/src/components/ApiLink';
1111

12+
import ApiLink from '@site/src/components/ApiLink';
13+
1214
import ErrorAsyncExample from '!!raw-loader!./code/04_error_async.py';
1315
import ErrorSyncExample from '!!raw-loader!./code/04_error_sync.py';
1416

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 [`ApifyApiError`](/reference/class/ApifyApiError). This exception wraps the raw JSON errors returned by the API and provides additional context, making it easier to debug any issues that arise.
17+
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 <ApiLink to="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.
1618

1719
<Tabs>
1820
<TabItem value="AsyncExample" label="Async client" default>

docs/02_concepts/05_retries.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99
import CodeBlock from '@theme/CodeBlock';
1010

11+
import ApiLink from '@site/src/components/ApiLink';
12+
1113
import RetriesAsyncExample from '!!raw-loader!./code/05_retries_async.py';
1214
import RetriesSyncExample from '!!raw-loader!./code/05_retries_sync.py';
1315

@@ -22,7 +24,7 @@ By default, the client retries a failed request up to 4 times. The retry interva
2224
- The first retry occurs after approximately 500 milliseconds.
2325
- The second retry occurs after approximately 1,000 milliseconds, and so on.
2426

25-
You can customize this behavior using the following options in the [`ApifyClient`](/reference/class/ApifyClient) constructor:
27+
You can customize this behavior using the following options in the <ApiLink to="class/ApifyClient">`ApifyClient`</ApiLink> constructor:
2628

2729
- `max_retries`: Defines the maximum number of retry attempts.
2830
- `min_delay_between_retries`: Sets the minimum delay between retries as a `timedelta`.

docs/02_concepts/07_convenience_methods.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99
import CodeBlock from '@theme/CodeBlock';
1010

11+
import ApiLink from '@site/src/components/ApiLink';
12+
1113
import CallAsyncExample from '!!raw-loader!./code/07_call_async.py';
1214
import CallSyncExample from '!!raw-loader!./code/07_call_sync.py';
1315

1416
The Apify client provides several convenience methods to handle actions that the API alone cannot perform efficiently, such as waiting for an Actor run to finish without running into network timeouts. These methods simplify common tasks and enhance the usability of the client.
1517

16-
- [`ActorClient.call`](/reference/class/ActorClient#call) - Starts an Actor and waits for it to finish, handling network timeouts internally. Waits indefinitely by default, or up to the specified `wait_duration`.
17-
- [`ActorClient.start`](/reference/class/ActorClient#start) - Starts an Actor and immediately returns the Run object without waiting for it to finish.
18-
- [`RunClient.wait_for_finish`](/reference/class/RunClient#wait_for_finish) - Waits for an already-started run to reach a terminal status.
18+
- <ApiLink to="class/ActorClient#call">`ActorClient.call`</ApiLink> - Starts an Actor and waits for it to finish, handling network timeouts internally. Waits indefinitely by default, or up to the specified `wait_duration`.
19+
- <ApiLink to="class/ActorClient#start">`ActorClient.start`</ApiLink> - Starts an Actor and immediately returns the Run object without waiting for it to finish.
20+
- <ApiLink to="class/RunClient#wait_for_finish">`RunClient.wait_for_finish`</ApiLink> - Waits for an already-started run to reach a terminal status.
1921

2022
Additionally, storage-related resources offer flexible options for data retrieval:
2123

@@ -34,3 +36,7 @@ Additionally, storage-related resources offer flexible options for data retrieva
3436
</CodeBlock>
3537
</TabItem>
3638
</Tabs>
39+
40+
:::tip
41+
The `call()` method polls internally and may take a long time for long-running Actors. Use `start()` and `wait_for_finish()` separately if you need more control over the waiting behavior.
42+
:::

docs/02_concepts/08_pagination.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99
import CodeBlock from '@theme/CodeBlock';
1010

11+
import ApiLink from '@site/src/components/ApiLink';
12+
1113
import PaginationAsyncExample from '!!raw-loader!./code/08_pagination_async.py';
1214
import PaginationSyncExample from '!!raw-loader!./code/08_pagination_sync.py';
1315

1416
import IterateItemsAsyncExample from '!!raw-loader!./code/08_iterate_items_async.py';
1517
import IterateItemsSyncExample from '!!raw-loader!./code/08_iterate_items_sync.py';
1618

17-
Most methods named `list` or `list_something` in the Apify client return a [`ListPage`](/reference/class/ListPage) object. This object provides a consistent interface for working with paginated data and includes the following properties:
19+
Most methods named `list` or `list_something` in the Apify client return a <ApiLink to="class/ListPage">`ListPage`</ApiLink> object. This object provides a consistent interface for working with paginated data and includes the following properties:
1820

1921
- `items` - The main results you're looking for.
2022
- `total` - The total number of items available.
@@ -24,7 +26,7 @@ Most methods named `list` or `list_something` in the Apify client return a [`Lis
2426

2527
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.
2628

27-
The following example demonstrates how to fetch all items from a dataset using pagination:
29+
The following example shows how to fetch all items from a dataset using pagination:
2830

2931
<Tabs>
3032
<TabItem value="AsyncExample" label="Async client" default>
@@ -39,7 +41,7 @@ The following example demonstrates how to fetch all items from a dataset using p
3941
</TabItem>
4042
</Tabs>
4143

42-
The [`ListPage`](/reference/class/ListPage) 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.
44+
The <ApiLink to="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.
4345

4446
## Generator-based iteration
4547

0 commit comments

Comments
 (0)