4

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?

kirtan403
  • 7,293
  • 6
  • 54
  • 97

2 Answers2

4

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.

  • Hi, thank you so much for your response. However, I would also like to know the reason, why I can't added photos to the free storage? Most of users are using the free storage service. If I have an app that creates a HD resolution video from the google photos, they are likely to run of storage in on 15 videos of 1 GB each. – kirtan403 Sep 22 '18 at 13:53
  • I've written a simple code using GET /albums, then POST /mediaItems:search?albumId = to get each album's media items and then cross referenced them with a full list of media items returned by GET /mediaItems. It worked reasonably well however I've noticed a problem with a shared item id. The id of a shared item returned as part of the albumId search (POST /mediaItems:search?albumId) does not match an id of the same item returned by the full list (GET /mediaItems). It seems to be happening for every shared media item. In addition, there is no way to tell if an item is shared. Any ideas? – pavel Feb 09 '21 at 01:40
  • Here is the github project https://github.com/pavelfomin/gphoto-manager – pavel Feb 11 '21 at 02:13
  • For a shared album owned by account A, if a media item is added from another account B then its id won't be found in the list of the media items of the account A. If such a shared media item then saved in account A its id won't match the id of the original shared media item added to the shared album. W/out an indicator of some sort to identify if a media item belongs to another account it's challenging to filter them out. – pavel Feb 11 '21 at 02:20
0

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"
}
Dushy
  • 375
  • 3
  • 13