Skip to content
Last updated

This example is a simple client application that uses C# 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.

Tutorial

Step 1: Get the code from GitHub

  • Clone the code from this repository.
  • Or download the ZIP file and extract it.
  • Navigate to the Examples/CSharp_Live folder.
git clone https://github.com/CirrusResearch/MyCirrus.git
git checkout master
cd Examples/CSharp_Live

Step 2: Add your API key

  • Edit the Program.cs file and replace <YOUR_API_KEY> with your API key.
  • For this example you also need to replace <YOUR_SERIAL> with the serial number of one of your instruments.

You can create an API key in the MyCirrus website. For more details see the Authentication guide.

const string Key = "<YOUR_API_KEY>";
const string SerialNumber = "<YOUR_SERIAL>";

Step 3: Running the Example

  • Run dotnet run to build and run the example
EXAMPLE_OUTPUT

Summary

This example showed how to connect to the MyCirrus live API using C#. 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 section.