# コレクションの管理

Hub上のSpaceを管理するためのメソッドの参考として、[HfApi](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi)のドキュメントページをご覧ください。

- コレクションのコンテンツを取得: [get_collection()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.get_collection)
- 新しいコレクションを作成: [create_collection()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.create_collection)
- コレクションの更新: [update_collection_metadata()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.update_collection_metadata)
- コレクションのリソースグループを更新します: [update_collection_resource_group()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.update_collection_resource_group)
- コレクションを削除します: [delete_collection()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.delete_collection)
- コレクションにアイテムを追加します: [add_collection_item()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.add_collection_item)
- コレクション内のアイテムを更新します: [update_collection_item()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.update_collection_item)
- コレクションからアイテムを削除します: [delete_collection_item()](/docs/huggingface_hub/v2.4.0/ja/package_reference/hf_api#huggingface_hub.HfApi.delete_collection_item)

### コレクション[[huggingface_hub.Collection]]

#### huggingface_hub.Collection[[huggingface_hub.Collection]]

```python
huggingface_hub.Collection(**kwargs)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/hf_api.py#L1381)

**パラメータ:**

slug (`str`) : コレクションのスラッグ。例: `"TheBloke/recent-models-64f9a55bb3115b4f513ec026"`。

title (`str`) : コレクションのタイトル。例: `"Recent models"`。

owner (`str`) : コレクションの所有者。例: `"TheBloke"`。

items (`list[CollectionItem]`) : コレクション内のアイテムのリスト。

last_updated (`datetime`) : コレクションの最終更新日。

position (`int`) : オーナーのコレクションリストにおける、そのコレクションの位置。

private (`bool`) : コレクションがプライベートかどうかを示します。

theme (`str`) : コレクションのテーマ。例: `"green"`。

upvotes (`int`) : コレクションの「いいね」数。

description (`str`, *任意*) : コレクションの説明をプレーンテキストとして指定します。

url (`str`) : (property) Hub 上のコレクションの URL。

Hub上のコレクションに関する情報を含みます。

### CollectionItem[[huggingface_hub.CollectionItem]]

#### huggingface_hub.CollectionItem[[huggingface_hub.CollectionItem]]

```python
huggingface_hub.CollectionItem(_id: str, id: str, type: CollectionItemType_T, position: int, note: dict | None = None, **kwargs)
```

[ソース](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/hf_api.py#L1333)

**パラメータ:**

item_object_id (`str`) : コレクション内のアイテムの一意のID。

item_id (`str`) : Hub 上の基盤オブジェクトの ID。repo_id、論文 ID、コレクションのスラッグ、またはバケット ID のいずれかです。例: `"jbilcke-hf/ai-comic-factory"`、`"2307.09288"`、`"celinah/cerebras-function-calling-682607169c35fbfa98b30b9a"`。

item_type (`str`) : 基底オブジェクトの型。`"model"`、`"dataset"`、`"space"`、`"paper"`、`"collection"`、`"bucket"` のいずれかです。

position (`int`) : コレクション内のアイテムの位置。

note (`str`, *任意*) : 項目に関連付けられた注釈。プレーンテキストとして指定します。

Collection（モデル、データセット、Space、論文、コレクション、またはバケット）のアイテムに関する情報を含みます。

