Getting Started
Platform Basics
Writing Strategies
Development Tools
Backtesting System
Advanced Topics
Data and Research
Integrations
Signature Authentication
Request format
Send a POST request to https://www.fmz.com/api/v1 with the parameters as a form (application/x-www-form-urlencoded). The server also accepts the same parameters in the URL query string of a GET request, but then they end up in access logs along the way, so POST is recommended.
| Parameter | Description |
|---|---|
| version | Version, always 1.0. |
| access_key | The AccessKey of the API KEY. |
| method | Method name, e.g. GetNodeList. |
| args | Method parameters as a JSON string: an array in parameter order (e.g. [], [123, "ok"]), or an object keyed by parameter name (e.g. {"robotId": 123}), see Extended API Interface Details. Treated as [] when omitted. |
| nonce | Timestamp in milliseconds. It must be within 1 hour of server time and greater than the nonce of this API KEY's previous request. |
| sign | Signature, computed as described below. |
The request does not contain the SecretKey.
Signature
Concatenate the string below, where args is the exact JSON string being submitted:
plaintext
version + "|" + method + "|" + args + "|" + nonce + "|" + secretKey
Compute the MD5 of the result and use its 32-character lowercase hexadecimal form as sign.
Python example
python
import hashlib
import json
import time
import urllib.parse
import urllib.request
ACCESS_KEY = '' # AccessKey of the API KEY
SECRET_KEY = '' # SecretKey of the API KEY
def api(method, *args, **kwargs):
d = {
'version': '1.0',
'access_key': ACCESS_KEY,
'method': method,
# Positional arguments are sent as an array, keyword arguments as an object (by name)
'args': json.dumps(kwargs if kwargs else list(args)),
'nonce': int(time.time() * 1000),
}
s = '%s|%s|%s|%d|%s' % (d['version'], d['method'], d['args'], d['nonce'], SECRET_KEY)
d['sign'] = hashlib.md5(s.encode('utf-8')).hexdigest()
body = urllib.parse.urlencode(d).encode('utf-8')
with urllib.request.urlopen('https://www.fmz.com/api/v1', body, timeout=10) as resp:
return json.loads(resp.read().decode('utf-8'))
print(api('GetNodeList')) # Docker list
print(api('GetRobotList', appId='member2')) # By name: bots labeled member2
print(api('CommandRobot', 123, 'ok')) # Send an interactive command to bot 123
print(api('GetRobotDetail', 123)) # Details of bot 123
Go example
mylang
package main
import (
"crypto/md5"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"time"
)
const (
accessKey = "" // AccessKey of the API KEY
secretKey = "" // SecretKey of the API KEY
baseAPI = "https://www.fmz.com/api/v1"
)
var client = &http.Client{Timeout: 10 * time.Second}
func api(method string, args ...interface{}) (string, error) {
if args == nil {
args = []interface{}{}
}
b, err := json.Marshal(args)
if err != nil {
return "", err
}
nonce := strconv.FormatInt(time.Now().UnixMilli(), 10)
sum := md5.Sum([]byte("1.0|" + method + "|" + string(b) + "|" + nonce + "|" + secretKey))
form := url.Values{
"version": {"1.0"},
"access_key": {accessKey},
"method": {method},
"args": {string(b)},
"nonce": {nonce},
"sign": {hex.EncodeToString(sum[:])},
}
resp, err := client.PostForm(baseAPI, form)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
return string(body), err
}
func main() {
ret, err := api("GetNodeList")
fmt.Println(ret, err)
// Restart bot 123 with a new configuration; settings fields: see the bot configuration section in Extended API Interface Details
settings := map[string]interface{}{
"name": "hedge test",
"strategy": 456,
"period": 60,
"node": 789,
"exchanges": []interface{}{
map[string]interface{}{"pid": 1001, "pair": "BTC_USDT"},
},
}
ret, err = api("RestartRobot", 123, settings)
fmt.Println(ret, err)
}