Overview

This page explains how to initialize the Ekiden SDK in TypeScript, Python, and Rust. Initialization sets up your client to interact with Ekiden’s REST and WebSocket APIs. You can operate in either public mode (read-only access) or authenticated mode (private endpoints and trading).

Supported Environments

Ekiden supports the following environments:

EnvironmentNetwork KeyBase REST URLWebSocket URL
Mainnetmainnethttps://api.ekiden.fiwss://ws.ekiden.fi
Testnettestnethttps://testnet.ekiden.fiwss://testnet-ws.ekiden.fi

Use the network parameter during client initialization to select your target environment.

Initialization Parameters

ParameterDescriptionRequiredDefault
networkTarget network (mainnet or testnet)Nomainnet
api_keyYour Ekiden API keyRequired for private endpoints
api_secretYour Ekiden API secretRequired for private endpoints
private_key(Alternative) Private key for signature-based authRequired if not using API key
subaccount_idOptional subaccount IDNo0
use_websocketWhether to initialize WebSocket connectionsNotrue
base_urlOverride default REST URLNoAuto-detected from network
ws_urlOverride default WebSocket URLNoAuto-detected from network

TypeScript Example

import { EkidenClient, Networks } from '@ekiden/sdk';

const client = new EkidenClient({
  network: Networks.TESTNET,
  apiKey: process.env.EKIDEN_API_KEY,
  apiSecret: process.env.EKIDEN_API_SECRET,
  subaccountId: 0,
  useWebsocket: true
});

await client.connect();
const markets = await client.getMarkets();
console.log(markets);

Python Example

from ekiden_sdk import EkidenClient
import os

client = EkidenClient(
    network="testnet",
    api_key=os.getenv("EKIDEN_API_KEY"),
    api_secret=os.getenv("EKIDEN_API_SECRET"),
    subaccount_id=0,
    use_websocket=True
)

client.connect()
markets = client.get_markets()
print(markets)

Rust Example

use ekiden_sdk::{ClientBuilder, Network};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ClientBuilder::new(Network::Testnet)
        .with_api_key(std::env::var("EKIDEN_API_KEY")?)
        .with_api_secret(std::env::var("EKIDEN_API_SECRET")?)
        .with_subaccount(0)
        .enable_websocket(true)
        .build()?;

    let markets = client.get_markets().await?;
    println!("{:?}", markets);

    Ok(())
}

Authentication Tips

  • Never hardcode your secrets in code.
  • Use environment variables or secure vaults.
  • Validate your connection with a public call like get_markets().

Troubleshooting

  • 401 Unauthorized: Check your keys and secret.
  • Timeouts: Check your network connection or proxy settings.
  • WebSocket not connecting: Verify ws_url and ensure the port is open.

Next Steps

Once initialized, explore other sections of the SDK documentation to:

  • Place trades
  • Subscribe to real-time updates
  • Query account balances and positions