Fetch athlete KPI data
AthleteKpv
AthleteKpv
The AthleteKpv
object is primarily the access point for athlete athlete measurements for the given KPV. It is nested under the Athlete
object.
It also contains the generic KPV-level info as well (e.g. name
, unit
, etc.). See kpvs
for information about KPV-level fields.
measurements(startDate: ISO 8601 String, endDate: ISO 8601 String)
=> [KpvMeasurement]
The measurements
field returns an array of KpvMeasurement
objects that were recorded for the athlete within the specified date range. It accepts two required arguments: a startDate
string in ISO 8601 format ("YYYY-MM-DD"
) to specify the beginning of the desired date range, and an endDate
string in ISO 8601 format to specify the end of the desired date range.
value
=> Float
The value
field returns a float that represents the athlete's most recent (or "current") measurement for the give KPV. It will return 0
if no measurements exists.
KpvMeasurement
KpvMeasurement
The KpvMeasurement
object contains information about an athlete measurement for the given KPV on a specific date.
athleteEmail
=> String
The athleteEmail
field returns the email of the athlete for whom the measurement was recorded.
date
=> ISO 8601 String
The date
field returns the date that the measurement was recorded in ISO 8601 format ("YYYY-MM-DD"
).
uuid
=> String
The uuid
field returns the UUID generated by FYTT for the object.
value
=> Float
The value
field returns the measurement's recorded numerical value as a float.
Sample Query
Example:
query {
athletes(emails: ["[email protected]"]) {
name,
kpvs(uuids: ["3c2dafb4-160d-4b67-be63-d2d6915310ec"]) {
name,
measurements(startDate: "2023-01-01", endDate: "2023-12-31") {
date,
value
}
}
}
}
Response:
{
"data": {
"athletes": [
{
"name": "Sally Jones",
"kpvs": [
{
"name": "Sleep",
"measurements": [
{
"date": "2024-08-29",
"value": 2
},
{
"date": "2024-09-29",
"value": 5
},
{
"date": "2024-10-16",
"value": 1
},
{
"date": "2024-10-27",
"value": 11
},
{
"date": "2024-10-29",
"value": 6
},
{
"date": "2024-10-30",
"value": 1
}
]
}
]
}
]
}
}
Avoid Request Timeouts
The amount of data requested can easily spiral out of control if you're not careful. To avoid request timeouts for very large amounts of data, we strongly advise that you limit the scope of each request to a subset of athletes and/or a relatively narrow date range (~30 days is probably the upper end of the recommended range depending on the number of athletes and the frequency of recorded measurements).