Type/to search
Getting Started
Platform Basics
Writing Strategies
Development Tools
Backtesting System
Advanced Topics
Data and Research
Extended API Interface
AI Integration
Create ApiKey
Authentication Methods
Extended API Interface Details
GetAccount
GetNodeList
DeleteNode
GetExchangeList
GetPlatformList
GetStrategyList
GetRobotGroupList
GetRobotList
GetRobotDetail
GetRobotLogs
NewRobot
RestartRobot
StopRobot
CommandRobot
DeleteRobot
PluginRun
pub
Extended API Interface Return Codes
Live Trading Status Codes

Runs a piece of JavaScript code on a docker and returns the result, without creating a robot or charging fees; one run lasts at most 5 minutes, and the code can place real orders.

Examples

Run code on docker 123 and get its logs and return value.

python
# api() is the function in the Python example on the signature authentication page import json settings = { "source": "function main() {Log(\"Hello FMZ\")}", "node": 123, "period": 60, "exchanges": [{"pid": 123, "pair": "SOL_USDT"}] } r = api('PluginRun', settings) out = json.loads(r['data']['result']) print(out['logs'], out['result'])

Returns

TypeDescription

string

data.result is JSON text: logs holds the lines written by Log() in the code, and result is the JSON text of the return value of main().

Arguments

NameTypeRequiredDescription

settings

object

Yes

Run configuration; fields are in the attributes table below.

Attributes

NameTypeDescription

settings.source

string

The code to run; its entry is main(), whose return value is the result.

settings.strategy

number

Without source, run the account's strategy with this ID (e.g. a trading plugin).

settings.node

number

ID of the docker that runs the code; omitted or -1 chooses one automatically.

settings.exchanges

array

Exchange object configuration, written as in "Robot configuration (settings)" in Extended API Interface Details.

Remarks

It uses the same execution mechanism as the "Debugging Tool" of the development tools and trading terminal plugins; see Plugin Principle and Development.

exchanges can also pass an exchange configuration directly instead of referencing an exchange account on the platform, e.g. {"eid": "Binance", "pair": "ETH_BTC", "meta": {"AccessKey": "...", "SecretKey": "..."}}; the field names of meta are given by the meta returned by GetExchangeList. Usually only one exchange object is set in exchanges (the debugging tool page supports only one); setting two raises no error, but accessing the second exchange object in the code does.

Example response
json
{ "code": 0, "data": { "result": "{\"logs\": [...], \"result\": \"\"}", "error": null } }

Parsed, result is:

json
{ "logs": [{ "PlatformId": "", "OrderId": "0", "LogType": 5, "Price": 0, "Amount": 0, "Extra": "Hello FMZ", "Currency": "", "Instrument": "", "Direction": "", "Time": 1732267473108 }], "result": "" }