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
description: 'The official Python library for accessing the Apify API, providing synchronous and asynchronous interfaces for Actors, datasets, and storage.'
5
+
---
6
+
7
+
## Introduction
8
+
9
+
The [Apify client for Python](https://github.com/apify/apify-client-python) is the official library to access the [Apify REST API](/api/v2) from your Python applications. It provides useful features like automatic retries and convenience functions that improve the experience of using the Apify API.
10
+
11
+
Key features:
12
+
13
+
- Synchronous and asynchronous interfaces for flexible integration
14
+
- Automatic retries for improved reliability
15
+
- JSON encoding with UTF-8 for all requests and responses
16
+
- Comprehensive API coverage for [Actors](/platform/actors), [datasets](/platform/storage/dataset), [key-value stores](/platform/storage/key-value-store), and more
17
+
18
+
## Next steps
19
+
20
+
Now that you're familiar with the basics, explore more advanced features:
21
+
22
+
-[Asyncio support](/concepts/asyncio-support) - Learn about asynchronous programming with the client
23
+
- Common use-case examples like:
24
+
-[Passing an input to Actor](/api/client/python/docs/examples/passing-input-to-actor)
25
+
-[Retrieve Actor data](/api/client/python/docs/examples/retrieve-actor-data)
26
+
-[API Reference](/api/client/python/reference) - Browse the complete API documentation
The [Apify client for Python](https://github.com/apify/apify-client-python) is the official library to access the [Apify REST API](/api/v2) from your Python applications. It provides useful features like automatic retries and convenience functions that improve the experience of using the Apify API.
22
-
23
-
Key features:
24
-
25
-
- Synchronous and asynchronous interfaces for flexible integration
26
-
- Automatic retries for improved reliability
27
-
- JSON encoding with UTF-8 for all requests and responses
28
-
- Comprehensive API coverage for [Actors](/platform/actors), [datasets](/platform/storage/dataset), [key-value stores](/platform/storage/key-value-store), and more
29
-
30
-
## Prerequisites
31
-
32
-
Before installing the Apify client, ensure your system meets the following requirements:
33
-
34
-
-_An Apify account_
35
-
-_Python 3.10 or higher_: You can download Python from the [official website](https://www.python.org/downloads/).
36
-
-_Python package manager_: While this guide uses [pip](https://pip.pypa.io/en/stable/), you can also use any package manager you want.
37
-
38
-
To verify that Python and pip are installed, run the following commands:
39
-
40
-
```sh
41
-
python --version
42
-
```
43
-
44
-
```sh
45
-
pip --version
46
-
```
47
-
48
-
If these commands return the respective versions, you're ready to continue.
49
-
50
-
## Installation
51
-
52
-
The Apify client is available as the [`apify-client`](https://pypi.org/project/apify-client/) package on PyPI. To install it, run:
53
-
54
-
```sh
55
-
pip install apify-client
56
-
```
57
-
58
-
After installation, verify that the client is installed correctly by checking its version:
To use the client, you need an [API token](/platform/integrations/api#api-token). You can find your token under the [Integrations](https://console.apify.com/account/integrations) tab in Apify Console. Copy the token and initialize the client by providing it as a parameter to the `ApifyClient` constructor.
67
27
@@ -84,11 +44,7 @@ The API token is used to authorize your requests to the Apify API. You can be ch
84
44
85
45
:::
86
46
87
-
## Quick start
88
-
89
-
Now that you have the client set up, let's explore how to run Actors on the Apify platform, provide input to them, and retrieve their results.
90
-
91
-
### Running your first Actor
47
+
## Step 2: Running your first Actor
92
48
93
49
To start an Actor, you need its ID (e.g., `john-doe/my-cool-actor`) and an API token. The Actor's ID is a combination of the Actor name and the Actor owner's username. Use the [`ActorClient`](/reference/class/ActorClient) to run the Actor and wait for it to complete. You can run both your own Actors and [Actors from Apify Store](https://docs.apify.com/platform/actors/running/actors-in-store).
94
50
@@ -105,7 +61,7 @@ To start an Actor, you need its ID (e.g., `john-doe/my-cool-actor`) and an API t
105
61
</TabItem>
106
62
</Tabs>
107
63
108
-
### Providing input to Actor
64
+
### Passing input to the Actor
109
65
110
66
Actors often require input, such as URLs to scrape, search terms, or other configuration data. You can pass input as a JSON object when starting the Actor using the [`ActorClient.call`](/reference/class/ActorClient#call) method. Actors respect the input schema defined in the Actor's [input schema](https://docs.apify.com/platform/actors/development/actor-definition/input-schema).
111
67
@@ -122,7 +78,7 @@ Actors often require input, such as URLs to scrape, search terms, or other confi
122
78
</TabItem>
123
79
</Tabs>
124
80
125
-
###Getting results from the dataset
81
+
##Step 3: Getting results from the dataset
126
82
127
83
To get the results from the dataset, you can use the [`DatasetClient`](/reference/class/DatasetClient) ([`ApifyClient.dataset`](/reference/class/ApifyClient#dataset)) and [`DatasetClient.list_items`](/reference/class/DatasetClient#list_items) method. You need to pass the dataset ID to define which dataset you want to access. You can get the dataset ID from the Actor's run dictionary (represented by `defaultDatasetId`).
128
84
@@ -144,13 +100,3 @@ To get the results from the dataset, you can use the [`DatasetClient`](/referenc
144
100
Running an Actor might take time, depending on the Actor's complexity and the amount of data it processes. If you want only to get data and have an immediate response, you should access the existing dataset of the finished [Actor run](https://docs.apify.com/platform/actors/running/runs-and-builds#runs).
145
101
146
102
:::
147
-
148
-
## Next steps
149
-
150
-
Now that you're familiar with the basics, explore more advanced features:
151
-
152
-
-[Asyncio support](/concepts/asyncio-support) - Learn about asynchronous programming with the client
153
-
- Common use-case examples like:
154
-
-[Passing an input to Actor](/api/client/python/docs/examples/passing-input-to-actor)
155
-
-[Retrieve Actor data](/api/client/python/docs/examples/retrieve-actor-data)
156
-
-[API Reference](/api/client/python/reference) - Browse the complete API documentation
0 commit comments