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.
Google Drive Activity API bao gồm tài nguyên DriveActivity. Tài nguyên này đại diện cho những thay đổi đối với các đối tượng trong Google Drive của người dùng và phương thức activity.query. Phương thức này cho phép bạn truy xuất thông tin về những thay đổi đó.
Yêu cầu
Ứng dụng của bạn yêu cầu dữ liệu hoạt động của người dùng bằng phương thức activity.query. Bạn có thể yêu cầu thông tin về hoạt động đối với một mục cụ thể trên Drive hoặc đối với mọi nội dung trong một thư mục trên Drive. Đối với một yêu cầu nhất định, bạn có thể chọn hạn chế phản hồi theo các ràng buộc như phạm vi thời gian hoặc loại hành động, đồng thời bạn có thể chọn hợp nhất hoạt động trong phản hồi. Để biết thêm thông tin, hãy xem phần Đưa ra yêu cầu trong Drive Activity API.
Phản hồi
Phản hồi cho một yêu cầu là danh sách các hoạt động khớp với các tham số đã cho, trong đó tài nguyên DriveActivity đại diện cho từng hoạt động:
Tài nguyên DriveActivity là một tập hợp các đối tượng Action, mỗi đối tượng là độc lập như một sự kiện. Action bao gồm ActionDetail (chẳng hạn như Create hoặc Edit), Actor (chẳng hạn như User hoặc Administrator), Target (chẳng hạn như DriveItem hoặc Drive) và Timestamp hoặc TimeRange.
Tài nguyên DriveActivity cũng chứa thông tin tóm tắt, chẳng hạn như mọi Actor và Target từ tất cả các hành động, Timestamp hoặc TimeRange hợp nhất và ActionDetail quan trọng nhất hoặc mang tính đại diện nhất của Action.
Một số hoạt động trên Drive có thể không được báo cáo khi bạn sử dụng API này. Việc Drive Activity API có báo cáo một thay đổi nhất định đối với một đối tượng hay không phụ thuộc vào việc người dùng đã xác thực trong ứng dụng của bạn có thấy được thay đổi đó hoặc thông tin về thay đổi đó hay không.
Khả năng hiển thị dựa trên các quyền được đặt cho đối tượng. Có một số trường hợp khi tệp và thư mục được chia sẻ trong Drive:
Nếu tác giả chia sẻ một tài liệu, thì nhật ký hoạt động của tài liệu đó không chỉ hiển thị cho người tạo mà còn cho cả những người dùng đã xác thực mà tài liệu được chia sẻ.
Nếu một tài liệu được chia sẻ với người dùng rồi chuyển sang chế độ riêng tư, thì người dùng đã xác thực có thể xem tất cả nhật ký hoạt động trong thời gian họ có quyền truy cập và biết rằng hiện tại các quyền đã bị hạn chế.
Nếu một tài liệu chưa từng được chia sẻ với người dùng, thì người dùng đó sẽ không thấy nhật ký hoạt động nào.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-04 UTC."],[],[],null,["# Introduction to Google Drive Activity API\n\nThe Google Drive Activity API consists of the\n[`DriveActivity`](/workspace/drive/activity/v2/reference/rest/v2/activity/driveactivity) resource, which\nrepresents changes made to objects within a user's Google Drive, and the\n[`activity.query`](/workspace/drive/activity/v2/reference/rest/v2/activity/query) method, which allows you to retrieve\ninformation about those changes.\n\nRequest\n-------\n\nYour app requests a user's activity data using the\n[`activity.query`](/workspace/drive/activity/v2/reference/rest/v2/activity/query) method. You can request activity\neither for a specific Drive item or for everything contained under a Drive\nfolder. For a given request, you can choose to restrict the response by\n[constraints](/workspace/drive/activity/v2/requests#filters) such as time range or action type, and you\ncan choose to have the activity [consolidated](/workspace/drive/activity/v2/requests#consolidation) in the\nresponse. For more information, see [Make requests in the Drive Activity API](/workspace/drive/activity/v2/requests).\n\nResponse\n--------\n\nThe response to a request is a list of activities matching the given parameters,\nwhere a\n[`DriveActivity`](/workspace/drive/activity/v2/reference/rest/v2/activity/driveactivity) resource represents each activity:\n\nA [`DriveActivity`](/workspace/drive/activity/v2/reference/rest/v2/activity/driveactivity) resource is a collection of\n[`Action`](/workspace/drive/activity/v2/reference/rest/v2/activity/action) objects, each of which is\nself-contained like an *event* . An `Action` includes an\n[`ActionDetail`](/workspace/drive/activity/v2/reference/rest/v2/activity/actiondetail) (such as `Create`\nor `Edit`), an [`Actor`](/workspace/drive/activity/v2/reference/rest/v2/activity/actor) (such as `User`\nor `Administrator`), a [`Target`](/workspace/drive/activity/v2/reference/rest/v2/activity/target) (such\nas `DriveItem` or `Drive`), and either a\n[`Timestamp`](/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp)\nor [`TimeRange`](/workspace/drive/activity/v2/reference/rest/v2/activity/timerange).\n\nA `DriveActivity` resource also contains\nsummary information, such as every\n`Actor` and\n`Target` from all the actions, a unified\n`Timestamp`\nor `TimeRange`, and either the most\nimportant or representative\n`ActionDetail` of the\n`Action`.\n\nFor more information, see the [Drive Activity API data model](/workspace/drive/activity/v2/datamodel).\n\nActivity history visibility\n---------------------------\n\nSome activity on Drive may not be reported when you use this API. Whether the\nDrive Activity API reports a given change to an object depends on whether\nthe change, or information about the change, is visible to the authenticated\nuser in your application.\n\nVisibility is based on the permissions set for the object. There's several\nscenarios when files and folders are shared in Drive:\n\n- If an author shares a document, the activity history for the document is visible to not only the creator, but also to the authenticated users with whom it was shared.\n- If a document was shared with a user and then made private, the authenticated user can see all activity history while they had access and that the permissions are now restricted.\n- If a document was never shared with a user, the user can't see any activity history.\n\nGet started\n-----------\n\nTo get the most out of the Drive Activity API, integrate your app with the\n[Google Drive API](/workspace/drive/api) first. To get started with the Drive Activity API,\nlearn how to [create a project](/workspace/drive/activity/v2/guides/project) and\n[authorize requests](/workspace/guides/configure-oauth-consent). Or, dive right in and read\nabout activities in the\n[API reference](/workspace/drive/activity/v2/reference/rest/v2/activity)."]]