3

I'm trying to refactor a Java application using the Picasa Web Albums API to using the new Google Photos api.

In Picasa API you had the PhotoEntry object, which represented the uploaded entity and one could access the URL to the uploaded image as follows:

photoEntry.getMediaThumbnails().get(0).getUrl();

This url could be used in a website as static content.

Currently I'm at a loss how to get a permanent url to an uploaded image with Google Photos API. There is the MediaItem object, which represents an uploaded image, but I can't figure out how to get a permanent url from it.

I find 2 types of url in the MediaItem API:

mediaItem.getBaseUrl()

This url expires after 60 minutes and

mediaItem.getProductUrl()

cannot be used for static content, since it requires to be logged in.

Anybody can tell me what I overlooked ?

Thanks Regards

sc3_2
  • 51
  • 5

1 Answers1

2

The Google Photos Library API is not designed for image hosting. If you'd like to embed images in another site, you may need to look at other hosting solutions, like Google Cloud Storage, Firebase Cloud Storage or similar.

You are correct, base URLs expire after 60 minutes and need to be refreshed. However, if you need a permanent URL to a media item that points to Google Photos, you can create a new album, share it and use the shareableURL that's returned as part of the shareInfo property. This URL is accessible without sign in and opens the shared album in Google Photos. You can find out more in the share media developer guide.

  • I didn't find a way to get a permanent URL to a media item. Could you explain how to do this? Thanks. – Michael Offengenden Apr 02 '19 at 21:48
  • @MichaelOffengenden if by "URL to a media item" you mean a permanent URL to an embeddable JPG image, then there is no way using the API. [You can do it by hand though](https://webapps.stackexchange.com/a/137631/23501). – kynan Jan 05 '20 at 11:46