Method: mediaItems.batchGet
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\u003eRetrieves a list of media items using their identifiers, returning them in the order provided.\u003c/p\u003e\n"],["\u003cp\u003eAccepts up to 50 media item identifiers in a single request using the \u003ccode\u003emediaItemIds\u003c/code\u003e query parameter.\u003c/p\u003e\n"],["\u003cp\u003eReturns a \u003ccode\u003emediaItemResults\u003c/code\u003e array containing the retrieved media items and any potential errors encountered.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization using specific OAuth scopes for accessing and reading media items, with some scopes undergoing changes as of March 31, 2025.\u003c/p\u003e\n"],["\u003cp\u003eProvides a \u003ccode\u003eMediaItemResult\u003c/code\u003e object for each requested media item, containing either the \u003ccode\u003emediaItem\u003c/code\u003e data or a \u003ccode\u003estatus\u003c/code\u003e object indicating any errors.\u003c/p\u003e\n"]]],["This document details the `batchGet` method for retrieving media items from the Google Photos Library API. It uses a `GET` HTTP request to the specified URL, with `mediaItemIds` as required query parameters, up to 50 at a time. The request body must be empty. The response includes a list of `mediaItemResults`, each containing the requested media item or its access error. The method requires specific authorization scopes. This method will be limited to app created data from March 31, 2025.\n"],null,["# Method: mediaItems.batchGet\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.BatchGetMediaItemsResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [MediaItemResult](#MediaItemResult)\n - [JSON representation](#MediaItemResult.SCHEMA_REPRESENTATION)\n- [Try it!](#try-it)\n\nReturns the list of app created media items for the specified media item identifiers. Items are returned in the same order as the supplied identifiers.\n\n### HTTP request\n\n`GET https://photoslibrary.googleapis.com/v1/mediaItems:batchGet`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Query parameters\n\n| Parameters ||\n|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mediaItemIds[]` | `string` Required. Identifiers of the media items to be requested. Must not contain repeated identifiers and cannot be empty. The maximum number of media items that can be retrieved in one call is 50. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nResponse to retrieve a list of app createdmedia items.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"mediaItemResults\": [ { object (/photos/library/reference/rest/v1/mediaItems/batchGet#MediaItemResult) } ] } ``` |\n\n| Fields ||\n|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mediaItemResults[]` | `object (`[MediaItemResult](/photos/library/reference/rest/v1/mediaItems/batchGet#MediaItemResult)`)` Output only. List of media items retrieved. Note that even if the call to mediaItems.batchGet succeeds, there may have been failures for some media items in the batch. These failures are indicated in each [MediaItemResult.status](/photos/library/reference/rest/v1/mediaItems/batchGet#MediaItemResult.FIELDS.status). |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `\n https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata`\n\nMediaItemResult\n---------------\n\nResult of retrieving a media item.\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"status\": { object (/photos/library/reference/rest/v1/Status) }, \"mediaItem\": { object (/photos/library/reference/rest/v1/mediaItems#MediaItem) } } ``` |\n\n| Fields ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `status` | `object (`[Status](/photos/library/reference/rest/v1/Status)`)` If an error occurred while accessing this media item, this field is populated with information related to the error. For details regarding this field, see [Status](/photos/library/reference/rest/v1/Status). |\n| `mediaItem` | `object (`[MediaItem](/photos/library/reference/rest/v1/mediaItems#MediaItem)`)` Media item retrieved from the user's library. It's populated if no errors occurred and the media item was fetched successfully. |"]]