Cortex API
  • Getting Started
  • Connecting to the Cortex API
  • Overview of API flow
  • Authentication
    • getCortexInfo
    • getUserLogin
    • requestAccess
    • hasAccessRight
    • authorize
    • generateNewToken
    • getUserInformation
    • getLicenseInfo
  • Headsets
    • controlDevice
    • queryHeadsets
    • updateHeadset
    • updateHeadsetCustomInfo
    • syncWithHeadsetClock
    • Headset object
  • Sessions
    • createSession
    • updateSession
    • querySessions
    • Session object
  • Data Subscription
    • subscribe
    • unsubscribe
    • Data sample object
  • Records
    • createRecord
    • stopRecord
    • updateRecord
    • deleteRecord
    • exportRecord
    • queryRecords
    • getRecordInfos
    • configOptOut
    • requestToDownloadRecordData
    • Record object
  • Markers
    • injectMarker
    • updateMarker
    • Marker object
  • Subjects
    • createSubject
    • updateSubject
    • deleteSubjects
    • querySubjects
    • getDemographicAttributes
    • Subject object
  • BCI
    • queryProfile
    • getCurrentProfile
    • setupProfile
    • loadGuestProfile
    • getDetectionInfo
    • training
    • Readonly profile
  • Advanced BCI
    • getTrainedSignatureActions
    • getTrainingTime
    • facialExpressionSignatureType
    • facialExpressionThreshold
    • mentalCommandActiveAction
    • mentalCommandBrainMap
    • mentalCommandGetSkillRating
    • mentalCommandTrainingThreshold
    • mentalCommandActionSensitivity
  • Warning Objects
  • Error Codes
  • Troubleshooting Guide
  • Release Notes
  • cortexaccess tool
Powered by GitBook
On this page
  • Parameters
  • Result
  • Examples
  1. Data Subscription

subscribe

PreviousData SubscriptionNextunsubscribe

Last updated 4 years ago

This method is to subscribe to one or more data streams. You can call to cancel a subscription. After you successfully subscribe to a stream, Cortex will keep sending you .

See for details.

Parameters

Name

Type

Required

Description

cortexToken

string

yes

session

string

yes

streams

array of strings

yes

The data streams you want to subscribe to.

The parameter streams must contain one or more values, chosen from this list: "eeg", "mot", "dev", "eq", "pow", "met", "com", "fac", "sys". See for details.

To subscribe to the "eeg" stream, you must have a paid license and the session.

Result

The result is an object that includes these fields:

Name

Type

Description

success

array of objects

For each stream you successfully subscribed to, this array contains an object that describe the data structure of this stream.

failure

array of objects

For each stream you failed to subscribed to, this array contains an object that describes the error.

In case of success, you get an object with these fields:

Name

Type

Description

streamName

string

The name of the stream.

cols

array of strings

The labels of the columns that are part of this stream.

sid

string

The session id.

In case of failure, you get an object with these fields:

Name

Type

Description

streamName

string

The name of the stream.

code

number

The error code.

message

string

The error message.

Examples

Subscribe successfully to motion and performance metrics.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "subscribe",
    "params": {
        "cortexToken": "xxx",
        "session": "f8cb7289-9a92-438b-8281-e5fdffe8166e",
        "streams": ["met","mot"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure": [],
        "success": [
            {
                "cols": ["eng","exc","lex","str","rel","int","foc"],
                "sid": "f8cb7289-9a92-438b-8281-e5fdffe8166e",
                "streamName": "met"
            },
            {
                "cols": [
                    "COUNTER_MEMS",
                    "INTERPOLATED_MEMS",
                    "GYROX",
                    "GYROY",
                    "GYROZ",
                    "ACCX",
                    "ACCY",
                    "ACCZ",
                    "MAGX",
                    "MAGY",
                    "MAGZ"
                ],
                "sid": "f8cb7289-9a92-438b-8281-e5fdffe8166e",
                "streamName": "mot"
            }
        ]
    }
}

Subscribe successfully to performance metrics, but fail to subscribe to raw EEG.

{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "subscribe",
    "params": {
        "cortexToken": "xxx",
        "session": "49eb6cb0-9df6-414a-b3e8-cfa17198daa0",
        "streams": ["met","eeg"]
    }
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "failure": [
            {
                "code": -32016,
                "message": "The stream is unavailable or unsupported.",
                "streamName": "eeg"
            }
        ],
        "success": [
            {
                "cols": ["eng","exc","lex","str","rel","int","foc"],
                "sid": "49eb6cb0-9df6-414a-b3e8-cfa17198daa0",
                "streamName": "met"
            }
        ]
    }
}

A token returned by .

A session id returned by .

Please note that the field cols is especially important. This field tells you which values you will get in the data stream, and in which order. See for details.

unsubscribe
data sample objects
Data Subscription
Data Subscription
activate
Data sample object
authorize
createSession