Skip to content

Crypto Trading API Documentation

Overview

The SUDIGITAL Crypto Trading API provides comprehensive endpoints for managing cryptocurrency trading operations, including assets, exchanges, markets, exchange API keys, trading bots, and transaction tracking.

Trading Components

1. Core Trading Entities

Assets

  • Purpose: Cryptocurrency and token definitions
  • Endpoints: /api/assets
  • Features: Create, read, and manage digital assets (BTC, ETH, SOL, USDT, etc.)

Exchanges

  • Purpose: Trading platform definitions
  • Endpoints: /api/exchanges
  • Features: Support for both CEX (Centralized) and DEX (Decentralized) exchanges

Markets

  • Purpose: Trading pair definitions
  • Endpoints: /api/markets
  • Features: Define trading pairs (e.g., BTC/USDT) for specific exchanges

2. User Trading Configuration

Exchange Key Management

  • Purpose: Secure storage and management of user exchange API credentials
  • Endpoints: /api/users/:id/exchange-keys
  • Security Features:
    • AES-256-CBC encryption for sensitive API keys
    • Role-based access control
    • Rate limiting (10 requests per hour)
    • Resource ownership verification

Available Operations:

typescript
GET    /api/users/:id/exchange-keys     // List user's exchange API keys
POST   /api/users/:id/exchange-keys     // Add new exchange API key
PUT    /api/exchange-keys/:id           // Update API key credentials
DELETE /api/exchange-keys/:id           // Delete API key securely

Bot Management

  • Purpose: Trading bot configuration and control
  • Endpoints: /api/users/:id/bots
  • Features:
    • Automated trading bot creation and management
    • Timeframe configuration (1H, 2H, 3H, 4H)
    • Size limits and market compatibility validation
    • Bot status tracking and control

Available Operations:

typescript
GET    /api/users/:id/bots              // List user's trading bots
POST   /api/users/:id/bots              // Create new trading bot
PUT    /api/bots/:id                    // Update bot configuration
DELETE /api/bots/:id                    // Delete trading bot

Transaction Tracking

  • Purpose: Trade execution history and monitoring
  • Endpoints: /api/users/:id/transactions, /api/bots/:id/transactions
  • Features:
    • Complete trade execution records
    • Transaction status tracking
    • Bot-linked transaction history
    • Comprehensive filtering and pagination

Available Operations:

typescript
GET    /api/users/:id/transactions      // User transaction history
GET    /api/bots/:id/transactions       // Bot transaction history
POST   /api/transactions               // Record new transaction
PUT    /api/transactions/:id           // Update transaction status

Security Implementation

Authentication & Authorization

  • JWT-based Authentication: Secure token-based access control
  • Role-based Permissions: 7 user roles with granular trading permissions
  • Resource Ownership: Users can only access their own trading resources

Rate Limiting

  • Trading Endpoints: 100 requests per 15 minutes
  • Exchange Key Management: 10 requests per hour
  • General API: 200 requests per 15 minutes

Data Encryption

  • Exchange API Keys: AES-256-CBC encryption before database storage
  • Secure Key Management: Environment-based encryption configuration
  • Sensitive Data Masking: Protected fields in API responses

Permission Matrix

User RoleCan TradeManage API KeysCreate BotsView All TransactionsManage Exchanges
Super Admin
Admin
Moderator
Owner
Worker
Player
User

Example Usage

Creating an Exchange API Key

bash
curl -X POST "https://api.sudigital.com/api/users/123/exchange-keys" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "your-exchange-api-key",
    "secretKey": "your-exchange-secret-key",
    "passphraseKey": "your-passphrase",
    "exchangeId": "exchange-uuid"
  }'

Creating a Trading Bot

bash
curl -X POST "https://api.sudigital.com/api/users/123/bots" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "BTC Scalping Bot",
    "marketId": "btc-usdt-market-uuid",
    "timeframe": "1H",
    "minimumSize": 0.001,
    "maximumSize": 0.01,
    "exchangeKeyId": "exchange-key-uuid"
  }'

Recording a Transaction

bash
curl -X POST "https://api.sudigital.com/api/transactions" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "orderNo": "exchange-order-123",
    "marketId": "btc-usdt-market-uuid",
    "side": "buy",
    "amount": 0.005,
    "price": 45000,
    "botId": "bot-uuid"
  }'

Interactive API Reference

Access the complete interactive API documentation with live testing capabilities at: /docs - Scalar API Reference

The interactive documentation includes:

  • Complete endpoint specifications
  • Request/response schemas
  • Authentication examples
  • Live API testing interface
  • Comprehensive error codes and responses