Skip to main content
Skip to main content
Version: Next 🚧

List Algorithms

Retrieve a paginated list of the authenticated user's trading algorithms.

Endpoint

GET /api/trading/algorithms

Authentication

Requires authentication via Bearer token.

Authorization: Bearer <access_token>

Request

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Items per page (max: 100)
statusstring-Filter by status: draft, active, stopped, paused, error
strategyTypestring-Filter by strategy type
sortstringcreatedAtSort field: name, createdAt, updatedAt
orderstringdescSort order: asc, desc

Example Request

GET /api/trading/algorithms?page=1&limit=20&status=active&sort=name&order=asc

Response

Success (200 OK)

{
"data": [
{
"id": "507f1f77bcf86cd799439011",
"name": "RSI Momentum Strategy",
"status": "active",
"active": true,
"strategyType": "momentum",
"timeframe": "15m",
"symbols": ["NSE:RELIANCE", "NSE:TCS"],
"performance": {
"totalTrades": 45,
"winRate": 62.5,
"totalProfit": 15000,
"profitFactor": 1.8
},
"createdAt": "2024-01-10T10:00:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
},
{
"id": "507f1f77bcf86cd799439012",
"name": "EMA Crossover",
"status": "stopped",
"active": false,
"strategyType": "trend",
"timeframe": "1h",
"symbols": ["NSE:NIFTY"],
"performance": {
"totalTrades": 12,
"winRate": 58.3,
"totalProfit": 5000,
"profitFactor": 1.5
},
"createdAt": "2024-01-05T14:00:00Z",
"updatedAt": "2024-01-14T09:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 2,
"totalPages": 1
}
}

Examples

Get All Active Algorithms

cURL:

curl -X GET "https://api.x3algo.com/api/trading/algorithms?status=active" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

JavaScript:

const response = await fetch('https://api.x3algo.com/api/trading/algorithms?status=active', {
headers: {
'Authorization': `Bearer ${accessToken}`
}
})

const { data: algorithms, pagination } = await response.json()
console.log(`Found ${pagination.total} active algorithms`)

Python:

response = requests.get(
'https://api.x3algo.com/api/trading/algorithms',
headers={'Authorization': f'Bearer {access_token}'},
params={'status': 'active'}
)

data = response.json()
algorithms = data['data']
print(f"Found {data['pagination']['total']} active algorithms")

Get Algorithms with Pagination

JavaScript:

async function getAllAlgorithms() {
const allAlgorithms = []
let page = 1
let hasMore = true

while (hasMore) {
const response = await fetch(
`https://api.x3algo.com/api/trading/algorithms?page=${page}&limit=50`,
{
headers: { 'Authorization': `Bearer ${accessToken}` }
}
)

const { data, pagination } = await response.json()
allAlgorithms.push(...data)

hasMore = page < pagination.totalPages
page++
}

return allAlgorithms
}

Filter by Strategy Type

cURL:

curl -X GET "https://api.x3algo.com/api/trading/algorithms?strategyType=momentum&sort=performance.winRate&order=desc" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"