ApifyClient.API.Datasets (apify_client v1.0.0)

Copy Markdown View Source

Provides API endpoints related to api/datasets

Summary

Functions

create(opts \\ [])

@spec create(opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.DatasetResource.t()}
  | {:error, ApifyClient.Error.t()}

Create dataset

Creates a dataset and returns its object. Keep in mind that data stored under unnamed dataset follows data retention period. It creates a dataset with the given name if the parameter name is used. If a dataset with the given name already exists then returns its object.

Options

  • name: Custom unique name to easily identify the dataset in the future.

delete(dataset_id, opts \\ [])

@spec delete(dataset_id :: String.t(), opts :: keyword()) ::
  :ok | {:error, ApifyClient.Error.t()}

Delete dataset

Deletes a specific dataset.

get(dataset_id, opts \\ [])

@spec get(dataset_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.DatasetResource.t()}
  | {:error, ApifyClient.Error.t()}

Get dataset

Returns dataset object for given dataset ID.

This does not return dataset items, only information about the storage itself. To retrieve dataset items, use the Get dataset items endpoint.

:::note

Keep in mind that attributes itemCount and cleanItemCount are not propagated right away after data are pushed into a dataset.

:::

There is a short period (up to 5 seconds) during which these counters may not match with exact counts in dataset items.

list(opts \\ [])

@spec list(opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.ListOfDatasets.t()}
  | {:error, ApifyClient.Error.t()}

Get list of datasets

Lists all of a user's datasets.

The response is a JSON array of objects, where each object contains basic information about one dataset.

By default, the objects are sorted by the createdAt field in ascending order, therefore you can use pagination to incrementally fetch all datasets while new ones are still being created. To sort them in descending order, use desc=1 parameter. The endpoint supports pagination using limit and offset parameters and it will not return more than 1000 array elements.

Options

  • offset: Number of items that should be skipped at the start. The default value is 0.

  • limit: Maximum number of items to return. The default value as well as the maximum is 1000.

  • desc: If true or 1 then the objects are sorted by the createdAt field in descending order. By default, they are sorted in ascending order.

  • unnamed: If true or 1 then all the storages are returned. By default, only named storages are returned.

  • ownership: Filter by ownership. If this parameter is omitted, all accessible datasets are returned.

    • ownedByMe: Return only datasets owned by the user.
    • sharedWithMe: Return only datasets shared with the user by other users.

statistics(dataset_id, opts \\ [])

@spec statistics(dataset_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.DatasetStatistics.t()}
  | {:error, ApifyClient.Error.t()}

Get dataset statistics

Returns statistics for given dataset.

Provides only field statistics.

update(dataset_id, body, opts \\ [])

@spec update(
  dataset_id :: String.t(),
  body :: map() | ApifyClient.Schemas.UpdateDatasetRequest.t(),
  opts :: keyword()
) ::
  {:ok, ApifyClient.Schemas.DatasetResource.t()}
  | {:error, ApifyClient.Error.t()}

Update dataset

Updates a dataset's name and general resource access level using a value specified by a JSON object passed in the PUT payload. The response is the updated dataset object, as returned by the Get dataset API endpoint.

Request Body

Content Types: application/json