2025 年 4 月 1 日,我们移除了 Library API 中的部分镜重。
点击此处了解详情。
Method: mediaItems.list
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):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`"]]