ユーザーのコレクションのリストの取得

ガイド コレクション ユーザーのコレクションのリストの取得

ユーザーのコレクションのリストの取得

ユーザーのすべてのコレクションのリストを取得するには、GET /collections APIを呼び出します。

cURL
curl -i -X GET "https://api.box.com/2.0/collections" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
BoxCollection<BoxCollectionItem> collections = await client.CollectionsManager.GetCollectionsAsync();
Java
Iterable<BoxCollection.Info> collections = BoxCollection.getAllCollections(api);
for (BoxCollection.Info collectionInfo : collections) {
	// Do something with the collection.
}
Python
collections = client.collections()
for collection in collections:
    print(f'Collection "{collection.name}" has ID {collection.id}')
Node
client.collections.getAll()
	.then(collections => {
		/* collections -> { total_count: 1,
			entries: 
			[ { type: 'collection',
				id: '11111',
				name: 'Favorites',
				collection_type: 'favorites' } ],
			limit: 100,
			offset: 0 }
		*/
	});

APIを介して使用できるコレクションは「お気に入り」コレクションのみです。このコレクションのIDはユーザーごとに異なります。

お気に入りコレクション

現在APIを介して項目を追加および削除できるコレクションは「お気に入り」コレクションのみです。

お気に入りコレクションのIDはユーザーごとに異なります。ユーザーのお気に入りのコレクションIDを確認するには、ユーザーの全コレクションのリストを取得し、collection_typefavoritesのコレクションを探します。

{
    "entries": [
        {
            "collection_type": "favorites",
            "id": "12345678",
            "name": "Favorites",
            "type": "collection"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total_count": 1
}