QuickStart

Applying the Asleep Track B2B Service

1. Generate API Key

To use the Asleep Track Service, you must have an API Key. To generate an API Key, you need to sign up for a membership through the dashboard. After signing up, you can generate an API key for development and testing purposes by clicking "Generate API Key"
API Key generation URL: Generate API Key

Dashboard Log in => Setting => Generate API Key

Dashboard Log in => Setting => Generate API Key

2. Trial Plan

After signing up and creating an API Key, Asleep Track allows you to test 500 sleep sessions with valid calls, with the following criteria for valid calls.

  • A continuous audio recording of at least 20 minutes is sent to the Asleep Track server for sleep analysis, and is considered a valid call only if the results of that analysis are provided to the client.
  • If the Asleep Track server generates a sleep analysis result, it is considered a valid call, and the client can re-call the result from the Asleep Track server, even if the client force closes or crashes.

3. B2B Service contracts

After selecting the features provided by Asleep Track, clients proceed to sign the official contract for service usage.
URL for Asleep Track provided services: Data Plan
Ask regarding the official contract for Asleep Track: Ask to Asleep

4. Enterprise Plan

Services for sleep analysis will be provided based on the criteria specified in the official contract after the formal agreement.

Asleep Track Application Guide

To utilize the Asleep Track service on mobile devices, clients can swiftly apply it using the API Key and the Asleep Track SDK. Additionally, clients can examine the implementation stage’s source code through a Sample App built with the Asleep Track SDK.

1. Generate API Key

Create an API Key after signing up through the Dashboard.
API Key generation URL: Generate API Key

2. Verify functionality through the Sample App

Clients can quickly verify the functionality by obtaining the source code of the Sample App applied using the Asleep Track SDK library.
Sample App Guide URL: Sample App

Sample App Sleep Tracking

Sample App Sleep Tracking

3. Implementation guide

3.1 Development Call Flow Using Asleep Track SDK

To utilize the Asleep Track service, it’s essential to understand the step-by-step states and functionalities provided through the SDK. Within the SDK:

  • Recording and Conversion: During sleep, it records respiratory sounds and converts them into Mel Spectrograms.

  • Data Transmission: The transformed Mel data is then transmitted to the Asleep Track Server.

  • Real-time Monitoring: It plays a role in providing real-time sleep results or receiving results after sleep completion.

  • Operation State:

    • INIT: Initialization for Asleep Track service usage.
    • TRACKING: Periodic audio recording, conversion, and transmission to the server.
    • REPORT: Allows users to review sleep analysis results.

    SDK operation state and and Call Flow guide URL: SDK Call Flow

3.2 Development Environment Setup

To develop using the Asleep Track SDK on Android and iOS, you’ll need to configure the following development environment.
Android development environment setup: Android Get Started
iOS development environment setup: iOS Get Started

3.3 Development Guide for using Asleep Track Service

Implementation guide for INIT, TRACKING, and REPORT phases by OS
Android Development: Android Sleep Tracking with Asleep Track SDK
iOS Development: iOS Sleep Tracking with Asleep Track SDK

let apiKey: String = "YOUR_API_KEY"
let userId: String?
let baseUrl: URL?
let callbackUrl: URL?
let service: String?
let delegate: AsleepConfigDelegate = self

Asleep.initAsleepConfig(apiKey: apiKey,
                        userId: userId,
                        baseUrl: baseUrl,
                        callbackUrl: callbackUrl,
                        service: service,
                        delegate: self)
import ai.asleep.asleepsdk.Asleep
import ai.asleep.asleepsdk.data.AsleepConfig
import ai.asleep.asleepsdk.AsleepErrorCode

...

Asleep.initAsleepConfig(  
    context = applicationContext,  
    apiKey = "[input your apiKey]",  
    userId = null,  
    baseUrl = null,  
    callbackUrl = null,  
    service = "[input your AppName]",  
    object : Asleep.AsleepConfigListener {  
        override fun onSuccess(userId: String?, asleepConfig: AsleepConfig?) {  
						...
            /* save userId and asleepConfig */
  
        }
    override fun onFail(errorCode: Int, detail: String) {
        ...
    }
})
  • Create SleepTrackingManager
var config: Asleep.Config?
let delegate: AsleepSleepTrackingManagerDelegate = self
var manager: Asleep.SleepTrackingManager?

if let config {
    manager = Asleep.createSleepTrackingManager(config: config,
                                                delegate: self)
}
import ai.asleep.asleepsdk.tracking.SleepTrackingManager

...

var sleepTrackingManager = Asleep.createSleepTrackingManager(asleepConfig, object : SleepTrackingManager.TrackingListener {                           
    override fun onCreate() {
    }

    override fun onUpload(sequence: Int) {
    }
    
    override fun onClose(sessionId: String) {
        ...
        /* save sessionId */
    }
    
    override fun onFail(errorCode: Int, detail: String) {
    }
})
  • Start Tracking
var manager: Asleep.SleepTrackingManager?
manager?.startTracking()
sleepTrackingManager?.startSleepTracking()
  • Stop Tracking
var manager: Asleep.SleepTrackingManager?
manager?.stopTracking()
sleepTrackingManager?.stopSleepTracking()
var config: Asleep.Config?
var reports: Asleep.Reports?

if let config {
    reports = Asleep.createReports(config: config)
}
val reports = Asleep.createReports(asleepConfig)

reports?.getReport(sessionId, object : Reports.ReportListener {
    override fun onSuccess(report: Report?) {
    }

    override fun onFail(errorCode: Int, detail: String) {
    }
})

3.4 How to confirm results

To verify results through the Asleep Track service, you can use the SDK's REPORT method or utilize the Callback URL set during the Dashboard or SDK's INIT phase to check on the Callback Server.
Client can verify the results of the measured data by logging in to the Dashboard Home on the Dashboard and referring to the content in the Dashboard Analysis tab.
Callback data delivers information defined in Callback to the client’s callback server according to the contracted policies.

Based on the collected data, the Asleep Track server delivers sleep analysis information. Client can understand the meaning of the data provided through Introduction about Sleep, and utilize the data to generate various sleep reports. Please refer to Sleep Report Design Guide for more details .