Skip to content

sleep_get_summary shouldn't pass both startdateymd&enddateymd AND lastupdate #92

@darthwalsh

Description

@darthwalsh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions