Create projects, request bot builds using QuantLab's own frameworks, run backtests, and fetch results with an API key instead of a browser session. Everything here consumes the same account quotas as the app, there is no separate developer allowance.
1. Sign in, go to Settings then API, and create a key. Copy it immediately, it is shown once.
2. Every request needs it as a bearer token:
curl https://alorny-quantlab.vercel.app/api/v1/me \
-H "Authorization: Bearer qlk_your_key_here"Every response is one of two shapes:
{ "ok": true, "data": { ... } }
{ "ok": false, "error": "some_error_code", "hint": "what to do about it" }Create a project (a trading bot, indicator, script, panel, or library):
curl https://alorny-quantlab.vercel.app/api/v1/projects \
-H "Authorization: Bearer qlk_your_key_here" \
-H "Content-Type: application/json" \
-d '{"name":"London breakout bot","platform":"mql5","requirements":"MT5 EA that trades the London session breakout with a 1 percent risk stop"}'Send a build request. This runs QuantLab's own generate and compile pipeline, the same one the in app chat uses, and it consumes the account's build quota:
curl https://alorny-quantlab.vercel.app/api/v1/projects/PROJECT_ID/messages \
-H "Authorization: Bearer qlk_your_key_here" \
-H "Content-Type: application/json" \
-d '{"content":"Add a daily loss limit of 3 percent that stops new trades once hit"}'Poll the project, then fetch the compiled source once the build is ready:
curl https://alorny-quantlab.vercel.app/api/v1/projects/PROJECT_ID \
-H "Authorization: Bearer qlk_your_key_here"
curl https://alorny-quantlab.vercel.app/api/v1/builds/BUILD_ID/source \
-H "Authorization: Bearer qlk_your_key_here"Run a real MT5 Strategy Tester DeepTest on the account's signed-in QuantLab desktop app (mode can also be preview for a quick estimate):
curl https://alorny-quantlab.vercel.app/api/v1/projects/PROJECT_ID/backtests \
-H "Authorization: Bearer qlk_your_key_here" \
-H "Content-Type: application/json" \
-d '{"mode":"real","symbol":"EURUSD","timeframe":"M15","from":"2023-01-01","to":"2024-12-31","deposit":10000}'Poll for status and metrics:
curl https://alorny-quantlab.vercel.app/api/v1/backtests/BACKTEST_ID \
-H "Authorization: Bearer qlk_your_key_here"Once a real backtest is ready, validate the edge with a market permutation test, or pull tester diagnostics if it misbehaved. Neither consumes AI or quota:
curl https://alorny-quantlab.vercel.app/api/v1/backtests/BACKTEST_ID/mcpt \
-H "Authorization: Bearer qlk_your_key_here" -d '{"n":50}'
curl https://alorny-quantlab.vercel.app/api/v1/backtests/BACKTEST_ID/diagnose \
-H "Authorization: Bearer qlk_your_key_here"Download the MCP server, then add it with one command:
curl -O https://alorny-quantlab.vercel.app/dev/quantlab-mcp.mjs
claude mcp add quantlab -e QUANTLAB_API_KEY=qlk_your_key_here -- node quantlab-mcp.mjsThat gives Claude Code these tools: quantlab_list_projects, quantlab_create_project, quantlab_get_project, quantlab_send_build_request, quantlab_get_build_source, quantlab_run_backtest, quantlab_get_backtest, quantlab_run_permutation_test, quantlab_run_diagnostics, quantlab_list_library.
If you keep a project level CLAUDE.md, this paste block gives an agent enough context to use the tools well:
## QuantLab MCP tools
Use the quantlab_* tools to build and test trading bots on QuantLab instead of
writing MQL5/NinjaScript/Pine by hand:
- quantlab_create_project then quantlab_send_build_request to generate and
compile a strategy using QuantLab's own frameworks
- quantlab_get_project / quantlab_get_build_source to check status and read
the generated source
- quantlab_run_backtest (mode "real" for a genuine MT5 Strategy Tester
DeepTest) then quantlab_get_backtest to read metrics
- quantlab_run_permutation_test and quantlab_run_diagnostics to sanity check
a result before trusting it
All of these consume the connected QuantLab account's normal plan quota.The MCP server is a single dependency free file (QUANTLAB_API_KEY and optional QUANTLAB_BASE_URL are its only config), so you can also point any other MCP capable agent at it the same way.
/api/v1/me/api/v1/projects/api/v1/projects/api/v1/projects/:id/api/v1/projects/:id/messages/api/v1/projects/:id/builds/api/v1/builds/:id/source/api/v1/projects/:id/backtests/api/v1/projects/:id/backtests/api/v1/backtests/:id/api/v1/backtests/:id/mcpt/api/v1/backtests/:id/diagnose/api/v1/library/api/v1/libraryEach API key is limited to 60 requests per minute. Going over returns HTTP 429 with a retry hint.
API usage draws from the exact same monthly quotas as the app: builds, preview backtests, real (DeepTest) backtests, and optimization runs. There is no separate developer allowance and no way to bypass a plan's limits or the free trial gate from the API. Backtests still require the account's QuantLab desktop application to be installed and online, since MT5 runs on your own machine.
Revoke a key any time from Settings then API. A revoked key stops working immediately, and creating a new key never affects existing ones.