2025 年 4 月 1 日,Library API 中的部分範圍已遭到移除。
詳情請參閱這篇文章。
Method: mediaItems.list
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eLists all media items from a user's Google Photos library using the \u003ccode\u003elistMediaItems\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eAllows pagination with \u003ccode\u003epageSize\u003c/code\u003e and \u003ccode\u003epageToken\u003c/code\u003e parameters to retrieve large sets of media items.\u003c/p\u003e\n"],["\u003cp\u003eReturns an array of \u003ccode\u003eMediaItem\u003c/code\u003e objects containing information about each media item.\u003c/p\u003e\n"],["\u003cp\u003eRequires specific OAuth scopes like \u003ccode\u003ephotoslibrary\u003c/code\u003e or \u003ccode\u003ephotoslibrary.readonly\u003c/code\u003e for authorization.\u003c/p\u003e\n"],["\u003cp\u003eFunctionality for interacting with media items not created by the app will be limited after March 31, 2025.\u003c/p\u003e\n"]]],["This content outlines how to list media items from a user's Google Photos library using the Photos API. Key actions involve sending a `GET` HTTP request to `https://photoslibrary.googleapis.com/v1/mediaItems`, with an empty request body. Optional query parameters include `pageSize` (default 25, max 100) and `pageToken` for pagination. The successful response is a JSON object containing an array of `mediaItems` and an optional `nextPageToken`. Authorization requires specific OAuth scopes. Note that beginning March 31, 2025, media access will be limited.\n"],null,["# Method: mediaItems.list\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.ListMediaItemsResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nList all media items created by your app from a user's Google Photos library.\n\n### HTTP request\n\n`GET https://photoslibrary.googleapis.com/v1/mediaItems`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Query parameters\n\n| Parameters ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `pageSize` | `integer` Maximum number of media items to return in the response. Fewer media items might be returned than the specified number. The default `pageSize` is 25, the maximum is 100. |\n| `pageToken` | `string` A continuation token to get the next page of the results. Adding this to the request returns the rows after the `pageToken`. The `pageToken` should be the value returned in the `nextPageToken` parameter in the response to the `listMediaItems` request. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nList of all media items from the user's Google Photos library.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|----------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"mediaItems\": [ { object (/photos/library/reference/rest/v1/mediaItems#MediaItem) } ], \"nextPageToken\": string } ``` |\n\n| Fields ||\n|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mediaItems[]` | `object (`[MediaItem](/photos/library/reference/rest/v1/mediaItems#MediaItem)`)` Output only. List of media items in the user's library. |\n| `nextPageToken` | `string` Output only. Token to use to get the next set of media items. Its presence is the only reliable indicator of more media items being available in the next request. |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `\n https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata`"]]