Skip to content

Commit 3686206

Browse files
TC-MOszaganek
andauthored
docs: storage tasks (#2975)
Sharing and cross-run usage were documented three times over, once per storage type, and had drifted apart; this consolidates them into two shared pages (Share storage, Use storage from another run) that the type pages now link to. Along the way it corrects the storage rate limits against `apify-core`. --------- Co-authored-by: Edyta <142720610+szaganek@users.noreply.github.com>
1 parent 6ca0937 commit 3686206

21 files changed

Lines changed: 291 additions & 353 deletions

‎apify-api/openapi/openapi.yaml‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,25 +433,45 @@ info:
433433
The default rate limit is applied to every API endpoint except a few select ones, which have higher rate limits.
434434
Each API endpoint returns its rate limit in `X-RateLimit-Limit` header.
435435
436+
These endpoints have a rate limit of _35 requests per second per resource_:
437+
438+
* Batch ([add](#/reference/request-queues/batch-request-operations/add-requests),
439+
[delete](#/reference/request-queues/batch-request-operations/delete-requests))
440+
operations on requests in request queues
441+
* [List and lock head](#/reference/request-queues/queue-head-with-locks/list-and-lock-head) of a request queue
442+
443+
These endpoints have a rate limit of _100 requests per second per resource_:
444+
445+
* Download records from a key-value store as a ZIP archive
446+
436447
These endpoints have a rate limit of _200 requests per second per resource_:
437448
438449
* CRUD ([get](#/reference/key-value-stores/record/get-record),
439450
[put](#/reference/key-value-stores/record/put-record),
440451
[delete](#/reference/key-value-stores/record/delete-record))
441452
operations on key-value store records
453+
* [Get list of keys](#/reference/key-value-stores/key-collection/get-list-of-keys) in a key-value store
454+
455+
These endpoints have a rate limit of _350 requests per second per resource_:
442456
443-
These endpoints have a rate limit of _400 requests per second per resource_:
444-
* [Run Actor](#/reference/actors/run-collection/run-actor)
445-
* [Run Actor task asynchronously](#/reference/actor-tasks/runs-collection/run-task-asynchronously)
446-
* [Run Actor task synchronously](#/reference/actor-tasks/runs-collection/run-task-synchronously)
447-
* [Metamorph Actor run](#/reference/actors/metamorph-run/metamorph-run)
448-
* [Push items](#/reference/datasets/item-collection/put-items) to dataset
449457
* CRUD
450458
([add](#/reference/request-queues/request-collection/add-request),
451459
[get](#/reference/request-queues/request-collection/get-request),
452460
[update](#/reference/request-queues/request-collection/update-request),
453461
[delete](#/reference/request-queues/request-collection/delete-request))
454462
operations on requests in request queues
463+
* Request lock operations
464+
([prolong](#/reference/request-queues/request-lock/prolong-request-lock),
465+
[delete](#/reference/request-queues/request-lock/delete-request-lock))
466+
in request queues
467+
468+
These endpoints have a rate limit of _400 requests per second per resource_:
469+
470+
* [Run Actor](#/reference/actors/run-collection/run-actor)
471+
* [Run Actor task asynchronously](#/reference/actor-tasks/runs-collection/run-task-asynchronously)
472+
* [Run Actor task synchronously](#/reference/actor-tasks/runs-collection/run-task-synchronously)
473+
* [Metamorph Actor run](#/reference/actors/metamorph-run/metamorph-run)
474+
* [Push items](#/reference/datasets/item-collection/put-items) to dataset
455475
456476
### Rate limit exceeded errors
457477
<span id="/introduction/rate-limiting/rate-limit-exceeded-errors"></span>

‎sources/platform/storage/dataset/index.md‎

Lines changed: 27 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ toc_max_heading_level: 4
66
slug: /storage/dataset
77
---
88

9-
import Tabs from '@theme/Tabs';
10-
import TabItem from '@theme/TabItem';
11-
129
Dataset storage enables you to sequentially save and retrieve data. A unique dataset is automatically created and assigned to each Actor run when the first item is stored.
1310

14-
Typically, datasets comprise results from web scraping, crawling, and data processing jobs. You can visualize this data in a table, where each object is forming a row and its attributes are represented as columns. You have the option to export data in various formats, including JSON, CSV, XML, Excel, HTML Table, RSS or JSONL.
11+
Typically, datasets hold results from web scraping, crawling, and data processing jobs. The data is displayed as a table, where each object forms a row and its attributes form columns. You can export the data in JSON, CSV, XML, Excel, HTML table, RSS, or JSONL formats.
1512

1613
:::info Retention period
1714

18-
Named datasets are retained indefinitely. Unnamed datasets expire after 7 days unless otherwise specified. [Learn more](/storage#named-and-unnamed-storages)
15+
Named datasets are retained indefinitely. Unnamed datasets expire after 7 days unless otherwise specified. [Learn more](/storage#data-retention)
1916

2017
:::
2118

@@ -36,7 +33,7 @@ Dataset schemas are defined in the Actor's `.actor` folder and apply to the Acto
3633

3734
You can access your datasets in several ways:
3835

39-
- [Apify Console](https://console.apify.com) - provides an easy-to-understand interface.
36+
- [Apify Console](https://console.apify.com) - view and manage your datasets in a visual interface.
4037
- [Apify API](/api/v2) - to access your datasets programmatically.
4138
- [Apify API client](/api) - to access your datasets from any Node.js/Python application.
4239
- [Apify SDKs](/sdk) - when building your own JavaScript/Python Actor.
@@ -45,21 +42,19 @@ You can access your datasets in several ways:
4542

4643
In [Apify Console](https://console.apify.com), you can view your datasets in the [Storage](https://console.apify.com/storage) section under the [Datasets](https://console.apify.com/storage?tab=datasets) tab.
4744

48-
![Datasets in app](../images/datasets-app.png)
45+
![Datasets in Apify Console](../images/storage-types-dataset.svg)
4946

5047
To view or download a dataset:
5148

5249
1. Click on its **Dataset ID** to open the dataset detail page.
5350
1. Browse the data in **Table** or **JSON** view.
5451
1. Click **Export** to download the data in your preferred format.
5552

56-
Utilize the **Actions** menu to modify the dataset's name, which also affects its [retention period](/storage#data-retention), and to adjust [access rights](/account/collaboration). The **API** button allows you to explore and test the dataset's [API endpoints](/api/v2/storage-datasets).
57-
58-
![Datasets detail view](../images/datasets-detail.png)
53+
To rename the dataset (which affects its [retention period](/storage#data-retention)) or adjust its [access rights](/account/collaboration), use the **Actions** menu. To view and test the dataset's [API endpoints](/api/v2/storage-datasets), select **API**.
5954

6055
### Apify API
6156

62-
The [Apify API](/api/v2/storage-datasets) enables you programmatic access to your datasets using [HTTP requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).
57+
The [Apify API](/api/v2/storage-datasets) gives you programmatic access to your datasets using [HTTP requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).
6358

6459
If you are accessing your datasets using the `username~store-name` [store ID format](../index.md), you will need to use your secret API token. You can find the token (and your user ID) on the [API & Integrations](https://console.apify.com/settings/integrations) tab of **Settings** page of your Apify account.
6560

@@ -115,11 +110,7 @@ To add data to a dataset, issue a POST request to the [Put items](/api/v2/datase
115110
https://api.apify.com/v2/datasets/{DATASET_ID}/items
116111
```
117112

118-
:::caution Rate limit
119-
120-
API data push to a dataset is capped at _400 requests per second_ to avoid overloading the servers.
121-
122-
:::
113+
Pushes to a dataset are rate-limited. For details, see [Rate limiting](#rate-limiting).
123114

124115
Example payload:
125116

@@ -141,11 +132,13 @@ For further details and a breakdown of each storage API endpoint, refer to the [
141132

142133
### Apify API Clients
143134

135+
Apify provides API clients for JavaScript and Python applications.
136+
144137
#### JavaScript API client
145138

146-
The [JavaScript API client](/api/client/js/reference/class/DatasetClient) (`apify-client`) enables you access to your datasets from any Node.js application, whether hosted on the Apify platform or externally.
139+
With the [JavaScript API client](/api/client/js/reference/class/DatasetClient) (`apify-client`), you can access your datasets from any Node.js application, whether hosted on the Apify platform or externally.
147140

148-
After importing and initiating the client, you can save each dataset to a variable for easier access.
141+
After importing and initializing the client, you can save each dataset to a variable for easier access.
149142

150143
```js
151144
const myDatasetClient = apifyClient.dataset('jane-doe/my-dataset');
@@ -163,9 +156,9 @@ Check out the [JavaScript API client documentation](/api/client/js/reference/cla
163156

164157
#### Python API client
165158

166-
The [Python API client](/api/client/python/reference/class/DatasetClient) (`apify-client`) enables you access to your datasets from any Python application, whether it is running on the Apify platform or externally.
159+
With the [Python API client](/api/client/python/reference/class/DatasetClient) (`apify-client`), you can access your datasets from any Python application, whether it's running on the Apify platform or externally.
167160

168-
After importing and initiating the client, you can save each dataset to a variable for easier access.
161+
After importing and initializing the client, you can save each dataset to a variable for easier access.
169162

170163
```python
171164
my_dataset_client = apify_client.dataset('jane-doe/my-dataset')
@@ -183,11 +176,13 @@ Check out the [Python API client documentation](/api/client/python/reference/cla
183176

184177
### Apify SDKs
185178

179+
Apify provides SDKs for JavaScript and Python Actors.
180+
186181
#### JavaScript SDK
187182

188-
When working with a JavaScript [Actor](../../actors/index.mdx), the [JavaScript SDK](/sdk/js/docs/guides/result-storage#dataset) is an essential tool, especially for dataset management. It simplifies the tasks of storing and retrieving data, seamlessly integrating with the Actor's workflow. Key features of the SDK include the ability to append data, retrieve what is stored, and manage dataset properties effectively. Central to this functionality is the [`Dataset`](/sdk/js/reference/class/Dataset) class. This class allows you to determine where your data is stored - locally or in the Apify cloud. To add data to your chosen datasets, use the [`pushData()`](/sdk/js/reference/class/Dataset#pushData) method.
183+
In JavaScript [Actors](../../actors/index.mdx), manage datasets with the JavaScript SDK's [`Dataset`](/sdk/js/reference/class/Dataset) class. It works both locally and on the Apify platform. To add data, use the [`pushData()`](/sdk/js/reference/class/Dataset#pushData) method.
189184

190-
Additionally the SDK offers other methods like [`getData()`](/sdk/js/reference/class/Dataset#getData), [`map()`](/sdk/js/reference/class/Dataset#map), and [`reduce()`](/sdk/js/reference/class/Dataset#reduce). For practical applications of these methods, refer to the [example](/sdk/js/docs/examples/map-and-reduce) section.
185+
The SDK also provides other methods like [`getData()`](/sdk/js/reference/class/Dataset#getData), [`map()`](/sdk/js/reference/class/Dataset#map), and [`reduce()`](/sdk/js/reference/class/Dataset#reduce). For practical applications of these methods, refer to the [example](/sdk/js/docs/examples/map-and-reduce) section.
191186

192187
If you have chosen to store your dataset locally, you can find it in the location below.
193188

@@ -218,7 +213,7 @@ await Actor.exit();
218213

219214
:::caution Always await pushData()
220215

221-
It's crucial to use the `await` keyword when calling `pushData()`, to ensure data storage completes before the Actor process terminates.
216+
Always use the `await` keyword when calling `pushData()`. Without it, the Actor process can exit before the data is stored.
222217

223218
:::
224219

@@ -240,7 +235,7 @@ await dataset.pushData({ foo: 'bar' });
240235
await Actor.exit();
241236
```
242237

243-
Utilize the `fields` option in the [`getData()`](/sdk/js/reference/class/Dataset#getData) method to specify which data fields to retrieve. This option accepts an array of fields names (string) to include in your results.
238+
To specify which data fields to retrieve, use the `fields` option in the [`getData()`](/sdk/js/reference/class/Dataset#getData) method. This option accepts an array of field names (string) to include in your results.
244239

245240
```js
246241
import { Actor } from 'apify';
@@ -263,7 +258,7 @@ Check out the [JavaScript SDK documentation](/sdk/js/docs/guides/result-storage#
263258

264259
#### Python SDK
265260

266-
For Python [Actors](../../actors/index.mdx), the [Python SDK](/sdk/python/docs/concepts/storages#working-with-datasets) is essential. The dataset is represented by a [`Dataset`](/sdk/python/reference/class/Dataset) class. You can use this class to specify whether your data is stored locally or in the Apify cloud and push data to the datasets of your choice using the [`push_data()`](/sdk/python/reference/class/Dataset#push_data) method. For further data manipulation you could also use other methods such as [`get_data()`](/sdk/python/reference/class/Dataset#get_data), [`map()`](/sdk/python/reference/class/Dataset#map) and [`reduce()`](/sdk/python/reference/class/Dataset#reduce).
261+
In Python [Actors](../../actors/index.mdx), manage datasets with the Python SDK's [`Dataset`](/sdk/python/reference/class/Dataset) class. It works both locally and on the Apify platform. To add data, use [`push_data()`](/sdk/python/reference/class/Dataset#push_data); to read and transform it, use [`get_data()`](/sdk/python/reference/class/Dataset#get_data), [`map()`](/sdk/python/reference/class/Dataset#map), and [`reduce()`](/sdk/python/reference/class/Dataset#reduce).
267262

268263
For datasets stored locally, the data is located at the following path:
269264

@@ -301,7 +296,7 @@ async def main():
301296
await dataset.push_data({'foo': 'bar'})
302297
```
303298

304-
Utilize the `fields` option in the [`get_data()`](/sdk/python/reference/class/Dataset#get_data) method to specify which data fields to retrieve. This option accepts an array of fields names (string) to include in your results.
299+
To specify which data fields to retrieve, use the `fields` option in the [`get_data()`](/sdk/python/reference/class/Dataset#get_data) method. This option accepts an array of field names (string) to include in your results.
305300

306301
```python
307302
from apify import Actor
@@ -378,7 +373,7 @@ becomes the following XML snippet:
378373
</address>
379374
```
380375

381-
In a JavaScript object, if a property is named `@`, its sub-properties are exported as attributes of the corresponding parent XML element. Additionally, when the parent XML element lacks child elements, its value is sourced from a property named `#` in the JavaScript Object.
376+
In a JavaScript object, if a property is named `@`, its sub-properties are exported as attributes of the corresponding parent XML element. When the parent XML element lacks child elements, its value comes from a property named `#` in the JavaScript object.
382377

383378
For example, the following JavaScript object:
384379

@@ -416,84 +411,24 @@ This feature is also useful when customizing your RSS feeds generated for variou
416411

417412
By default, the whole result is wrapped in an `<items/>` element, while each page object is contained in an `<item/>` element. You can change this using the `xmlRoot` and `xmlRow` URL parameters when retrieving your data with a GET request.
418413

419-
## Share
420-
421-
You can grant [access rights](/account/collaboration) to your dataset through the **Share** button under the **Actions** menu. For more details, check the [full list of permissions](/account/collaboration/list-of-permissions).
422-
423-
You can also share datasets by link using their ID or name, depending on your account or resource-level general access setting. Learn how link-based access works in [General resource access](/account/collaboration/general-resource-access).
424-
425-
For one-off sharing of specific records when access is restricted, you can generate time-limited pre-signed URLs. See [Sharing restricted resources with pre-signed URLs](/account/collaboration/general-resource-access#pre-signed-urls).
426-
427-
### Share datasets between runs
428-
429-
You can access a dataset from any [Actor](../../actors/index.mdx) or [task](../../actors/running/tasks.md) run as long as you know its _name_ or _ID_.
430-
431-
To access a dataset from another run using the [Apify SDK](/sdk), open it using the same method as you would with any other dataset.
432-
433-
<Tabs groupId="main">
434-
<TabItem value="JavaScript" label="JavaScript">
435-
436-
```js
437-
import { Actor } from 'apify';
438-
439-
await Actor.init();
440-
441-
const otherDataset = await Actor.openDataset('old-dataset');
442-
// ...
443-
444-
await Actor.exit();
445-
```
446-
447-
</TabItem>
448-
<TabItem value="Python" label="Python">
449-
450-
```python
451-
from apify import Actor
452-
453-
async def main():
454-
async with Actor:
455-
other_dataset = await Actor.open_dataset(name='old-dataset')
456-
# ...
457-
```
458-
459-
</TabItem>
460-
</Tabs>
461-
462-
In the [JavaScript API client](/api/client/js/reference/class/DatasetClient) as well as in [Python API client](/api/client/python/reference/class/DatasetClient) , you can access a dataset using its client. Once you've opened the dataset, you can read its contents and add new data in the same manner as you would for a dataset from your current run.
463-
464-
<Tabs groupId="main">
465-
<TabItem value="JavaScript" label="JavaScript">
466-
467-
```js
468-
const otherDatasetClient = apifyClient.dataset('jane-doe/old-dataset');
469-
```
470-
471-
</TabItem>
472-
<TabItem value="Python" label="Python">
473-
474-
```python
475-
other_dataset_client = apify_client.dataset('jane-doe/old-dataset')
476-
```
477-
478-
</TabItem>
479-
</Tabs>
414+
## Share and reuse {#share}
480415

481-
The same applies for the [Apify API](#apify-api) - you can use [the same endpoints](#apify-api) as you would normally do.
416+
You can grant access rights to your dataset, share it by link, or generate a time-limited pre-signed URL for specific items. For details, see [Share storage](../share.md).
482417

483-
See the [Storage overview](/storage#share-storages-between-runs) for details on sharing storages between runs.
418+
To read from or write to a dataset that belongs to a different Actor or task run, see [Use storage from another run](../use-from-another-run.md).
484419

485420
## Limits
486421

487422
- Data storage formats that use tabulation (like HTML, CSV, and Excel) are limited to a maximum of _2000_ columns. Data exceeding this limit will not be retrieved.
488423

489-
- The `pushData()`method is constrained by the receiving API's size limit. It accepts objects with JSON size under _9MB_. While individual objects within an array must not exceed _9MB_, the overall size has no restriction.
424+
- The `pushData()` method is constrained by the receiving API's size limit. It accepts objects with JSON size under 9MB. While individual objects within an array must not exceed 9MB, the overall size has no restriction.
490425

491426
- The maximum length for dataset names is 63 characters.
492427

493428
### Rate limiting
494429

495430
The rate limit for pushing data to a dataset through the [API](/api/v2/dataset-items-post) is capped at _400 requests per second_ for each dataset, a measure to prevent overloading Apify servers.
496431

497-
For all other dataset [API endpoints](/api/v2/storage-datasets) , the rate limit is _60 requests per second_ for each dataset.
432+
For all other dataset [API endpoints](/api/v2/storage-datasets), the rate limit is 60 requests per second for each dataset.
498433

499434
Check out the [API documentation](/api/v2#rate-limiting) for more information and guidance on actions to take if you exceed these rate limits.

‎sources/platform/storage/dataset/multiple_datasets.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Multiple datasets
3-
description: Learn how to use multiple datasets within your Actors to organize and store different types of data separately.
2+
title: Use multiple datasets
3+
description: Define more than one dataset in your Actor, write to each from your code, and surface them on the run page so users can find the right output.
44
sidebar_position: 3
55
slug: /storage/dataset-schema/multiple-datasets
66
---

‎sources/platform/storage/dataset/validation.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Dataset validation
2+
title: Validate dataset output
33
description: Specify the dataset schema within your Actors to add monitoring and validation at the field level, ensuring data quality and consistency across runs.
44
sidebar_position: 2
55
slug: /storage/dataset-schema/validation
-71.4 KB
Binary file not shown.
-112 KB
Binary file not shown.
-39.4 KB
Binary file not shown.
-72.1 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)