# `HuggingfaceClient.Hub.Collections`
[🔗](https://github.com/huggingface/huggingface_client/blob/v0.1.0/lib/huggingface_client/hub/collections.ex#L1)

CRUD operations for HuggingFace Hub Collections.

Collections group models, datasets, spaces, and papers under a curated list.

## Usage

    # Lazy-stream all public collections
    HuggingfaceClient.Hub.Collections.list()
    |> Stream.take(10)
    |> Enum.to_list()

    # Get a single collection by slug
    {:ok, col} = HuggingfaceClient.Hub.Collections.get("open-llm-leaderboard", [])

# `add_item`

```elixir
@spec add_item(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Exception.t()}
```

Adds an item to a collection.

## Required options

- `:type` — `"model"` | `"dataset"` | `"space"` | `"paper"`
- `:id`   — item id (e.g. `"gpt2"`, `"arxiv:2406.11717"`)

# `create`

```elixir
@spec create(keyword()) :: {:ok, map()} | {:error, Exception.t()}
```

Creates a new collection owned by the authenticated user or org.

## Required options

- `:title` — display title
- `:namespace` — owner username or org slug

## Optional options

- `:description`, `:private` (default false), `:access_token`

# `delete`

```elixir
@spec delete(
  String.t(),
  keyword()
) :: :ok | {:error, Exception.t()}
```

Deletes a collection by slug.

# `get`

```elixir
@spec get(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Exception.t()}
```

Fetches a single collection by its `slug`.

The slug is the short identifier shown in the collection URL, e.g.
`"open-llm-leaderboard"` from `huggingface.co/collections/open-llm-leaderboard`.

# `list`

```elixir
@spec list(keyword()) :: Enumerable.t()
```

Returns a lazy `Stream` of all public collections.

## Options

- `:owner` — filter by owner username/org
- `:item` — filter by item (e.g. `"models/gpt2"`)
- `:sort` — `"lastModified"` | `"trending"` | `"upvotes"`
- `:limit` — stop after N results (nil = all)
- `:access_token`

# `remove_item`

```elixir
@spec remove_item(String.t(), String.t(), keyword()) :: :ok | {:error, Exception.t()}
```

Removes an item from a collection by its item id.

# `update`

```elixir
@spec update(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Exception.t()}
```

Updates an existing collection.

## Required

- `:slug` — collection slug to update

## Optional

- `:title`, `:description`, `:private`, `:access_token`

---

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