OS Trading Engine
API Reference
Overview

API Overview

The Nexgent API provides programmatic access to manage agents, execute trades, and monitor positions.


Base URL

All API requests are made to:

https://your-instance.com/api/v1

For local development:

http://localhost:4000/api/v1

API Versioning

The API uses URL-based versioning. The current version is v1.

/api/v1/agents
/api/v1/trading-signals
/api/v1/wallets

Authentication

The API supports two authentication methods:

MethodUse CaseHeader
JWT TokenDashboard, user sessionsAuthorization: Bearer <access_token>
API KeyProgrammatic access, integrationsX-API-Key: nex_xxxxx

Quick Examples

JWT Authentication:

curl -X GET https://your-instance.com/api/v1/agents \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."

API Key Authentication:

curl -X POST https://your-instance.com/api/v1/trading-signals \
  -H "X-API-Key: nex_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" \
  -H "Content-Type: application/json" \
  -d '{"tokenAddress": "...", "action": "buy", "score": 4}'

Request Format

Content Type

All requests with a body must use JSON:

Content-Type: application/json

Request Body

{
  "name": "My Agent",
  "tradingMode": "simulation"
}

Response Format

All responses return JSON with consistent structure.

Success Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "My Agent",
  "tradingMode": "simulation",
  "isActive": true,
  "createdAt": "2024-01-15T10:30:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z"
}

List Response

[
  { "id": "...", "name": "Agent 1", ... },
  { "id": "...", "name": "Agent 2", ... }
]

Error Response

{
  "error": "Agent not found",
  "code": "AGENT_NOT_FOUND"
}

Available Endpoints

Authentication

EndpointDescription
POST /auth/registerRegister new user
POST /auth/loginLogin and get tokens
POST /auth/refreshRefresh access token
POST /auth/logoutLogout and invalidate tokens
GET /auth/meGet current user

Agents

EndpointDescription
GET /agentsList all agents
POST /agentsCreate new agent
GET /agents/:idGet agent by ID
PUT /agents/:idUpdate agent
DELETE /agents/:idDelete agent
GET /agents/:id/configGet agent trading config
PUT /agents/:id/configUpdate agent trading config
GET /agents/:id/performanceGet agent performance metrics
GET /agents/:id/balance-historyGet agent balance history

Agent Resources

EndpointDescription
GET /agent-balancesList agent balances
GET /agent-positionsList agent positions
POST /agent-positions/:id/closeClose a position
GET /agent-transactionsList agent transactions
GET /agent-historical-swapsList historical swaps

Trading Signals

EndpointDescription
GET /trading-signalsList signals
POST /trading-signalsCreate new signal
GET /trading-signals/:idGet signal by ID
DELETE /trading-signals/:idDelete signal

Wallets

EndpointDescription
GET /walletsList available wallets
POST /wallets/assignAssign wallet to agent
POST /wallets/resetReset wallet assignment

API Keys

EndpointDescription
GET /api-keysList API keys
POST /api-keysCreate new API key
DELETE /api-keys/:idDelete API key

Data & Prices

EndpointDescription
GET /price-feedsGet current prices
GET /data-sourcesList data sources

Health & Metrics

EndpointDescription
GET /healthHealth check
GET /health/liveLiveness probe
GET /health/readyReadiness probe
GET /metricsPrometheus metrics

HTTP Status Codes

CodeDescription
200Success
201Created
400Bad Request - Invalid input
401Unauthorized - Invalid or missing auth
403Forbidden - Insufficient permissions
404Not Found - Resource doesn't exist
423Locked - Account locked
429Too Many Requests - Rate limited
500Internal Server Error

Pagination

List endpoints support pagination via query parameters:

ParameterDescriptionDefault
limitNumber of items to return50
offsetNumber of items to skip0

Example:

GET /api/v1/agents?limit=10&offset=20

Filtering

Many list endpoints support filtering:

# Filter agent balances by agent
GET /api/v1/agent-balances?agentId=550e8400-e29b-41d4-a716-446655440000
 
# Filter transactions by agent
GET /api/v1/agent-transactions?agentId=550e8400-e29b-41d4-a716-446655440000

SDKs & Tools

Postman Collection

A complete Postman collection is available for testing:

cURL Examples

All documentation includes cURL examples for quick testing.