Các API của Google Fit, bao gồm cả API Google Fit REST, sẽ ngừng hoạt động vào năm 2026. Kể từ ngày 1 tháng 5 năm 2024, nhà phát triển không thể đăng ký sử dụng các API này.
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.
Mỗi điểm dữ liệu trong Google Fit đều có một nguồn dữ liệu liên kết. Nguồn dữ liệu chứa thông tin để xác định ứng dụng hoặc thiết bị thu thập hoặc chuyển đổi dữ liệu.
API REST cho phép bạn xác định ứng dụng nào đã chèn dữ liệu về hoạt động thể dục.
Ví dụ: một ứng dụng phân tích nhiều dữ liệu từ nhật ký thể dục của người dùng có thể muốn hiển thị cho người dùng danh sách các phiên hoạt động thể dục có trong bản phân tích, cùng với thông tin về ứng dụng nào đã chèn vào từng phiên.
API REST cũng cho phép bạn liên kết dữ liệu mà bạn chèn vào kho dữ liệu thể dục với ứng dụng của mình.
Xác định dữ liệu được chèn vào ứng dụng
Cách lấy tên gói của ứng dụng Android đã chèn một phiên hoặc tên của ứng dụng REST đã chèn một phiên:
Khi liệt kê tất cả các phiên có sẵn trong một khoảng thời gian trong ứng dụng, bạn có thể sử dụng thông tin này để cho người dùng biết ứng dụng nào đã chèn mỗi phiên.
Cung cấp thông tin về đơn đăng ký của bạn
Để phân bổ dữ liệu bạn chèn vào kho dữ liệu thể dục cho ứng dụng của mình, hãy đảm bảo rằng:
Bạn sẽ thêm thông tin chi tiết về ứng dụng vào thuộc tính dataSources.application khi tạo nguồn dữ liệu.
Bạn chỉ định đúng datasets.dataSourceId cho nguồn dữ liệu của mình khi thêm điểm vào tập dữ liệu.
Các ứng dụng truy cập vào dữ liệu bạn đã chèn có thể dùng thông tin này để phân bổ dữ liệu đó cho ứng dụng của bạn.
[[["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-31 UTC."],[[["\u003cp\u003eEvery data point in Google Fit is linked to a data source, which identifies the source app or device.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Fit REST API allows you to identify the app that inserted specific fitness data, like sessions or datasets.\u003c/p\u003e\n"],["\u003cp\u003eYou can attribute data you insert into Google Fit to your application by including application details when creating data sources.\u003c/p\u003e\n"],["\u003cp\u003eThis attribution allows other apps to correctly identify your application as the source of the data.\u003c/p\u003e\n"]]],[],null,["# Data Attribution\n\nEvery data point in Google Fit has an associated data source. Data sources contain\ninformation to identify the app or the device that collects or transforms the data.\n\nThe REST API lets you determine which app inserted fitness data.\nFor example, an app that analyzes a variety of data from the user's fitness history may\nwant to present users with the list of fitness sessions included in the analysis, along with\ninformation about which app inserted each session.\n\nThe REST API also lets you associate data that you insert in the fitness store with your\napplication.\n\nDetermine which application inserted data\n-----------------------------------------\n\nTo obtain the package name of the Android application that inserted a session or\nthe name of the REST application that inserted a session:\n\n1. Retrieve the session.\n2. Read the [`session.application.packageName`](/fit/rest/v1/reference/users/sessions/list#session.application.packageName) or [`session.application.name`](/fit/rest/v1/reference/users/sessions/list#session.application.name) property.\n\nTo obtain the package name of the Android application or\nthe name of the REST application that inserted a dataset:\n\n1. Retrieve the dataset.\n2. Retrieve the data source by reading the [`dataset.dataSourceId`](/fit/rest/v1/reference/users/dataSources/datasets#dataSourceId) property.\n3. Read the [`dataSources.application.packageName`](/fit/rest/v1/reference/users/dataSources#application.packageName) or [`dataSources.application.name`](/fit/rest/v1/reference/users/dataSources#application.name) property.\n\nThe `application` property contains these fields:\n\n`name`\n: The name of the application.\n\n`packageName`\n: The package name of the Android application.\n\n`detailsUrl`\n: (Optional) A URI to link to the application.\n\nWhen you list all available sessions for a time interval in your application, you can\nuse this information to show your users which app inserted each session.\n\nProvide information about your application\n------------------------------------------\n\nTo attribute data you insert into the fitness store to your application, ensure that:\n\n- You add your application details to the [`dataSources.application`](/fit/rest/v1/reference/users/dataSources#application) property when creating data sources.\n- You specify the correct [`datasets.dataSourceId`](/fit/rest/v1/reference/users/dataSources/datasets) for your data source when adding points to datasets.\n\nApplications accessing data you inserted can use this information to attribute that data to your\napplication."]]