این فایل تولیدشده است — دستی ویرایشش نکنید.
Generated from the live OpenAPI schema by
backend/scripts/generate_api_docs.py. Editing it by hand is how the previous copy drifted into documenting endpoints that do not exist.Regenerate:
cd backend && python scripts/generate_api_docs.pyCI fails if this file is out of date.
روتها سه وضعیت دسترسی دارند (تعریف در backend/app/api/v1/__init__.py):
| دسته | پیشوند/مسیرها | احراز هویت |
|---|---|---|
| Public | health/*, metrics, auth/login, nobitex/status, agents |
بدون توکن |
| Protected | ai/*, trading/*, risk/*, auth/me, auth/users* |
Authorization: Bearer <JWT> |
| Realtime | ws/ws |
کوئری ?token=<JWT> در handshake |
TOKEN=$(curl -s -X POST http://localhost:8000/api/v1/auth/login \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=admin@aark-kernel.dev&password=<ADMIN_PASSWORD>' \
| python3 -c 'import sys,json;print(json.load(sys.stdin)["access_token"])')
curl -s http://localhost:8000/api/v1/auth/me -H "Authorization: Bearer $TOKEN"توکن ۳۰ دقیقه اعتبار دارد (ACCESS_TOKEN_TTL_MINUTES در app/core/auth.py).
حساب ادمین هنگام اولین راهاندازی از ADMIN_EMAIL / ADMIN_PASSWORD در .env
ساخته میشود (app/db/init_db.py::bootstrap_admin).
ws://<host>/api/v1/ws/ws?token=<JWT>
پیامهای کلاینت:
{"type": "subscribe", "topic": "market.BTCUSDT"}
{"type": "unsubscribe", "topic": "market.BTCUSDT"}
{"type": "ping"}
{"type": "get_status"}پیامهای سرور: connected, subscribed, unsubscribed, pong, status,
heartbeat, market_update, order_update, position_update, risk_alert,
portfolio_update, agent_message, notification.
توکن نامعتبر یا منقضی → بستهشدن با کد 1008.
App: AARK Kernel Ops
Version: 3.3.0
Routes: 39 paths
Prefix: /api/v1
- Advanced AI — 8 operation(s)
- Advanced Risk Management — 7 operation(s)
- Authentication & Authorization — 8 operation(s)
- External Integrations — 1 operation(s)
- Health & Monitoring — 4 operation(s)
- Multi-Agent Gateway — 3 operation(s)
- Trading Engine — 9 operation(s)
- Untagged — 4 operation(s)
Agent Chat
Request body — application/json → ChatRequest
| Field | Type | Required |
|---|---|---|
message |
string | ✅ |
model |
— | — |
use_tools |
boolean | — |
stream |
boolean | — |
system_prompt |
— | — |
Responses: 200, 422
Evaluate Stream
Request body — application/json → EvaluateStreamRequest
| Field | Type | Required |
|---|---|---|
wallet_balance_irt |
number | ✅ |
market_context |
string | ✅ |
Responses: 200, 422
Clear Memory
Responses: 200
Get Memory Summary
Responses: 200
List Models
Responses: 200
Register Model
Request body — application/json → ModelRegisterRequest
| Field | Type | Required |
|---|---|---|
name |
string | ✅ |
provider |
string | ✅ |
base_url |
string | ✅ |
api_key |
— | — |
max_tokens |
integer | — |
temperature |
number | — |
supports_tools |
boolean | — |
supports_streaming |
boolean | — |
priority |
integer | — |
Responses: 200, 422
List Tools
Responses: 200
Execute Tool
Parameters
| Name | In | Type | Required |
|---|---|---|---|
tool_name |
query | string | ✅ |
Request body — application/json
Responses: 200, 422
Get Correlation Risk
Analyze correlation risk across positions.
Parameters
| Name | In | Type | Required |
|---|---|---|---|
symbols |
query | array | ✅ |
lookback_days |
query | integer | — |
Responses: 200, 422
Legacy Validate Order
Backward compatible risk validation endpoint.
Request body — application/json → LegacyValidateRequest
| Field | Type | Required |
|---|---|---|
current_balance_irt |
number | ✅ |
requested_amount_irt |
number | ✅ |
Responses: 200, 422
Calculate Position Size
Calculate dynamic position size based on risk parameters.
Request body — application/json → PositionSizeRequest
| Field | Type | Required |
|---|---|---|
symbol |
string | ✅ |
signal_strength |
number | ✅ |
volatility |
number | ✅ |
portfolio_value |
number | ✅ |
current_positions |
object | — |
prices |
object | — |
max_risk_per_trade |
number | — |
Responses: 200, 422
Run Stress Test
Run portfolio stress tests against the 6 built-in (or custom) scenarios.
Request body — application/json → StressTestRequest
| Field | Type | Required |
|---|---|---|
positions |
object | — |
prices |
object | — |
scenarios |
— | — |
Responses: 200, 422
Get Risk Summary
Get current risk engine configuration and state.
Responses: 200
Validate Portfolio Risk
Comprehensive portfolio risk validation.
Request body — application/json → RiskValidateRequest
| Field | Type | Required |
|---|---|---|
positions |
object | — |
prices |
object | — |
daily_pnl |
number | — |
portfolio_value |
number | ✅ |
returns_history |
— | — |
Responses: 200, 422
Get Var
Calculate Value at Risk using specified method.
Parameters
| Name | In | Type | Required |
|---|---|---|---|
method |
query | string | — |
confidence |
query | number | — |
portfolio_value |
query | number | ✅ |
Responses: 200, 422
Login
Request body — application/x-www-form-urlencoded → Body_login_api_v1_auth_login_post
| Field | Type | Required |
|---|---|---|
grant_type |
— | — |
username |
string | ✅ |
password |
string | ✅ |
scope |
string | — |
client_id |
— | — |
client_secret |
— | — |
Responses: 200, 422
Get Current User Info
Responses: 200
Update Current User
Request body — application/json → UserUpdate
| Field | Type | Required |
|---|---|---|
full_name |
— | — |
role |
— | — |
is_active |
— | — |
Responses: 200, 422
Register
Request body — application/json → UserCreate
| Field | Type | Required |
|---|---|---|
email |
string | ✅ |
password |
string | ✅ |
full_name |
— | — |
role |
UserRole | — |
Responses: 200, 422
List Users
Parameters
| Name | In | Type | Required |
|---|---|---|---|
skip |
query | integer | — |
limit |
query | integer | — |
Responses: 200, 422
Delete User
Parameters
| Name | In | Type | Required |
|---|---|---|---|
user_id |
path | integer | ✅ |
Responses: 200, 422
Get User
Parameters
| Name | In | Type | Required |
|---|---|---|---|
user_id |
path | integer | ✅ |
Responses: 200, 422
Update User
Parameters
| Name | In | Type | Required |
|---|---|---|---|
user_id |
path | integer | ✅ |
Request body — application/json → UserUpdate
| Field | Type | Required |
|---|---|---|
full_name |
— | — |
role |
— | — |
is_active |
— | — |
Responses: 200, 422
Sync Accounting Event
وبهوک ورودی/خروجی استاندارد برای اتصال به سیستمهای مالی و حسابداری
Request body — application/json
Responses: 200, 422
Health Check
Responses: 200
Liveness Probe
Responses: 200
Readiness Probe
Responses: 200
Metrics
Responses: 200
List Agents
دریافت لیست ایجنتهای ثبتشده سیستم
Responses: 200
Agent To Agent Message
پروتکل ارتباطی بین ایجنتها (Agent-to-Agent)
Request body — application/json → AgentMessage
| Field | Type | Required |
|---|---|---|
sender_id |
string | ✅ |
target_id |
string | ✅ |
action |
string | ✅ |
payload |
object | — |
timestamp |
string | — |
Responses: 200, 422
Register New Agent
تعریف و ثبت داینامیک ایجنت از پنل یا اپلیکیشنهای دیگر
Request body — application/json → AgentConfig
| Field | Type | Required |
|---|---|---|
id |
string | — |
name |
string | ✅ |
role |
string | ✅ |
system_prompt |
string | ✅ |
allowed_tools |
array | — |
is_active |
boolean | — |
metadata |
object | — |
Responses: 200, 422
List Orders
Parameters
| Name | In | Type | Required |
|---|---|---|---|
symbol |
query | — | — |
Responses: 200, 422
Place Order
Request body — application/json → PlaceOrderRequest
| Field | Type | Required |
|---|---|---|
symbol |
string | ✅ |
side |
string | ✅ |
order_type |
string | ✅ |
quantity |
number | ✅ |
price |
— | — |
stop_price |
— | — |
client_order_id |
— | — |
Responses: 200, 422
Place Batch Orders
Request body — application/json
Responses: 200, 422
Cancel Order
Parameters
| Name | In | Type | Required |
|---|---|---|---|
order_id |
path | string | ✅ |
Responses: 200, 422
Get Order
Parameters
| Name | In | Type | Required |
|---|---|---|---|
order_id |
path | string | ✅ |
Responses: 200, 422
Get Balances
Responses: 200
Get Pnl
Responses: 200
Get Positions
Responses: 200
Get Portfolio Value
Total portfolio value quoted in IRT.
Responses: 200
Evaluate
Request body — application/json → EvaluateRequest
| Field | Type | Required |
|---|---|---|
wallet_balance_irt |
number | ✅ |
market_context |
string | ✅ |
Responses: 200, 422
Remove Nobitex Key
Forget the stored API key (kill-switch for exchange access).
Responses: 200
Save Nobitex Key
Request body — application/json → NobitexKeyRequest
| Field | Type | Required |
|---|---|---|
api_key |
string | ✅ |
Responses: 200, 422
Nobitex Status
Responses: 200
| Field | Type | Required |
|---|---|---|
id |
string | — |
name |
string | ✅ |
role |
string | ✅ |
system_prompt |
string | ✅ |
allowed_tools |
array | — |
is_active |
boolean | — |
metadata |
object | — |
| Field | Type | Required |
|---|---|---|
sender_id |
string | ✅ |
target_id |
string | ✅ |
action |
string | ✅ |
payload |
object | — |
timestamp |
string | — |
| Field | Type | Required |
|---|---|---|
grant_type |
— | — |
username |
string | ✅ |
password |
string | ✅ |
scope |
string | — |
client_id |
— | — |
client_secret |
— | — |
| Field | Type | Required |
|---|---|---|
message |
string | ✅ |
model |
— | — |
use_tools |
boolean | — |
stream |
boolean | — |
system_prompt |
— | — |
| Field | Type | Required |
|---|---|---|
symbol_pairs |
object | ✅ |
max_correlation |
number | ✅ |
avg_correlation |
number | ✅ |
high_correlation_pairs |
array | ✅ |
concentration_risk |
number | ✅ |
| Field | Type | Required |
|---|---|---|
wallet_balance_irt |
number | ✅ |
market_context |
string | ✅ |
| Field | Type | Required |
|---|---|---|
wallet_balance_irt |
number | ✅ |
market_context |
string | ✅ |
| Field | Type | Required |
|---|---|---|
detail |
array | — |
| Field | Type | Required |
|---|---|---|
current_balance_irt |
number | ✅ |
requested_amount_irt |
number | ✅ |
| Field | Type | Required |
|---|---|---|
name |
string | ✅ |
provider |
string | ✅ |
base_url |
string | ✅ |
api_key |
— | — |
max_tokens |
integer | — |
temperature |
number | — |
supports_tools |
boolean | — |
supports_streaming |
boolean | — |
priority |
integer | — |
| Field | Type | Required |
|---|---|---|
api_key |
string | ✅ |
| Field | Type | Required |
|---|---|---|
order_id |
string | ✅ |
client_order_id |
— | ✅ |
symbol |
string | ✅ |
side |
string | ✅ |
order_type |
string | ✅ |
quantity |
number | ✅ |
price |
— | ✅ |
status |
string | ✅ |
filled_quantity |
number | ✅ |
avg_fill_price |
— | ✅ |
commission |
number | ✅ |
timestamp |
string | ✅ |
| Field | Type | Required |
|---|---|---|
symbol |
string | ✅ |
side |
string | ✅ |
order_type |
string | ✅ |
quantity |
number | ✅ |
price |
— | — |
stop_price |
— | — |
client_order_id |
— | — |
| Field | Type | Required |
|---|---|---|
order_id |
string | ✅ |
client_order_id |
— | ✅ |
symbol |
string | ✅ |
side |
string | ✅ |
order_type |
string | ✅ |
quantity |
number | ✅ |
price |
— | ✅ |
status |
string | ✅ |
filled_quantity |
number | ✅ |
avg_fill_price |
— | ✅ |
error |
— | — |
| Field | Type | Required |
|---|---|---|
symbol |
string | ✅ |
signal_strength |
number | ✅ |
volatility |
number | ✅ |
portfolio_value |
number | ✅ |
current_positions |
object | — |
prices |
object | — |
max_risk_per_trade |
number | — |
| Field | Type | Required |
|---|---|---|
recommended_size |
number | ✅ |
risk_budget_used |
number | ✅ |
volatility_adjusted_size |
number | ✅ |
signal_adjusted_size |
number | ✅ |
| Field | Type | Required |
|---|---|---|
metrics |
array | ✅ |
overall_level |
string | ✅ |
timestamp |
string | ✅ |
| Field | Type | Required |
|---|---|---|
positions |
object | — |
prices |
object | — |
daily_pnl |
number | — |
portfolio_value |
number | ✅ |
returns_history |
— | — |
| Field | Type | Required |
|---|---|---|
positions |
object | — |
prices |
object | — |
scenarios |
— | — |
| Field | Type | Required |
|---|---|---|
scenario_name |
string | ✅ |
portfolio_value_before |
number | ✅ |
portfolio_value_after |
number | ✅ |
pnl_impact |
number | ✅ |
pnl_pct |
number | ✅ |
risk_level |
string | ✅ |
details |
object | ✅ |
| Field | Type | Required |
|---|---|---|
access_token |
string | ✅ |
token_type |
string | — |
expires_in |
integer | ✅ |
| Field | Type | Required |
|---|---|---|
email |
string | ✅ |
password |
string | ✅ |
full_name |
— | — |
role |
UserRole | — |
| Field | Type | Required |
|---|---|---|
id |
integer | ✅ |
email |
string | ✅ |
full_name |
— | ✅ |
role |
UserRole | ✅ |
is_active |
boolean | ✅ |
is_superuser |
boolean | ✅ |
created_at |
string | ✅ |
last_login |
— | ✅ |
(free-form object)
| Field | Type | Required |
|---|---|---|
full_name |
— | — |
role |
— | — |
is_active |
— | — |
| Field | Type | Required |
|---|---|---|
var_95 |
number | ✅ |
var_99 |
number | ✅ |
cvar_95 |
number | ✅ |
cvar_99 |
number | ✅ |
confidence_level |
number | ✅ |
method |
string | ✅ |
timestamp |
string | ✅ |
| Field | Type | Required |
|---|---|---|
loc |
array | ✅ |
msg |
string | ✅ |
type |
string | ✅ |
input |
— | — |
ctx |
object | — |
- در FastAPI پارامترهای scalar یک endpoint
POSTبهصورت پیشفرض query هستند و پارامترهای غیرscalar (dict/model) body. ترکیب این دو در یک endpoint باعث قرارداد گیجکننده میشود —/risk/validateقبلاً به همین دلیل همیشه422میداد. همهٔ این endpointها حالا مدل درخواست صریح دارند. /docs(Swagger UI) فقط وقتیDEBUG=trueباشد فعال است.- پاسخ خطاها شامل
correlation_idاست که در هدرX-Correlation-IDهم میآید.