[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-29 UTC。"],[[["\u003cp\u003eThe Google Photos Library API allows you to access and list media items created by your application, including photos and videos.\u003c/p\u003e\n"],["\u003cp\u003eYou can list media items from specific app-created albums or the entire app-created library, applying filters (date, content category, media type) to refine results.\u003c/p\u003e\n"],["\u003cp\u003eWhen listing media items, you receive \u003ccode\u003emediaItem\u003c/code\u003e objects containing essential details like direct links and metadata; however, remember to store the \u003ccode\u003emediaItem\u003c/code\u003e ID and re-request details when needed to avoid caching issues.\u003c/p\u003e\n"],["\u003cp\u003eUtilize pagination to efficiently handle large result sets by using the \u003ccode\u003enextPageToken\u003c/code\u003e in subsequent requests to retrieve additional media items or albums.\u003c/p\u003e\n"]]],["To access app-created media, the `photoslibrary.readonly.appcreateddata` scope is required. You can list media items from specific app-created albums or the entire app-created library using `mediaItems.list` or `mediaItems.search`. Filtering by date, content category, or media type is available when listing the library, but not albums. Use `albums.list` to get album details like ID, title, and `coverPhotoBaseUrl`. Pagination is used for large datasets, using the `nextPageToken` for subsequent requests, with recommended and maximum page sizes.\n"],null,["# List app-created media items and albums\n\nRequired authorization scopes\n-----------------------------\n\nListing app-created content requires the `photoslibrary.readonly.appcreateddata`\nscope. For more information on scopes, see [Authorization\nscopes](/photos/overview/authorization).\n\nOverview\n--------\n\nThe Library API lets you to list and access media items that your application\nhas created.\n\nSome key features of listing media items include the following:\n\n- List media items from specific app-created albums or the entire app-created library\n- [Apply filters (date, content category, media\n type)](/photos/library/guides/apply-filters) when listing to narrow your\n results\n\n | **Note:** Filters are not supported when you list items from albums.\n- Retrieve [`mediaItem`](/photos/library/reference/rest/v1/mediaItems) objects\n with essential details like direct links and metadata.\n\nListing the library and album contents returns a list of media items.\n[Enrichments](/photos/library/guides/add-enrichments) that are part of an album\naren't included. Media items describe a photo, video, or other media. A\n`mediaItem` includes a direct link to the item, a link to the item in\nGoogle Photos, and other relevant metadata. For more information, see\n[Access media items](/photos/library/guides/access-media-items) and\n[`mediaItems`](/photos/library/reference/rest/v1/mediaItems).\n| **Caution:** Don't cache user photos and videos. Instead, store the media item `id` and request its details again when you need them. Images may change, and direct access through the `baseUrl` expires after 60 minutes. For more information, see [Access media items](/photos/library/guides/access-media-items).\n\nList app-created albums\n-----------------------\n\nYou can list albums that have been created by your app using\n[`albums.list`](/photos/library/reference/rest/v1/albums/list). \n\n### REST\n\nHere is a sample request: \n\n```\nGET https://photoslibrary.googleapis.com/v1/albums\n```\n\nThe request returns the following result: \n\n```restructuredtext\n{\n \"albums\": [\n {\n \"id\": \"album-id\",\n \"title\": \"album-title\",\n \"productUrl\": \"album-product-url\",\n \"coverPhotoBaseUrl\": \"album-cover-base-url_do-not-use-directly\",\n \"coverPhotoMediaItemId\": \"album-cover-media-item-id\",\n \"isWriteable\": \"whether-you-can-write-to-this-album\",\n \"mediaItemsCount\": \"number-of-media-items-in-album\"\n },\n ...\n ],\n \"nextPageToken\": \"\u003cvar translate=\"no\"\u003etoken-for-pagination\u003c/var\u003e\"\n}\n```\n\nEach returned album has an ID that can be used to retrieve the contents of the\nalbum as shown in [List album contents](#listing-album-contents). It also\nincludes the title and the number of media items it contains.\n\nThe `productUrl` points to the album in Google Photos that can be a\nopened by the user.\n\nThe `coverPhotoMediaItemId` contains the [media item\nID](/photos/library/reference/rest/v1/mediaItems) that represents the cover\nphoto of this album. To the access this cover image, use `coverPhotoBaseUrl`.\nYou shouldn't use the `coverPhotoBaseUrl` directly without specifying\n[additional parameters](/photos/library/guides/access-media-items#base-urls).\n\nThe response also contains a `nextPageToken`. For more information, see\n[Pagination](#pagination).\n\nThe response for empty albums varies in that, `mediaItemsCount` and\n`coverPhotoMediaItemId` are set to 0 by default and are omitted from the REST\nresponse. Also note that `coverPhotoBaseUrl` points to a default placeholder\nimage.\n\nList app-created library contents\n---------------------------------\n\nYou can list all the media items from the user's Google Photos library\nthat were created by your app.. This excludes archived and deleted items. You\ncan list media items based on their content, date, and other properties by\n[applying filters](/photos/library/guides/apply-filters).\n\nTo list a media items, call\n[`mediaItems.list`](/photos/library/reference/rest/v1/mediaItems/list). \n\n### REST\n\nHere is a sample request: \n\n```restructuredtext\nGET https://photoslibrary.googleapis.com/v1/mediaItems\nContent-type: application/json\nAuthorization: Bearer \u003cvar translate=\"no\"\u003eoauth2-token\u003c/var\u003e\n{\n \"pageSize\": \"100\",\n}\n```\n\nThe GET request returns the following response: \n\n```restructuredtext\n{\n \"mediaItems\": [\n ...\n ],\n \"nextPageToken\": \"\u003cvar translate=\"no\"\u003etoken-for-pagination\u003c/var\u003e\"\n}\n```\n\nThe response contains a list of media items, ordered from most to least recent.\nFor more information, see\n[`mediaItems`](/photos/library/reference/rest/v1/mediaItems#MediaItem). It also\ncontains a `nextPageToken`, which is described in more detail in\n[Pagination](#pagination).\n\nList album contents\n-------------------\n\nTo list all of the media items in an album, add the `albumId` field to your\nsearch request. For more information about `albumId`, see [Listing\nalbums](#listing-albums). If the `albumId` is invalid, a `Bad Request` error is\nreturned. If the ID is valid, but the album doesn't exist for the authenticated\nuser, a `Not Found` error is returned. For more details regarding error\nhandling,see [Performance tips](/photos/library/guides/performance-tips) and\n[Best practices](/photos/library/guides/best-practices). \n\n### REST\n\nHere is a sample request: \n\n```restructuredtext\nPOST https://photoslibrary.googleapis.com/v1/mediaItems:search\nContent-type: application/json\nAuthorization: Bearer \u003cvar translate=\"no\"\u003eoauth2-token\u003c/var\u003e\n{\n \"pageSize\": \"100\",\n \"albumId\": \"album-id\"\n}\n```\n\nThe POST request returns the following response: \n\n```restructuredtext\n{\n \"mediaItems\": [\n ...\n ],\n \"nextPageToken\": \"\u003cvar translate=\"no\"\u003etoken-for-pagination\u003c/var\u003e\"\n}\n```\n\nThe response contains a `nextPageToken` and the list of media items. Unlike when\nlisting library contents, the media items are returned by their order in the\nalbum. For more details, see\n[`mediaItems`](/photos/library/reference/rest/v1/mediaItems) and\n[Pagination](#pagination). The user can edit the order in the\nGoogle Photos interface.\n\nIf the `albumId` is set, you can't apply a filter when listing album contents.\nDoing so results in a `Bad Request` error.\n\nPagination for REST\n-------------------\n\nTo improve performance, methods that return a large number of results (such as\nlist methods) may paginate the response. The maximum number of results in each\npage is given by the `pageSize` parameter.\n\nFor calls to `mediaItems.search` and `mediaItems.list`, the default page size is\n25 items. We recommend this page size because it strikes a balance between the\nsize of the response and the fill rate. The maximum page size for media item\nsearch and list requests is 100 items.\n\nThe default and recommended page size when listing albums is 20 albums, with a\nmaximum of 50 albums.\n\nWhen the number of available results is greater than the page size, the response\nincludes a `nextPageToken`, which indicates to your application that there are\nmore results to be fetched from the server.\n| **Note:** The `pageSize` parameter is a maximum --- fewer results might be returned than are requested.\n\n### Example\n\nYou must append the `nextPageToken` to subsequent requests in the parameter\n`pageToken`, as shown in the following example. Specify the `pageToken` together\nwith other parameters required for the operation, either in the body of the\nrequest, or as a query parameter.\n\n#### Request #1\n\n```text\n{\n \"pageSize\": \"5\",\n \"filters\": { … }\n}\n```\n\n#### Response #1\n\n```text\n{\n \"mediaItem\": [ … ],\n \"nextPageToken\": \"next-page-token\"\n}\n```\n\n#### Request #2\n\n```text\n{\n \"pageSize\": \"5\",\n \"filters\": { … },\n \"pageToken\": \"page-token\"\n}\n```\n\n#### Response #2\n\n```text\n{\n \"mediaItem\": [ … ],\n \"nextPageToken\": \"next-page-token\"\n}\n```\n\nContinue this pattern until there are no more `nextPageToken` objects.\n\nThe `nextPageToken` is only valid for the same request. If any parameters are\nchanged, a previously used `nextPageToken` shouldn't be used in the same\nrequest.\n| **Note:** The existence of `nextPageToken` is the only indicator of whether or not there are more results to be fetched from the server. Don't count the number of results to determine if you should use your `nextPageToken`. A request may return fewer results than requested in the page size. If a `nextPageToken` is present, you can send a request for more results after your initial request."]]