Skip to main content

Introduction

The Primary SDK is a C# library that provides programmatic access to the Primary exchange market data and trading API. It enables you to authenticate, retrieve market data, manage orders, and receive real-time updates via WebSockets.

Installation

Add the Primary SDK to your C# project:
using Primary;
using Primary.Data;
using Primary.Data.Orders;
using Primary.WebSockets;

Initialize the API

Create an API instance by specifying the endpoint:
// Production endpoint
var api = new Api(Api.ProductionEndpoint);

// Demo endpoint
var api = new Api(Api.DemoEndpoint);

Available Endpoints

ProductionEndpoint
Uri
Production API endpoint: https://api.primary.com.ar
DemoEndpoint
Uri
Demo API endpoint: https://api.remarkets.primary.com.arGet demo credentials at https://remarkets.primary.ventures

Quick Start Example

Here’s a complete example to authenticate and get market data:
using Primary;
using Primary.Data;

// Initialize API with demo endpoint
var api = new Api(Api.DemoEndpoint);

// Authenticate
bool success = await api.Login(Api.DemoUsername, Api.DemoPassword);

if (success)
{
    // Get all instruments
    var instruments = await api.GetAllInstruments();
    
    // Get market data for a specific instrument
    var instrument = instruments.First();
    var marketData = await api.GetMarketData(instrument);
    
    Console.WriteLine($"Last price: {marketData.Data.Last?.Price}");
}

API Categories

The Primary SDK is organized into the following categories:

Authentication

Login and manage authentication tokens

Market Data

REST API for market data and historical trades

Instruments

Get instrument details and listings

Orders

Submit, cancel, and query orders

Positions

Get account positions and balances

WebSockets

Real-time market and order data streams

Error Handling

The SDK throws exceptions when API calls fail:
try
{
    var orderId = await api.SubmitOrder(Api.DemoAccount, order);
}
catch (Exception ex)
{
    Console.Error.WriteLine($"Order failed: {ex.Message}");
}
Errors include the status, message, and description from the API response.

Base URI and HTTP Client

The API class exposes the following properties:
BaseUri
Uri
The base URI for all API requests
HttpClient
HttpClient
The underlying HTTP client (default timeout: 5 minutes)

Demo Credentials

For testing, use these built-in demo credentials:
Api.DemoUsername // "naicigam2046"
Api.DemoPassword // "nczhmL9@"
Api.DemoAccount  // "REM2046"

Build docs developers (and LLMs) love