# `ApifyClient.Datasets`
[🔗](https://github.com/social-growth-studio/apify-client-ex/blob/v1.0.0/lib/apify_client/datasets.ex#L1)

Dataset items: read, stream and push them.

    {:ok, items} = ApifyClient.Datasets.list_items(dataset_id, limit: 100, clean: true)

    ApifyClient.Datasets.stream_items(dataset_id)
    |> Stream.map(&Map.fetch!(&1, "url"))
    |> Enum.to_list()

Items are returned as decoded JSON (maps with string keys), as the Actor
stored them.

Functions take the connection options described in `ApifyClient.Client`
(`:token`, `:config`, ...) next to their own. For everything else about
datasets, see `ApifyClient.API.Datasets` and `ApifyClient.API.Datasets.Items`.

# `list_items`

```elixir
@spec list_items(String.t(), keyword()) ::
  {:ok, [map()] | binary()} | {:error, ApifyClient.Error.t()}
```

Gets one page of items.

With the default JSON format the items come back as a list of maps. With
another `:format` (`"csv"`, `"xlsx"`, `"jsonl"`, `"html"`, `"xml"`, `"rss"`) the
body comes back as a binary.

## Options

The options of `ApifyClient.API.Datasets.Items.list/2`, among them:

  * `:offset`, `:limit` - the page (the API returns at most 1000 items per page)
  * `:clean` - leave out empty and hidden items and fields (`skip_empty` and
    `skip_hidden` together)
  * `:fields`, `:omit` - fields to include or leave out, as a list
  * `:desc` - newest items first
  * `:format` - see above

# `push_items`

```elixir
@spec push_items(String.t(), map() | [map()], keyword()) ::
  :ok | {:error, ApifyClient.Error.t()}
```

Adds items to a dataset: one item (a map) or a list of them.

Items are sent as JSON with their keys as given.

# `stream_items`

```elixir
@spec stream_items(String.t(), keyword()) :: Enumerable.t()
```

Streams all items, fetching them page by page as the stream is consumed.

Raises `ApifyClient.Error` if a page can't be fetched.

## Options

The options of `list_items/2` (always in JSON format), where `:offset` and
`:limit` apply to the whole stream, plus:

  * `:page_size` - items per request (default and maximum: 1000)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
