Reputation: 7411
I was going through the documentation for the new Google Photos API, but unable to find any information for the album metadata along with photo information.
Like, if I am using a List library contents API with filter, the resultant photos does not provide me the details of the albums that photo belongs to.
Is it even possible with the current API?
I checked in the mediaItems ref also. Unable to find such item. Has anyone explored this thing?
Upvotes: 4
Views: 3402
Reputation: 405
Yes you can get the media of a specific album.
See this documentation Listing album contents
To list all of the media items in an album, add the albumId field to your search request. For more information about albumId, see Listing albums. If the albumId is invalid, a Bad Request error is returned. If the ID is valid, but the album doesn't exist for the authenticated user, a Not Found error is returned. For more details regarding error handling, see Performance tips and Best practices.
POST https://photoslibrary.googleapis.com/v1/mediaItems:search
Content-type: application/json
Authorization: Bearer OAUTH2_TOKEN
{
"pageSize":"100",
"albumId": "ALBUM_ID"
}
Upvotes: 0
Reputation: 1106
A media item can belong to multiple albums, some of which might be shared.
However, the Library API does not provide a mapping from a media item back to albums it belongs to. You could file a feature request and describe your use case if this is something that is missing for you. Be sure to describe how you would use this feature.
If you want to see if a particular media item (e.g. one you have found via a search) is part of an album, you need to compare their IDs. For example, you could list the contents of an album and check if the ID of the media item you are interested in is part of the response.
Upvotes: 4