# Live Node.js client This example is a simple client application that uses Node.js to access the live API (WebSocket). It will connect the websocket for an instrument, display the live data for a few minutes and then disconnect. This example uses the `ws` library for WebSocket connections. ## Tutorial ### Step 1: Get the code from GitHub - Clone the code from [this repository](https://github.com/CirrusResearch/MyCirrus). - Or download the [ZIP file](https://github.com/CirrusResearch/MyCirrus/archive/refs/heads/master.zip) and extract it. - Navigate to the `Examples/Nodejs_Live` folder. ```shell git clone https://github.com/CirrusResearch/MyCirrus.git git checkout master cd Examples/Nodejs_Live ``` ### Step 2: Add your API key - Edit the `index.js` file and replace `` with your API key. - For this example you also need to replace `` with the serial number of one of your instruments. You can create an API key in the [MyCirrus website](https://mycirrus.cloud/developer-api). For more details see the [Authentication guide](/guides/authentication). ```js const ws = new WebSocket('wss://api.mycirrus.cloud/v1/live/', { headers: { 'X-Api-Key': '' } }); ``` ### Step 3: Running the Example - Run `npm install` to install the dependencies. - Run `node index.js` to run the example. ```shell EXAMPLE_OUTPUT ``` ## Summary This example showed how to connect to the MyCirrus live API using Node.js and the `ws` library. It demonstrated how to establish a WebSocket connection, subscribe to live data for a specific instrument, and handle incoming messages. You can modify the example to suit your needs, such as changing which live data you request or sending commands for other actions such as Calibration. For more information on the available WebSocket messages and data formats, refer to the [API Reference](/apis) section.