Create, update, read, or delete albums on OneDrive (REST)

Create, update, read, or delete a user's album on OneDrive by using the Live SDK REST API.

In this article
Prerequisites
Create an album
Update an album
Read an album
Delete an album
Remarks

This tutorial shows you how to create, update, read, and delete albums from a user's Microsoft OneDrive, by using the Live SDK REST API.

Prerequisites

We assume that the user has already signed in and consented to the wl.skydrive scope for reading file or folder properties. If you have not added user sign-in to your apps, see Signing users in with REST.

We assume that you are familiar with the REST API and JSON.

Create an album

To add a new album, use code like this. The wl.skydrive_update scope is required.

Note

You can create albums only in the user's top-level OneDrive folder, represented here as me/albums.

POST https://apis.live.net/v5.0/me/albums

Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

{
    "name": "My example album"
}

Update an album

To change info for an existing album, use code like this. The wl.skydrive_update scope is required.

PUT https://apis.live.net/v5.0/folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!111

Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

{
    "name": "My example album has changed"
}

Read an album

To get info about an album, you can use code like this. The wl.photos or wl.skydrive scope is required.

To use this code, change the album ID to this:

  • A different album ID, to get info about another album.

  • me/albums, to get info about all of the signed-in user's albums.

  • /me/skydrive/shared/albums, to get info about all of the signed-in user's shared albums.

  • USER_ID/albums, to get info about all of a user's albums that correspond to a valid USER_ID.

GET https://apis.live.net/v5.0/folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!111?access_token=ACCESS_TOKEN

You can also do this:

  • Use ALBUM_ID/photos or ALBUM_ID/videos, to get a list of all photos or videos in an album. Then your code can make another call that uses a specific photo ID or video ID to get the info for that photo or video.

  • Use ALBUM_ID/files to get a list of all photos, videos, audio, child albums, and child folders in an album. Then your code can make another call that uses a specific photo ID, video ID, album ID, audio ID, or folder ID to get the info for that photo, video, album, audio, or folder.

    Note

    You can get info about an album's photos, videos, audio, child albums, and child folders only.

  • Use ALBUM_ID/picture to get a picture of an album's cover.

  • Get a limited number of items by using the limit parameter in the preceding code to specify the number of items to get. For example, to get the first two items, use ALBUM_ID/files?limit=2.

  • Set the first item to start getting by using the offset parameter in the preceding code to specify the index of the first item to get. For example, to get two items starting at the third item, use ALBUM_ID/files?limit=2&offset=3.

    Note

    In the JavaScript Object Notation (JSON)-formatted object that's returned, you can look in the paging object for the previous and next structures to get the offset and limit parameter values of the previous and next entries.

  • Set the items' sort criteria by using the sort_by parameter in the preceding code to specify the criteria: updated, name, size, or default. For example, to sort the items by name, use ALBUM_ID/files?sort_by=name.

  • Set the items' sort order by using the sort_order parameter in the preceding code to specify the order: ascending or descending. For example, to sort the items in descending order, use ALBUM_ID/files?sort_by=descending.

Delete an album

To remove an album, use code like this. The wl.skydrive_update scope is required. Change the album ID to the album ID of the album that you want to remove

DELETE https://apis.live.netv/5.0/folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!111?access_token=ACCESS_TOKEN

Remarks

For details about the minimum required and optional structures that your app must provide when using PUT or POST, see the Album object.