> ## Documentation Index
> Fetch the complete documentation index at: https://help.apnealytics.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Nightly rows

> Returns individual nightly rows in ascending date order. Optionally filter by an inclusive date window with `from` / `to`. The response contains the most recent `limit` rows that match the filter (default 100, maximum 1000); `total` is the number of rows matching the filter before the limit is applied.

Non-ResMed machines (DreamStation, F&P SleepStyle, DeVilbiss, BMC) currently populate usage and pressure settings only — clinical fields such as AHI sub-indices and leak are `null` for those nights.



## OpenAPI

````yaml /openapi.json get /api/v1/me/nights
openapi: 3.1.0
info:
  title: Apnealytics API
  version: 1.0.0
  description: >-
    A read-only REST API for your own CPAP therapy data. Authenticate with a
    personal API key (created in the app under Account → API) sent as a Bearer
    token. Every response is JSON and is scoped to your own account only. The
    API is a Pro feature.


    Apnealytics is a tracking and coaching tool, not a medical device.
    Machine-estimated AHI and the values returned here are not a clinical
    diagnosis — discuss your therapy with a qualified clinician.
servers:
  - url: https://my.apnealytics.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Account
    description: Account profile and high-level counts.
  - name: Therapy
    description: Nightly therapy data and aggregate summaries.
  - name: Vitals
    description: Wearable / Apple Health daily metrics.
paths:
  /api/v1/me/nights:
    get:
      tags:
        - Therapy
      summary: Nightly rows
      description: >-
        Returns individual nightly rows in ascending date order. Optionally
        filter by an inclusive date window with `from` / `to`. The response
        contains the most recent `limit` rows that match the filter (default
        100, maximum 1000); `total` is the number of rows matching the filter
        before the limit is applied.


        Non-ResMed machines (DreamStation, F&P SleepStyle, DeVilbiss, BMC)
        currently populate usage and pressure settings only — clinical fields
        such as AHI sub-indices and leak are `null` for those nights.
      operationId: getNights
      parameters:
        - name: from
          in: query
          required: false
          description: Inclusive lower bound on the night date, `YYYY-MM-DD`.
          schema:
            type: string
            format: date
            pattern: ^\d{4}-\d{2}-\d{2}$
          example: '2026-09-01'
        - name: to
          in: query
          required: false
          description: Inclusive upper bound on the night date, `YYYY-MM-DD`.
          schema:
            type: string
            format: date
            pattern: ^\d{4}-\d{2}-\d{2}$
          example: '2026-09-30'
        - name: limit
          in: query
          required: false
          description: >-
            Maximum number of (most recent) rows to return. Clamped to the range
            1–1000. Defaults to 100.
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 100
          example: 30
      responses:
        '200':
          description: A page of nightly rows.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NightsResponse'
              example:
                nights:
                  - date: '2026-10-13'
                    usage_min: 441
                    ahi: 2.9
                    oai: 1.1
                    cai: 0.3
                    hi: 1.4
                    uai: 0.1
                    leak_50: 3.6
                    leak_95: 11.4
                    press_50: 9.2
                    press_95: 10.8
                    rr_50: 14.5
                    spo2_50: 95
                    set_min: 7
                    set_max: 15
                    epr: 2
                    epr_enabled: true
                    mode: 1
                    source: resmed
                count: 1
                total: 212
                limit: 30
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - bearerAuth: []
components:
  schemas:
    NightsResponse:
      type: object
      properties:
        nights:
          type: array
          description: The returned page of nights, oldest first.
          items:
            $ref: '#/components/schemas/Night'
        count:
          type: integer
          description: Number of rows in this page.
        total:
          type: integer
          description: Total rows matching the filter before `limit` was applied.
        limit:
          type: integer
          description: The effective limit used (after clamping).
      required:
        - nights
        - count
        - total
        - limit
    Night:
      type: object
      description: >-
        One night of therapy. Leak is stored in L/min; pressures in cmH2O; AHI
        and sub-indices are events/hour. Clinical fields may be null for
        non-ResMed sources.
      properties:
        date:
          type: string
          format: date
          description: Calendar day of therapy, `YYYY-MM-DD`.
        usage_min:
          type: number
          description: Mask-on time for the night, in minutes.
        ahi:
          type:
            - number
            - 'null'
          description: Apnea-Hypopnea Index (events/hour).
        oai:
          type:
            - number
            - 'null'
          description: Obstructive apnea index.
        cai:
          type:
            - number
            - 'null'
          description: Central apnea index.
        hi:
          type:
            - number
            - 'null'
          description: Hypopnea index.
        uai:
          type:
            - number
            - 'null'
          description: Unclassified apnea index.
        leak_50:
          type:
            - number
            - 'null'
          description: Median leak (L/min).
        leak_95:
          type:
            - number
            - 'null'
          description: 95th-percentile leak (L/min).
        press_50:
          type:
            - number
            - 'null'
          description: Median pressure (cmH2O).
        press_95:
          type:
            - number
            - 'null'
          description: 95th-percentile pressure (cmH2O).
        rr_50:
          type:
            - number
            - 'null'
          description: Median respiratory rate.
        spo2_50:
          type:
            - number
            - 'null'
          description: Median SpO2 (%) from the machine, when recorded.
        set_min:
          type:
            - number
            - 'null'
          description: Configured minimum pressure (cmH2O).
        set_max:
          type:
            - number
            - 'null'
          description: Configured maximum pressure (cmH2O).
        epr:
          type:
            - number
            - 'null'
          description: Expiratory pressure relief setting.
        epr_enabled:
          type:
            - boolean
            - 'null'
          description: Whether EPR was enabled.
        mode:
          type:
            - integer
            - 'null'
          description: Machine mode code.
        source:
          type: string
          description: Machine family this night was parsed from.
          enum:
            - resmed
            - dreamstation
            - fp_sleepstyle
            - devilbiss
            - bmc
      required:
        - date
        - usage_min
        - ahi
        - oai
        - cai
        - hi
        - uai
        - leak_50
        - leak_95
        - press_50
        - press_95
        - rr_50
        - spo2_50
        - set_min
        - set_max
        - epr
        - epr_enabled
        - mode
        - source
    Error:
      type: object
      description: Uniform error envelope. `error` is a stable machine-readable code.
      properties:
        error:
          type: string
          description: Error code.
          enum:
            - unauthorized
            - invalid_request
            - server_error
      required:
        - error
  responses:
    InvalidRequest:
      description: >-
        A query parameter failed validation (e.g. a `from`/`to` value that is
        not `YYYY-MM-DD`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: invalid_request
    Unauthorized:
      description: >-
        Missing, malformed, revoked, expired, or non-Pro API key. The body never
        distinguishes between these cases.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
    ServerError:
      description: >-
        Unexpected server error. The body carries no stack trace or internal
        detail.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: server_error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Personal API key, created in the app under Account → API. Send it as
        `Authorization: Bearer apn_...`. Keys are read-only, Pro-gated, and
        revocable. A revoked, expired, or non-Pro key returns 401.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.