These docs are for v1.0. Click to read the latest docs for v2.0.

1. Create Reports

  • Asleep.createReports

Generate Reports to get results for sleep tracking.

fun createReports(asleepConfig: AsleepConfig?): Reports?
Parameter NameTypeDescription
asleepConfigAsleepConfig?Enter the set value received by the callback in the initasleepconfig call

2. Get Single Report

  • Asleep.Reports.getReport

Bring sessionId Report.

fun getReport(sessionId: String, reportListener: ReportListener)
Parameter NameTypeDescription
sessionIdStringWhen Sleep Tracking stops, sessionId value
reportListenerReportListenerReport Callback listener
  • Asleep.Reports.ReportListener
interface ReportListener {
    fun onSuccess(report: Report?)
    fun onFail(errorCode: Int, detail: String)
}

If success, onSuccess() is called.

data class Report(
    val validity: String?,
    val session: Session?,
    val stat: Stat?,
    val timezone: String?
)

data class Session(
    val endTime: String?,
    val id: String?,
    val osaStages: List<Int?>?,
    val sleepStages: List<Int?>?,
    val startTime: String?,
    val state: String?
)

data class Stat(
    val sleepEfficiency: Float?,
    val sleepLatency: Int?,
    val sleepTime: String?,
    val timeInBed: Int?,
    val timeInDeep: Int?,
    val timeInLight: Int?,
    val timeInRem: Int?,
    val timeInSleep: Int?,
    val timeInWake: Int?,
    val wakeTime: String?,
    val wakeupLatency: Int?,
    val timeInSleepPeriod: Int?,
    val timeInStableBreath: Int?,
    val timeInUnstableBreath: Int?,
    val wakeRatio: Float?,
    val sleepRatio: Float?,
    val remRatio: Float?,
    val lightRatio: Float?,
    val deepRatio: Float?,
    val stableBreathRatio: Float?,
    val unstableBreathRatio: Float?,
    val breathingPattern: String?,
    val estimatedAhi: Float?
)
Parameter NameTypeDescription
validityString?Whether the analysis of that sleep session is valid
If some of the uploaded audio files are invalid, or if the percentage lost is more than a certain number, the analysis is inaccurate and displays a field

IN_PROGRESS: If session is OPEN
INVALID:TOO_MANDY_DEFECTS_IN_SLEEP_STAGES: Sleep stage analysis result is not enough
INVALID:TOO_MANY_DEFECTS_IN_OSA_STAGES: Sleep apnea stage analysis result is not enough
VALID: Analysis is valid
sessionSession?Session analysis information
statStat?Analysis statistical information
timezoneString?The adjusted time zone of the analysis result
e.g. UTC, Asia/Seoul
endTimeString?Session end time
idString?Session Id
osaStagesList<Int?>?Sleep apnea stages
sleepStagesList<Int?>?Sleep stages
startTimeString?Session start time
stateString?Sleep session state (OPEN, CLOSED or COMPLETE)
sleepEfficiencyFloat?The percentage of time you actually slept during sleep measurement
sleepLatencyInt?time it took to fall asleep
sleepTimeString?The time it takes to fall asleep after the start of sleep measurement
timeInBedInt?The time from the start of the sleep measurement to the end of the sleep measurement
timeInDeepInt?Total time the sleep phase progressed to deep
timeInLightInt?Total time the sleep phase progressed to light
timeInRemInt?Total time the sleep phase progressed to rem
timeInSleepInt?During sleep measurement time, the time you were actually sleeping
Classified into three stages: deep, light, rem
timeInWakeInt?wake during sleep
wakeTimeString?wake up time
wakeupLatencyInt?The time it takes to wake up and end your sleep measurement
timeInSleepPeriodInt?During sleep measurement time, excluding the time it took from the start of the sleep measurement to fall asleep and the time it took from the wake to the end of the sleep measurement
timeInStableBreathInt?Total time in the breathing stable section
timeInUnstableBreathInt?Total time in the breathing unstable section
wakeRatioFloat?Rate of waking time in the middle during sleep stage
sleepRatioFloat?The percentage of time you sleep without waking during the sleep phase
remRatioFloat?Rate of REM sleep during sleep stage
lightRatioFloat?Rate of light sleep during sleep stage
deepRatioFloat?Rate of deep sleep during sleep stage
stableBreathRatioFloat?The percentage of time that was a breathing stable section during the sleep stage
unstableBreathRatioFloat?The percentage of time that was a breathing unstable section during the sleep stage
breathingPatternString?Breathing stability stage
VERY_STABLE: Very Stable
STABLE: Stable
UNSTABLE: Unstable
estimatedAhiFloat?Values for determining respiratory instability levels

If failure, onFail() is called.

Parameter NameTypeDescription
errorCodeIntSee AsleepErrorCode
detailStringerrorCode Message

3. Get Multiple Reports

  • Asleep.Reports.getReports

Gets a list of Report that are within the range of the date you entered.

fun getReports(
    fromDate: String, 
  	toDate: String, 
  	orderBy: String = "DESC", 
  	offset: Int = 0, 
  	limit: Int = 20, 
  	reportsListener: ReportsListener?)
    
Parameter NameTypeDescription
fromDateString (YYYY-MM-DD)View start date
toDateString (YYYY-MM-DD)View last date
orderBy = "DESC"StringDESC: descending order, ASC: ascending order
offset = 0Intnumber of skipped Report
limit = 20Intmax number of Report (0~20)
reportsListenerReportsListener?Report list callback listener
  • Asleep.Reports.ReportsListener
interface ReportsListener {
    fun onSuccess(reports: List<SleepSession>?)
    fun onFail(errorCode: Int, detail: String)
}

If success, onSuccess() is called.

data class SleepSession(
    val sessionId: String?,
    val lastReceivedSeqNum: Int?,
    val sessionEndTime: String?,  
    val sessionStartTime: String?,
    val state: String?,
    val timeInBed: Int?
)
Parameter NameTypeDescription
sessionIdString?Sleep session ID
lastReceivedSeqNumInt?The sequence number of the last uploaded audio file
sessionEndTimeString?Session end time
sessionStartTimeString?Session start time
stateString?Sleep session state (OPEN, CLOSED or COMPLETE)
timeInBedInt?The time from the start of the sleep measurement to the end of the sleep measurement

When getReport() is called with a sessionId, it acquires a comprehensive report.

If failure, onFail() is called.

Parameter NameTypeDescription
errorCodeIntSee AsleepErrorCode
detailStringerrorCode Message

4. Delete Report

❗️

When session data is deleted from the Asleep server upon a request, it becomes difficult to provide specific evidence for the deleted sessions during subsequent billing usage analysis.

  • Asleep.deleteReport

Delete sessionId Report.

fun deleteReport(sessionId: String, deleteReportListener: DeleteReportListener)
Parameter NameTypeDescription
sessionIdStringDelete sessionId value
deleteReportListenerDeleteReportListenerReport delete callback listener
  • Asleep.Reports.DeleteReportListener
interface DeleteReportListener {
    fun onSuccess(sessionId: String?)
    fun onFail(errorCode: Int, detail: String)
}

If success, onSuccess() is called.

Parameter NameTypeDescription
sessionIdString?delete sessionId value

If failure, onFail() is called.

Parameter NameTypeDescription
errorCodeIntSee AsleepErrorCode
detailStringerrorCode Message