List User's Collections
List User's Collections
To list all collections for a user, call the GET /collections
API.
cURL
curl -i -X GET "https://api.box.com/2.0/collections" \
-H "authorization: Bearer <ACCESS_TOKEN>"
Node/TypeScript v10
await client.collections.getCollections();
Python v10
client.collections.get_collections()
.NET v10
await client.Collections.GetCollectionsAsync();
Swift v10
try await client.collections.getCollections()
Java v4
Iterable<BoxCollection.Info> collections = BoxCollection.getAllCollections(api);
for (BoxCollection.Info collectionInfo : collections) {
// Do something with the collection.
}
Python v3
collections = client.collections()
for collection in collections:
print(f'Collection "{collection.name}" has ID {collection.id}')
.NET v5
BoxCollection<BoxCollectionItem> collections = await client.CollectionsManager.GetCollectionsAsync();
Node v3
client.collections.getAll()
.then(collections => {
/* collections -> { total_count: 1,
entries:
[ { type: 'collection',
id: '11111',
name: 'Favorites',
collection_type: 'favorites' } ],
limit: 100,
offset: 0 }
*/
});
Favorites Collection
The only collection that can items can currently be added and removed to via the API is the "Favorites" collection.
The ID of the favorites collection is different for every user. To find the
user's collection ID for their favorites, list all the user's collections and
then find the collection with a collection_type
of favorites
.
{
"entries": [
{
"collection_type": "favorites",
"id": "12345678",
"name": "Favorites",
"type": "collection"
}
],
"limit": 100,
"offset": 0,
"total_count": 1
}