SleepType

The data type representing sleep data specifications.

It includes bedtime, wake-up time, actual sleep duration and sleep score across entire sleep sessions. A single sleep data record contains of one or more sleep session data. Each SleepSession data has the session's start time, end time, sleep duration, and sleep stages.

Sleep data can be measured from wearable devices such as Galaxy Watch, Galaxy Fit, and Galaxy Ring. The Samsung Health app's sleep tracker makes it easy to check sleep data based on the sleep goal time set by the user, even if there are multiple sleep sessions.

You can get the following sleep data information:

  • The sleep duration, bedtime, wake-up time, and a sleep score

  • The list of sleep sessions

Available aggregate operation

  • TOTAL_DURATION
    : To get a total sleep duration time for a data request.

Predefined instance

Using the following instance allows for obtaining sleep data with more concise code.

Required permission

The user's consent is required to access this data type. Check the granted permissions and request permissions if the required permission is not granted yet with:

See a code example in here.

Available requests

Data specifications

This data type includes the following information.

PropertyDescription
uid[Mandatory]
The data's unique identifier assigned by the Samsung Health app.
startTime[Mandatory]
The timestamp representing the bedtime, specified as Instant, in milliseconds.
endTime[Mandatory]
The timestamp representing the wake-up time, specified as Instant, in milliseconds.
zoneOffset[Mandatory]
The ZoneOffset for startTime and endTime.
dataSource[Mandatory]
The data's source information including the application package name and which device's ID.
DURATION[Mandatory]
The sleep duration of the SleepType data, specified as Duration, in minutes.
SESSIONS[Mandatory]
The list of SleepSession.
SLEEP_SCOREThe sleep score of this sleep data record.

Associated data

The Samsung Health app records blood oxygen levels and skin temperature data continuously during the user's sleep. The Samsung Health app's Data SDK enables your app to get the following associated data.

For a specific SleepType data record, getting associated data is available through:

Inserting sleep data into the Samsung Health app

For inserting sleep data into the Samsung Health app, please take note of the following:

If there are two or more SleepSessions in the sleep data, set the startTime and endTime of each SleepSession within the range of startTime and endTime of the SleepType data, and ensure they do not overlap with any other SleepSession within the SleepType data.

The SleepStage.startTime and SleepStage.endTime need to be set within the range of SleepSession.startTime and SleepSession.endTime, and are not allowed to overlap with other SleepStage within the same SleepSession.

Since

1.0.0

See also

Types

Link copied to clipboard
Link copied to clipboard
object Companion
Link copied to clipboard

The type of sleep stage.

Properties

Link copied to clipboard
Link copied to clipboard

Retrieves a ChangedDataRequest instance to retrieve changed sleep data.

Link copied to clipboard

Retrieves a DeleteDataRequest instance to delete sleep data that the app inserted into the Samsung Health app.

Link copied to clipboard

Retrieves an InsertDataRequest instance to insert new sleep data to the Samsung Health app.

Link copied to clipboard

Retrieves a ReadDataRequest instance to read sleep data.

Link copied to clipboard

Retrieves an UpdateDataRequest instance to update sleep data that the app inserted into the Samsung Health app.

Preferences Submitted

You have successfully updated your cookie preferences.