Google-photos – How to get a list of albums in Google Photos

albumgoogle-photos

I have many albums in Google Photos. (Maybe 200). I want to get a list of these albums along with their urls. How can I do this?

To put it in context, I want to send an email listing many of these albums to friends. As a workaround I can, in principle, click into each album in the Google Photos web interface. Then click "More options" then click "Sharing options" then click "COPY". Then I can paste this url somewhere. But that's an absolute best case of 5 or 6 clicks times 200. It's probably much higher.

Surely there is an API I can use in a hacky one-time sort of way to get a list of all of my albums. No? It seems like this should be simple. Can someone point me to the documentation that I'm not finding? I don't even see where in the world of Google to ask this question. I have found a similar question, but it's unanswered. It seems that today (2016-03-05) the Picasa Web Albums Data API is probably what I need. But I'm not sure.

My ideal solution is probably to have a simple script in a Google Sheet to grab a list of all Albums: Names in one column and public url (if it exists) in another column. But I'll settle for ANY way of getting a list of all my albums with their urls.

UPDATE: Sally, raised the possibility of screen scraping to get the answer. I love this idea! But I'm unable to use her idea, so I'm adding this angle to the question to provoke a clearer answer.

I'm able to list all of my shared albums at this url: https://photos.google.com/shared

I would like to obtain the public url for all of these albums. But the public url, which has this form: https://goo.gl/photos/Rw5gpSaD4ikadj6M9, is not found in the source code for the page. I must click into each album and then click "Share" to find the public url.

In short: obtaining the complete list of my shared albums with their public urls via API, screen scraping, or any other means would meet my requirement.

Best Answer

The Google Photos interface is very minimal even for humans, let alone applications. The best way I found to get a list of album names and URLs is to parse the page source using the browser console.

The list of all albums

Executed on the page https://photos.google.com/albums, this script returns a string that can be copy-pasted to a Google Sheet, creating a table of names and URLs.

var links = document.getElementsByTagName('A'); 
var s = ''; 
for (var i = 0; i< links.length; i++) {
  if (/\b(album|share)\b/.test(links[i].href)) {
    var albumName = links[i].children[3].children[0].innerText;
    s = s + albumName + '\t' + links[i].href + '\n';
  }
}

The list of shared albums

Executed on the page https://photos.google.com/shared, this script returns the list of album names and URLs.

var links = document.getElementsByTagName('A'); 
var s = ''; 
for (var i = 0; i< links.length; i++) {
  if (/\b(album|share)\b/.test(links[i].href)) {
    s = s + links[i].innerText + '\t' + links[i].href + '\n';
  }
}

The URLs are in the long format: https://photos.google.com/share/...?key=..., not in the short format https://goo.gl/photos/... that you would get by clicking the share button. But they are functionally equivalent: the latter redirects to the former after going through Google's URL shortening service goo.gl. If length is a concern, you can shorten them yourself within Google Sheets by using an Apps Script for generating goo.gl URLs.