Reproduce
api = WithingsApi(get_credentials())
sleep_data = api.sleep_get_summary(
data_fields=[GetSleepSummaryField.SLEEP_SCORE],
startdateymd=arrow.utcnow().shift(days=-2),
)
series = getattr(sleep_data, "series", [])
print([f"{s.date.format('YYYY-MM-DD')} {s.data.sleep_score}" for s in series])
Expected
Print sleep scores for the last two days
['2025-10-12 84', '2025-10-13 91']
Actual
API returns 0 days
Workarounds
It works if you set lastupdate to None:
sleep_data = api.sleep_get_summary(
data_fields=[GetSleepSummaryField.SLEEP_SCORE],
startdateymd=arrow.utcnow().shift(days=-2),
lastupdate=None,
)
Cause
getsummary docs for lastupdate say
DO NOT USE WITH FOLLOWING PARAMS: [startdateymd, enddateymd]
So the default fields for getsummary shouldn't be setting both of these:
|
def sleep_get_summary( |
|
self, |
|
data_fields: Iterable[GetSleepSummaryField], |
|
startdateymd: Optional[DateType] = arrow.utcnow(), |
|
enddateymd: Optional[DateType] = arrow.utcnow(), |
|
offset: Optional[int] = None, |
|
lastupdate: Optional[DateType] = arrow.utcnow(), |
|
) -> SleepGetSummaryResponse: |
Related problems
I checked through the withings API, and saw similar issues in measure_get_activity (docs)
If you search "DO NOT USE WITH FOLLOWING PARAMS" there are a couple other APIs with incompatible paramater sets.
Reproduce
Expected
Print sleep scores for the last two days
Actual
API returns 0 days
Workarounds
It works if you set
lastupdatetoNone:Cause
getsummary docs for
lastupdatesaySo the default fields for getsummary shouldn't be setting both of these:
python_withings_api/withings_api/__init__.py
Lines 223 to 230 in 69c21c3
Related problems
I checked through the withings API, and saw similar issues in
measure_get_activity(docs)If you search "DO NOT USE WITH FOLLOWING PARAMS" there are a couple other APIs with incompatible paramater sets.