API Reference
Because the API Server is private, we will need to acknowledge that the request is from you, this is done by attaching the API Key and a custom signature to your request headers. Take a look at Authorization and Headers for more information.
Headers
The following HTTP headers must be present else requests will be rejected.
X-CYBOTRADE-TIMESTAMP
- Current timestamp in milliseconds.X-CYBOTRADE-API-KEY
- API Key.X-CYBOTRADE-SIGN
- The signature derived from parameters.
Authorization
To generate a signature for X-CYBOTRADE-SIGN
, follow the steps outlined below:
- Make a string of API_KEY + TIMESTAMP + JSON_BODY_STRING.
- Use HMAC_SHA256 algorithm to sign the string you got from step 1 using your API Secret.
- Encode the signature as a hex string (HMAC_SHA256).
Note that the timestamp
here must be equal to the timestamp given in X-CYBOTRADE-TIMESTAMP
.
Below is a code snippet in Python on how you can achieve it.
import hmac
import hashlib
import time
import json
def generate_signature(api_key: str, api_secret: str, timestamp: int, payload: dict) -> str:
params_str = f"{api_key}{timestamp}{json.dumps(payload)}"
hash = hmac.new(
bytes(api_secret, "utf-8"),
params_str.encode("utf-8"),
hashlib.sha256,
).hexdigest()
return hash
print(f"signature = {generate_signature("XXXX", "XXXX", int(time.time() * 10 ** 3), {"side": "buy"})}")
Endpoints
Trade signals
This endpoint forwards a trade signal to all the followers.
Order ID, this is not unique. This is for associating the order to a trade, see below for more information.
Order side, only 'buy' and 'sell' are valid.
The quantity of the order, will use the order size configured on Cybotrade if not given.
Indicate whether the signal sent successfully.