@@ -17,8 +17,8 @@ It provides useful features like automatic retries and convenience functions tha
17
17
18
18
Requires Python 3.7+
19
19
20
- Right now the client is not available on PyPI yet, so you can install it only from its [ git repo ] ( https://github.com/apify /apify-client-python ) .
21
- To do that, run ` pip install git+https://github.com/ apify/apify -client-python.git `
20
+ You can install the client from its [ PyPI listing ] ( https://pypi.org/project /apify-client/ ) .
21
+ To do that, simply run ` pip install apify-client ` .
22
22
23
23
## Quick Start
24
24
@@ -31,7 +31,7 @@ apify_client = ApifyClient('MY-APIFY-TOKEN')
31
31
actor_call = apify_client.actor(' john-doe/my-cool-actor' ).call()
32
32
33
33
# Fetch results from the actor's default dataset
34
- dataset_items = apify_client.dataset(actor_call[' defaultDatasetId' ]).list_items()[ ' items' ]
34
+ dataset_items = apify_client.dataset(actor_call[' defaultDatasetId' ]).list_items(). items
35
35
```
36
36
37
37
## Features
@@ -74,16 +74,16 @@ apify_client = ApifyClient('MY-APIFY-TOKEN')
74
74
# Collection clients do not require a parameter
75
75
actor_collection_client = apify_client.actors()
76
76
# Create an actor with the name: my-actor
77
- my_actor = actor_collection_client.create({ name: ' my-actor' } )
77
+ my_actor = actor_collection_client.create(name = ' my-actor' )
78
78
# List all of your actors
79
- actor_list = actor_collection_client.list()[ ' items' ]
79
+ actor_list = actor_collection_client.list(). items
80
80
```
81
81
82
82
``` python
83
83
# Collection clients do not require a parameter
84
84
dataset_collection_client = apify_client.datasets()
85
85
# Get (or create, if it doesn't exist) a dataset with the name of my-dataset
86
- my_dataset = dataset_collection_client.get_or_create(' my-dataset' )
86
+ my_dataset = dataset_collection_client.get_or_create(name = ' my-dataset' )
87
87
```
88
88
89
89
``` python
@@ -92,14 +92,14 @@ actor_client = apify_client.actor('john-doe/my-actor')
92
92
# Fetch the john-doe/my-actor object from the API
93
93
my_actor = actor_client.get()
94
94
# Start the run of john-doe/my-actor and return the Run object
95
- my_actor_run = actor_client.start();
95
+ my_actor_run = actor_client.start()
96
96
```
97
97
98
98
``` python
99
99
# Resource clients accept an ID of the resource
100
100
dataset_client = apify_client.dataset(' john-doe/my-dataset' )
101
101
# Append items to the end of john-doe/my-dataset
102
- dataset_client.push_items([{ " foo" : 1 }, { " bar" : 2 }])
102
+ dataset_client.push_items([{ ' foo' : 1 }, { ' bar' : 2 }])
103
103
```
104
104
105
105
> The ID of the resource can be either the ` id ` of the said resource,
@@ -117,18 +117,14 @@ nested collections, such as runs of a given actor.
117
117
actor_client = apify_client.actor(' john-doe/my-actor' )
118
118
runs_client = actor_client.runs()
119
119
# List the last 10 runs of the john-doe/hello-world actor
120
- actor_runs = runs_client.list(limit = 10 , desc = True )[ ' items' ]
120
+ actor_runs = runs_client.list(limit = 10 , desc = True ). items
121
121
122
122
# Select the last run of the john-doe/hello-world actor that finished with a SUCCEEDED status
123
123
last_succeeded_run_client = actor_client.last_run(status = ' SUCCEEDED' )
124
124
# Fetch items from the run's dataset
125
- dataset_items = last_succeeded_run_client.dataset().list_items()[ ' items' ]
125
+ dataset_items = last_succeeded_run_client.dataset().list_items(). items
126
126
```
127
127
128
- > The quick access to ` dataset ` and other storages directly from the run
129
- > client can now only be used with the ` last_run() ` method, but the feature
130
- > will be available to all runs in the future.
131
-
132
128
### Pagination
133
129
134
130
Most methods named ` list ` or ` list_something ` return a [ ` ListPage ` ] ( #ListPage ) object,
@@ -1108,9 +1104,6 @@ Run status will be updated to RUNNING and its container will be restarted with t
1108
1104
1109
1105
Get the client for the default dataset of the actor run.
1110
1106
1111
- Currently this works only through actor_client.last_run().dataset().
1112
- It will become available for all runs once the API supports it.
1113
-
1114
1107
[ https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages ] ( https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages )
1115
1108
1116
1109
* ** Returns**
@@ -1127,9 +1120,6 @@ It will become available for all runs once the API supports it.
1127
1120
1128
1121
Get the client for the default key-value store of the actor run.
1129
1122
1130
- Currently this works only through actor_client.last_run().key_value_store().
1131
- It will become available for all runs once the API supports it.
1132
-
1133
1123
[ https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages ] ( https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages )
1134
1124
1135
1125
* ** Returns**
@@ -1146,9 +1136,6 @@ It will become available for all runs once the API supports it.
1146
1136
1147
1137
Get the client for the default request queue of the actor run.
1148
1138
1149
- Currently this works only through actor_client.last_run().request_queue().
1150
- It will become available for all runs once the API supports it.
1151
-
1152
1139
[ https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages ] ( https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages )
1153
1140
1154
1141
* ** Returns**
@@ -1165,9 +1152,6 @@ It will become available for all runs once the API supports it.
1165
1152
1166
1153
Get the client for the log of the actor run.
1167
1154
1168
- Currently this works only through actor_client.last_run().log().
1169
- It will become available for all runs once the API supports it.
1170
-
1171
1155
[ https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages ] ( https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages )
1172
1156
1173
1157
* ** Returns**
0 commit comments