关于通过Google Photos API获取用户回忆(Memories)的技术问询
Hey there,
I totally get where you're coming from—trying to pull up those nostalgic Memories via the Google Photos API can feel like hitting a wall at first, since it's not explicitly called out in the official docs. Let me break down what I know about this scenario:
First, the straight-up truth: The Google Photos API doesn't currently have a dedicated endpoint or method specifically built to fetch "Memories" directly. Those curated, personalized collections are part of Google's internal personalization logic, which hasn't been exposed publicly through the API yet.
But don't worry—there are workarounds that can get you pretty close to replicating the Memories functionality programmatically:
Mimic Memories with date-based search filters: Memories typically resurface content from the same date in previous years, or media that's been untouched for a long time. You can use the API's
searchendpoint with adateFilterto target these timeframes. For example, to pull media from exactly 3 years ago, your request body might look like this:{ "pageSize": 15, "filters": { "dateFilter": { "dates": [ { "year": 2020, "month": 10, "day": 12 } ] } } }You'd just dynamically calculate the target date (e.g., current date minus N years) to match the kind of content Memories surfaces.
Combine filters to narrow down relevant content: While there's no "MEMORIES" flag in the API's
featureFilter, you can pair date filters with other criteria to refine results. For example, you might filter for media types (photos vs. videos) or exclude items marked as favorites (since Memories often includes less frequently interacted content).
A quick heads-up: Google might expand the API to include dedicated Memories support down the line, so it's worth checking the official docs periodically for new endpoints or parameters. Also, make sure your OAuth setup includes the https://www.googleapis.com/auth/photoslibrary.readonly scope—you'll need that to access a user's media items.
Hope these tips help you build a solution that fits your project needs!
备注:内容来源于stack exchange,提问作者Ben Rosenbaum

