My ultimate goal is to get a list with all the files (photos, videos) in my Google Photos account preferably with their path.
If I have to use some API I would rather use a .NET based one. Can you provide some directions in this matter?
I've tried the Gdata API, via the PicasaService, but providing my email/password as credentials did not work and I always get 404 response.
This answer is outdated and will no longer work as Picasa and its API have been shut down
I was surprised at how long it took me to find this API. It's not necessarily "secret information", but I suppose most users are perfectly happy viewing their Google Photos "the old fashioned way". My initial goal was to be able to determine which photos had/had not properly uploaded before I risk deleting anything as valuable as even my "3rd backup copy" of old photos.
Like so many things in life, there's an easy way and a hard way.
Depending on your point of view, the hard way is often more fun and/or more fulfilling...
Make sure you're logged into your Google Account on your "usual" (default) browser.
You'll get a text-based list of all your Google Photos Albums. Both the album list and the photo list look suspiciously like RSS Feeds (and can be bookmarked as such if you should so desire).
I know you don't want to copy your list of photos manually, but I suspect others that come across this question want the "easy" way:
After opening the API URL, click the first album link.
hit Ctrl+A then Ctrl+C to copy text from the page
go to your favorite text editor (Notepad++, Excel, oldschool Notepad, etc) and hit Ctrl+V
go back to the photo list, click your browser's Back button and repeat for each album.
Authentication: For the sake of simplicty, first make sure you are signed in to your Google account from any Google page, such as from the top-right corner of the Google Search page. This will allow you to use the generic addresses listed below -- otherwise the word "default
" would need to be replaced with your Google ID, as as well as other changes to accomodate Google API Authentication.
If you have a preferred method of sending GET requests then all you'll need is two URL's.
As I understand it, all Google Photos are stored in Albums (even if they don't appear to be). Therefore, in order to list all photos, you must parse all of your albums, listing the photos in each one.
The GET
call to list your Google Photos albums is:
https://picasaweb.google.com/data/feed/api/user/default
The GET
call to list all photos within an album is:
https://picasaweb.google.com/data/feed/api/user/default/albumid/__[albumID]__
.NET Example from Google:
PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(username, albumid));
PicasaFeed feed = service.Query(query);
foreach (PicasaEntry entry in feed.Entries)
{
Console.WriteLine(entry.Title.Text);
}
★ The string "
default
" can be used in place of a real username, in which case the server will use the username of the current user credentials used to authenticate the request.
More Info: Google Picasa .NET Developer's Guide: Request a List of Photos
Excel has built-in XML-Parsing functionality, in various forms:
...but not even the newest features seem to support enough [of what I assume to be] variations in XML style/source, to be of use to me... (or maybe I'm just doing something wrong.
Thus, my preferred method for parsing XML is to simply load it into a String with an HttpRequest
and then use Instr
and Mid
to locate the values I'm interested in. It's messy, but I've used it as a "quick fix" to retrieve several types of data from several types of sites.
While writing this answer I seem to have misplaced my related code (side effect of over-multitasking?!) -- but if you made it this far, you probably get the gist of it. The simple function for retrieving the source from a URL is below. If you're interested in seeing the rest, add a comment and I'll look harder. :-)
Public Function getHTTP(ByVal url As String) As String
'equivalent to Excel's WEBSERVICE function
Dim encResp() As Byte, xmlHTTP As Object
Set xmlHTTP = CreateObject("MSXML2.XMLHTTP") 'create XML/HTTP object
xmlHTTP.Open "GET", url, False 'initialize GET request
xmlHTTP.send 'send request to remote server
encResp = xmlHTTP.responseBody 'receive raw (encoded) response
Set xmlHTTP = Nothing 'always clean up after yourself!
getHTTP = StrConv(encResp, vbUnicode) 'return decoded response
End Function
Also a sneaky way to quickly count occurrences of one string within another:
Function countOccur(searchWithin As String, toFind As String) As String
'returns the count of occurrences of [toFind] within [searchWithin]
countOccur = UBound(Split(searchWithin, toFind))
End Function
Counting occurrences of <entry>
on an album or photo page returns the count of albums or photos on that page.