Google Health API memberi Anda akses ke data kesehatan dan kebugaran yang dikirimkan pengguna. Informasi profil pengguna tersedia melalui endpoint
getProfile, tetapi
terbatas pada metrik seperti usia dan tanggal mulai keanggotaan.
Untuk mendapatkan informasi profil pengguna tambahan, Anda dapat menggunakan
People API. Anda mungkin perlu meminta otorisasi untuk cakupan tambahan. Misalnya, untuk membaca tanggal lahir pengguna, Anda harus menyertakan https://www.googleapis.com/auth/user.birthday.read dan https://www.googleapis.com/auth/userinfo.profile dalam permintaan otorisasi Anda. Untuk mengetahui informasi selengkapnya tentang otorisasi People API, lihat Mengotorisasi Permintaan.
Misalnya, untuk mendapatkan tanggal lahir pengguna menggunakan People API:
Protokol
GET /v1/people/me?personFields=birthdays HTTP/1.1 Host: people.googleapis.com
Java
Person profile = peopleService.people().get("people/me") .setPersonFields("birthdays") .execute();
Python
profile = people_service.people() .get('people/me', personFields='birthdays')
PHP
$profile = $people_service->people->get( 'people/me', array('personFields' => 'birthdays'));
.NET
PeopleResource.GetRequest peopleRequest = peopleService.People.Get("people/me"); peopleRequest.PersonFields = "birthdays"; Person profile = peopleRequest.Execute();
Respons
{ "resourceName": "people/115549...", "etag": "%EgQBBy43...", "birthdays": [ { "metadata": { "primary": true, "source": { "type": "DOMAIN_PROFILE", "id": "115549..." } }, "date": { "month": 1, "day": 1 } }, { "metadata": { "source": { "type": "ACCOUNT", "id": "115549..." } }, "date": { "year": 1990, "month": 1, "day": 1 } } ] }