Method: mediaItems.list
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\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`"]]