API Doc v0.1

Zeo Web API


The Zeo API is a set of web services that allow third parties to develop applications that allow users full
access to their individual sleep records. A set of operations is provided using HTTP and can return data in
either JSON or XML formats. All API operations must be authenticated using either Basic Auth or OAuth.
Sample code is be provided to illustrate best practices for using the API and to provide a starting point for
new Zeo-aware applications.

Using the Zeo API, developers will have the ability to access nightly sleep data including ZQ scores,
total sleep time, the number of times woken, and the amount of REM, light, and deep sleep. Additionally,
developers will be able to display a sleep graph, showing how the user slept in 5-minute increments
throughout the night.



Contents


  • Introduction
  • API Basics
  • Identification and Authentication
  • Notification Service
  • Code Samples
  • Service Catalog

Introduction


To use the API, you will need a Zeo issued key which must be included with all requests. It is freely available for non-commercial use by any developer and may be licensed (or freely licensed in some cases) for commercial use by prior arrangement.


You can apply for a key here


API Basics



Request format


The Zeo Web API is REST-based. All communication is over SSL. Requests are sent as HTTPS GET requests.

A typical Zeo Web API service request follows this template :


https://api.myzeo.com:8443/zeows/api/[version]/[response_type]/[service_name]/[action_name]?key=[key]&[parameters]

Where :
[version] is the requested service version (i.e. v1),
[response_type] is the requested response output type (i.e. json). This is an optional argument (default returns XML)
[service_name] is the requested service (i.e. sleeperService),
[action_name] is the action you want to perform on the requested service (i.e. getSleepStatsByDateRange),
[key] is the Zeo-issued API key you received when you signed up (i.e. B0372F610DBA1D7C19F987835F05F4CA1),
[parameters] are parameters, mandatory or optional, passed to the requested service.


For every call, the version, service_name, action_name, key parameters are all required.

Response format


Responses to such requests can be either XML or JSON documents. By default, XML format is returned. To specify either return format, the request "Accept" header can be modified to include "application/xml" for XML or "application/json" for json. In the case that you cannot modify the request "Accept" header, and need JSON output, you can force the api to return JSON by changing the URL as discussed above with 'json' in the response_type section.


XML responses look like the following:



JSON responses look like the following:


						
					

In this example, the sleepRecords is empty, indicating no data.
Any single response will provide a mandatory status field. A response with a status of 0 is OK. A response with a non-zero status will also include an <errMsg> tag describing the error. Please refer to the Error code sections to get a hint as to what went wrong, and why.


A XML library is available for most programming languages at http://www.xml.com.

A JSON library is available for most programming languages at http://www.json.org.



Identification and Authentication


You typically use the Zeo Web API to retrieve data related to a given user, for example, sleep ZQ scores and nightly sleep data. A user is part of an account.

An account is what Zeo users use to log into their dashboard. An account is uniquely defined by an email address. For access to be granted to a given account, its password (chosen by the user at registration time) is needed.


There are two types of authentication, HTTP Basic and OAUTH. If you wish to access the API via OAUTH, your app must be hosted on an external server. If you are not accessing the API programatically, and doing it through a web browser, you will be brought to a login screen if you have not already authenticated.

When accessing the API directly or via a 3rd party (i.e. using OAUTH), the user account credentials must be entered (email address and password). Once authenticated, the user will not be asked to log in again until the session expires.


To learn more about HTTP Basic Authentication, Please see http://en.wikipedia.org/wiki/Basic_access_authentication.
To learn more about OAUTH, please see http://oauth.net/

Notification Service for Third Parties


The most effective way for third parties to retrieve measurement updates is to setup notifications (some might call it "Push") for the users they are interested in. Each time the subscribed users upload their sleep data, the Zeo Web API will send notifications to all their monitoring third parties.


Subscriptions will not be performed if the user has not allowed its profile to be public. A given user can not be subscribed by more than 10 third parties. The user must subscribe to the notification service directly from the third party website, and must login with their own credentials.


When the Zeo Web API sees that subscriber data has been modified, it sends a notification to the subscribing third party application. The notification contains information that helps to determine what should be downloaded to remain in sync.


Notifications subscriptions last until the user or the third party application unsubscribes from the notification service.


The subscription can be revoked at any time. To find out more, download our Notification Feature PDF, or contact us at DeveloperRelations@myZeo.com. Also, please see our terms of service here



Code Samples


We've put together some samples in different languages to help illustrate the documentation.
We've included samples and libraries in the following languages:



You can download samples from here


Service Catalog


Overall Average Functions:

Date Functions:

Paging Functions:
  • getPreviousSleepStats - Returns the SleepStats (grouped by day) for the latest date prior to the specified date.
  • getPreviousSleepRecord - Returns the SleepRecord for the latest date prior to the specified date.
  • getNextSleepStats - Returns the SleepStats (grouped by day) for the earliest date after the specified date.
  • getNextSleepRecord - Returns the SleepStats for the earliest date after the specified date.
  • getEarliestSleepStats - Returns the SleepStats (grouped by day) with the earliest date on record for the current user.
  • getEarliestSleepRecord - Returns the SleepRecord with the earliest date on record for the current user.
  • getLatestSleepStats - Returns the SleepStats (grouped by day) with the latest date on record for the current user.
  • getLatestSleepRecord - Returns the SleepRecord with the latest date on record for the current user.

Miscellaneous Functions:
  • logout - Logs the user out of the API and closes the session.


getOverallAverageZQScore


This returns the average ZQ score for the user.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



getOverallAverageDayFeelScore


This returns an average score of how the user feels during the day.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



getOverallAverageMorningFeelScore


This returns an average score of how the user feels in the morning.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



getOverallAverageSleepStealerScore


This returns an average score of the number of sleep stealers.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



getAllDatesWithSleepData


Returns an array of ZeoDate objects representing dates for which sleep data is available.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



getDatesWithSleepDataInRange


Returns an array of ZeoDate objects representing dates for which sleep data is available.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.
optional dateFrom string The bottom of the date range. If not specified API assumes the first record.
optional dateTo string The top of the date range. If not specified API assumes the last record.



getSleepStatsForDate


Returns a SleepStats object for the date requested. Null will be returned if date specified has no sleep stats.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.
required date string The requested date. Date must be in YEAR-MONTH-DAY format.



getSleepRecordForDate


Returns a SleepRecord object for the date requested. Null will be returned if date specified has no sleep record.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.
required date string The requested date. Date must be in YEAR-MONTH-DAY format.



getPreviousSleepStats


Returns the SleepStats (grouped by day) for the latest date prior to the specified date.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.
required date string The requested date. Date must be in YEAR-MONTH-DAY format.



getPreviousSleepRecord


Returns the SleepRecord for the latest date prior to the specified date.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.
required date string The requested date. Date must be in YEAR-MONTH-DAY format.



getNextSleepStats


Returns the SleepStats (grouped by day) for the earliest date after the specified date.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.
required date string The requested date. Date must be in YEAR-MONTH-DAY format.



getNextSleepRecord


Returns the SleepStats for the earliest date after the specified date.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.
required date string The requested date. Date must be in YEAR-MONTH-DAY format.



getEarliestSleepStats


Returns the SleepStats (grouped by day) with the earliest date on record for the current user.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



getEarliestSleepRecord


Returns the SleepRecord with the earliest date on record for the current user.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



getLatestSleepStats


Returns the SleepStats (grouped by day) with the latest date on record for the current user.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



getLatestSleepRecord


Returns the SleepRecord with the latest date on record for the current user.


Parameters
Response
Example

Parameters

Required Name Type Description
required key string The API key of the API consumer.



logout


This logs the user out of the API and closes the session.


Parameters
Response
Example

Parameters

Required Name Type Description
optional key string The API key of the API consumer.



Zeo Personal Sleep Coach is neither a medical device nor a medical program and is not intended for the diagnosis or treatment of sleep disorders. If you suspect that you may have a sleep disorder, consult your physician.