ユーザーのコレクションのリストの取得
ユーザーのコレクションのリストの取得
ユーザーのすべてのコレクションのリストを取得するには、GET /collections
APIを呼び出します。
cURL
curl -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('Collection "{0}" has ID {1}'.format(collection.name, 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 }
*/
});
Favoritesコレクション
現在APIを介して項目を追加および削除できるコレクションは「Favorites」コレクションのみです。
FavoritesコレクションのIDはユーザーごとに異なります。ユーザーのお気に入りのコレクションIDを確認するには、ユーザーの全コレクションのリストを取得し、collection_type
がfavorites
のコレクションを探します。
{
"entries": [
{
"collection_type": "favorites",
"id": "12345678",
"name": "Favorites",
"type": "collection"
}
],
"limit": 100,
"offset": 0,
"total_count": 1
}