Update a resting limit or stop order
curl --request PATCH \
--url https://api.gains.trade/v1/{chain}/orders/{id} \
--header 'Content-Type: application/json' \
--header 'X-Gains-Signature: <api-key>' \
--data '
{
"price": "0.5",
"size": "0.5",
"sl": "0.5",
"tp": "0.5",
"slippage": "0.5"
}
'import requests
url = "https://api.gains.trade/v1/{chain}/orders/{id}"
payload = {
"price": "0.5",
"size": "0.5",
"sl": "0.5",
"tp": "0.5",
"slippage": "0.5"
}
headers = {
"X-Gains-Signature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-Gains-Signature': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({price: '0.5', size: '0.5', sl: '0.5', tp: '0.5', slippage: '0.5'})
};
fetch('https://api.gains.trade/v1/{chain}/orders/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gains.trade/v1/{chain}/orders/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'price' => '0.5',
'size' => '0.5',
'sl' => '0.5',
'tp' => '0.5',
'slippage' => '0.5'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Gains-Signature: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gains.trade/v1/{chain}/orders/{id}"
payload := strings.NewReader("{\n \"price\": \"0.5\",\n \"size\": \"0.5\",\n \"sl\": \"0.5\",\n \"tp\": \"0.5\",\n \"slippage\": \"0.5\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-Gains-Signature", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.gains.trade/v1/{chain}/orders/{id}")
.header("X-Gains-Signature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"price\": \"0.5\",\n \"size\": \"0.5\",\n \"sl\": \"0.5\",\n \"tp\": \"0.5\",\n \"slippage\": \"0.5\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gains.trade/v1/{chain}/orders/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-Gains-Signature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"price\": \"0.5\",\n \"size\": \"0.5\",\n \"sl\": \"0.5\",\n \"tp\": \"0.5\",\n \"slippage\": \"0.5\"\n}"
response = http.request(request)
puts response.read_body{
"order": {
"id": "5316911983139663",
"trader": "0x73b3A111C5BCCf9086c97B96e0AbAad69Dc4f523",
"market": "BTC/USD",
"side": "long",
"type": "market",
"size": "0.5",
"price": "0.5",
"leverage": "0.5",
"collateral": "<string>",
"sl": "0.5",
"tp": "0.5",
"reduceOnly": true,
"slippage": "0.5",
"clientId": "<string>",
"status": "prepared",
"txHash": "0xabc123",
"expiresAt": 123,
"fill": {
"price": "0.5",
"size": "0.5",
"collateral": "0.5",
"feeCollateral": "0.5",
"txHash": "0xabc123",
"timestamp": 123,
"positionId": "5316911983139663"
},
"reason": "NONE",
"createdAt": 123,
"updatedAt": 123
},
"transaction": {
"to": "0x73b3A111C5BCCf9086c97B96e0AbAad69Dc4f523",
"data": "0xabc123",
"value": "0",
"chainId": 123,
"gas": "<string>",
"expiresAt": 123
}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}Orders
Update a resting limit or stop order
PATCH
/
v1
/
{chain}
/
orders
/
{id}
Update a resting limit or stop order
curl --request PATCH \
--url https://api.gains.trade/v1/{chain}/orders/{id} \
--header 'Content-Type: application/json' \
--header 'X-Gains-Signature: <api-key>' \
--data '
{
"price": "0.5",
"size": "0.5",
"sl": "0.5",
"tp": "0.5",
"slippage": "0.5"
}
'import requests
url = "https://api.gains.trade/v1/{chain}/orders/{id}"
payload = {
"price": "0.5",
"size": "0.5",
"sl": "0.5",
"tp": "0.5",
"slippage": "0.5"
}
headers = {
"X-Gains-Signature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-Gains-Signature': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({price: '0.5', size: '0.5', sl: '0.5', tp: '0.5', slippage: '0.5'})
};
fetch('https://api.gains.trade/v1/{chain}/orders/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gains.trade/v1/{chain}/orders/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'price' => '0.5',
'size' => '0.5',
'sl' => '0.5',
'tp' => '0.5',
'slippage' => '0.5'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Gains-Signature: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gains.trade/v1/{chain}/orders/{id}"
payload := strings.NewReader("{\n \"price\": \"0.5\",\n \"size\": \"0.5\",\n \"sl\": \"0.5\",\n \"tp\": \"0.5\",\n \"slippage\": \"0.5\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-Gains-Signature", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.gains.trade/v1/{chain}/orders/{id}")
.header("X-Gains-Signature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"price\": \"0.5\",\n \"size\": \"0.5\",\n \"sl\": \"0.5\",\n \"tp\": \"0.5\",\n \"slippage\": \"0.5\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gains.trade/v1/{chain}/orders/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-Gains-Signature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"price\": \"0.5\",\n \"size\": \"0.5\",\n \"sl\": \"0.5\",\n \"tp\": \"0.5\",\n \"slippage\": \"0.5\"\n}"
response = http.request(request)
puts response.read_body{
"order": {
"id": "5316911983139663",
"trader": "0x73b3A111C5BCCf9086c97B96e0AbAad69Dc4f523",
"market": "BTC/USD",
"side": "long",
"type": "market",
"size": "0.5",
"price": "0.5",
"leverage": "0.5",
"collateral": "<string>",
"sl": "0.5",
"tp": "0.5",
"reduceOnly": true,
"slippage": "0.5",
"clientId": "<string>",
"status": "prepared",
"txHash": "0xabc123",
"expiresAt": 123,
"fill": {
"price": "0.5",
"size": "0.5",
"collateral": "0.5",
"feeCollateral": "0.5",
"txHash": "0xabc123",
"timestamp": 123,
"positionId": "5316911983139663"
},
"reason": "NONE",
"createdAt": 123,
"updatedAt": 123
},
"transaction": {
"to": "0x73b3A111C5BCCf9086c97B96e0AbAad69Dc4f523",
"data": "0xabc123",
"value": "0",
"chainId": 123,
"gas": "<string>",
"expiresAt": 123
}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}Authorizations
EIP-712 signature by an authorised agent over {method, path, body, timestamp, nonce}, sent with X-Gains-Agent, X-Gains-Timestamp and X-Gains-Nonce.
Path Parameters
Available options:
arbitrum, base, polygon, megaeth, arbitrum-sepolia Example:
"arbitrum"
Example:
"5316911983139663"
Body
application/json
Fields to change
Decimal number encoded as a string to preserve precision.
Pattern:
^-?(?:0|[1-9]\d*)(?:\.\d+)?$Example:
"0.5"
Decimal number encoded as a string to preserve precision.
Pattern:
^-?(?:0|[1-9]\d*)(?:\.\d+)?$Example:
"0.5"
Decimal number encoded as a string to preserve precision.
Pattern:
^-?(?:0|[1-9]\d*)(?:\.\d+)?$Example:
"0.5"
Decimal number encoded as a string to preserve precision.
Pattern:
^-?(?:0|[1-9]\d*)(?:\.\d+)?$Example:
"0.5"
Decimal number encoded as a string to preserve precision.
Pattern:
^-?(?:0|[1-9]\d*)(?:\.\d+)?$Example:
"0.5"
