Virtual order book
curl --request GET \
--url https://api.gains.trade/v1/{chain}/markets/{symbol}/bookimport requests
url = "https://api.gains.trade/v1/{chain}/markets/{symbol}/book"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.gains.trade/v1/{chain}/markets/{symbol}/book', 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}/markets/{symbol}/book",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.gains.trade/v1/{chain}/markets/{symbol}/book"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.gains.trade/v1/{chain}/markets/{symbol}/book")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gains.trade/v1/{chain}/markets/{symbol}/book")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"market": "BTC/USD",
"markPrice": "0.5",
"bids": [
{
"price": "0.5",
"size": "0.5",
"sizeUsd": "0.5",
"cumulativeUsd": "0.5"
}
],
"asks": [
{
"price": "0.5",
"size": "0.5",
"sizeUsd": "0.5",
"cumulativeUsd": "0.5"
}
],
"timestamp": 123
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}Markets
Virtual order book
Gains has no resting order book. Levels are derived from the on-chain depth bands: the size at each level is the liquidity available at that price impact.
GET
/
v1
/
{chain}
/
markets
/
{symbol}
/
book
Virtual order book
curl --request GET \
--url https://api.gains.trade/v1/{chain}/markets/{symbol}/bookimport requests
url = "https://api.gains.trade/v1/{chain}/markets/{symbol}/book"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.gains.trade/v1/{chain}/markets/{symbol}/book', 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}/markets/{symbol}/book",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.gains.trade/v1/{chain}/markets/{symbol}/book"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.gains.trade/v1/{chain}/markets/{symbol}/book")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gains.trade/v1/{chain}/markets/{symbol}/book")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"market": "BTC/USD",
"markPrice": "0.5",
"bids": [
{
"price": "0.5",
"size": "0.5",
"sizeUsd": "0.5",
"cumulativeUsd": "0.5"
}
],
"asks": [
{
"price": "0.5",
"size": "0.5",
"sizeUsd": "0.5",
"cumulativeUsd": "0.5"
}
],
"timestamp": 123
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}{
"code": "VALIDATION_ERROR",
"message": "<string>",
"details": {}
}Path Parameters
Available options:
arbitrum, base, polygon, megaeth, arbitrum-sepolia Example:
"arbitrum"
Market symbol. BTC-USD and BTC%2FUSD are both accepted.
Example:
"BTC-USD"
Query Parameters
Required range:
1 <= x <= 30Response
Bids and asks around the mark price
Gains market symbol, <base>/<quote>.
Pattern:
^[A-Z0-9.]{1,15}\/[A-Z0-9]{1,10}$Example:
"BTC/USD"
Decimal number encoded as a string to preserve precision.
Pattern:
^-?(?:0|[1-9]\d*)(?:\.\d+)?$Example:
"0.5"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
