All URIs are relative to https://api.gateio.ws/api/v4
Method | HTTP request | Description |
---|---|---|
listCurrencies | GET /spot/currencies | List all currencies' details |
getCurrency | GET /spot/currencies/{currency} | Get details of a specific currency |
listCurrencyPairs | GET /spot/currency_pairs | List all currency pairs supported |
getCurrencyPair | GET /spot/currency_pairs/{currency_pair} | Get details of a specifc currency pair |
listTickers | GET /spot/tickers | Retrieve ticker information |
listOrderBook | GET /spot/order_book | Retrieve order book |
listTrades | GET /spot/trades | Retrieve market trades |
listCandlesticks | GET /spot/candlesticks | Market candlesticks |
getFee | GET /spot/fee | Query user trading fee rates |
getBatchSpotFee | GET /spot/batch_fee | Query a batch of user trading fee rates |
listSpotAccounts | GET /spot/accounts | List spot accounts |
createBatchOrders | POST /spot/batch_orders | Create a batch of orders |
listAllOpenOrders | GET /spot/open_orders | List all open orders |
createCrossLiquidateOrder | POST /spot/cross_liquidate_orders | close position when cross-currency is disabled |
listOrders | GET /spot/orders | List orders |
createOrder | POST /spot/orders | Create an order |
cancelOrders | DELETE /spot/orders | Cancel all `open` orders in specified currency pair |
cancelBatchOrders | POST /spot/cancel_batch_orders | Cancel a batch of orders with an ID list |
getOrder | GET /spot/orders/{order_id} | Get a single order |
cancelOrder | DELETE /spot/orders/{order_id} | Cancel a single order |
amendOrder | PATCH /spot/orders/{order_id} | Amend an order |
listMyTrades | GET /spot/my_trades | List personal trading history |
getSystemTime | GET /spot/time | Get server current time |
countdownCancelAllSpot | POST /spot/countdown_cancel_all | Countdown cancel orders |
listSpotPriceTriggeredOrders | GET /spot/price_orders | Retrieve running auto order list |
createSpotPriceTriggeredOrder | POST /spot/price_orders | Create a price-triggered order |
cancelSpotPriceTriggeredOrderList | DELETE /spot/price_orders | Cancel all open orders |
getSpotPriceTriggeredOrder | GET /spot/price_orders/{order_id} | Get a price-triggered order |
cancelSpotPriceTriggeredOrder | DELETE /spot/price_orders/{order_id} | cancel a price-triggered order |
\GateApi\Model\Currency[] listCurrencies()
List all currencies' details
Currency has two forms: 1. Only currency name, e.g., BTC, USDT 2. <currency>_<chain>
, e.g., HT_ETH
The latter one occurs when one currency has multiple chains. Currency detail contains a chain
field whatever the form is. To retrieve all chains of one currency, you can use use all the details which has the name of the currency or name starting with <currency>_
.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
try {
$result = $apiInstance->listCurrencies();
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listCurrencies: ', $e->getMessage(), PHP_EOL;
}
?>
This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Currency getCurrency($currency)
Get details of a specific currency
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$currency = 'GT'; // string | Currency name
try {
$result = $apiInstance->getCurrency($currency);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->getCurrency: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Currency name |
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\CurrencyPair[] listCurrencyPairs()
List all currency pairs supported
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
try {
$result = $apiInstance->listCurrencyPairs();
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listCurrencyPairs: ', $e->getMessage(), PHP_EOL;
}
?>
This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\CurrencyPair getCurrencyPair($currency_pair)
Get details of a specifc currency pair
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$currency_pair = 'ETH_BTC'; // string | Currency pair
try {
$result = $apiInstance->getCurrencyPair($currency_pair);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->getCurrencyPair: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Currency pair |
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Ticker[] listTickers($currency_pair, $timezone)
Retrieve ticker information
Return only related data if currency_pair
is specified; otherwise return all of them
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$associate_array['currency_pair'] = 'BTC_USDT'; // string | Currency pair
$associate_array['timezone'] = 'utc0'; // string | Timezone
try {
$result = $apiInstance->listTickers($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listTickers: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Currency pair | [optional] |
timezone | string | Timezone | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\OrderBook listOrderBook($currency_pair, $interval, $limit, $with_id)
Retrieve order book
Order book will be sorted by price from high to low on bids; low to high on asks
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$associate_array['currency_pair'] = 'BTC_USDT'; // string | Currency pair
$associate_array['interval'] = '0'; // string | Order depth. 0 means no aggregation is applied. default to 0
$associate_array['limit'] = 10; // int | Maximum number of order depth data in asks or bids
$associate_array['with_id'] = false; // bool | Return order book ID
try {
$result = $apiInstance->listOrderBook($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listOrderBook: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Currency pair | |
interval | string | Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] |
limit | int | Maximum number of order depth data in asks or bids | [optional] [default to 10] |
with_id | bool | Return order book ID | [optional] [default to false] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Trade[] listTrades($currency_pair, $limit, $last_id, $reverse, $from, $to, $page)
Retrieve market trades
You can use from
and to
to query by time range, or use last_id
by scrolling page. The default behavior is by time range. Scrolling query using last_id
is not recommended any more. If last_id
is specified, time range query parameters will be ignored.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$associate_array['currency_pair'] = 'BTC_USDT'; // string | Currency pair
$associate_array['limit'] = 100; // int | Maximum number of records to be returned in a single list. Default: 100, Minimum: 1, Maximum: 1000
$associate_array['last_id'] = '12345'; // string | Specify list staring point using the `id` of last record in previous list-query results
$associate_array['reverse'] = false; // bool | Whether the id of records to be retrieved should be less than the last_id specified. Default to false. When `last_id` is specified. Set `reverse` to `true` to trace back trading history; `false` to retrieve latest tradings. No effect if `last_id` is not specified.
$associate_array['from'] = 1627706330; // int | Start timestamp of the query
$associate_array['to'] = 1635329650; // int | Time range ending, default to current time
$associate_array['page'] = 1; // int | Page number
try {
$result = $apiInstance->listTrades($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listTrades: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Currency pair | |
limit | int | Maximum number of records to be returned in a single list. Default: 100, Minimum: 1, Maximum: 1000 | [optional] [default to 100] |
last_id | string | Specify list staring point using the `id` of last record in previous list-query results | [optional] |
reverse | bool | Whether the id of records to be retrieved should be less than the last_id specified. Default to false. When `last_id` is specified. Set `reverse` to `true` to trace back trading history; `false` to retrieve latest tradings. No effect if `last_id` is not specified. | [optional] [default to false] |
from | int | Start timestamp of the query | [optional] |
to | int | Time range ending, default to current time | [optional] |
page | int | Page number | [optional] [default to 1] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
string[][] listCandlesticks($currency_pair, $limit, $from, $to, $interval)
Market candlesticks
Maximum of 1000 points can be returned in a query. Be sure not to exceed the limit when specifying from, to and interval
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$associate_array['currency_pair'] = 'BTC_USDT'; // string | Currency pair
$associate_array['limit'] = 100; // int | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
$associate_array['from'] = 1546905600; // int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
$associate_array['to'] = 1546935600; // int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
$associate_array['interval'] = '30m'; // string | Interval time between data points. Note that `30d` means 1 natual month, not 30 days
try {
$result = $apiInstance->listCandlesticks($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listCandlesticks: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Currency pair | |
limit | int | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] |
from | int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] |
to | int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] |
interval | string | Interval time between data points. Note that `30d` means 1 natual month, not 30 days | [optional] [default to '30m'] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\TradeFee getFee($currency_pair)
Query user trading fee rates
This API is deprecated in favour of new fee retrieving API /wallet/fee
.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$associate_array['currency_pair'] = 'BTC_USDT'; // string | Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs
try {
$result = $apiInstance->getFee($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->getFee: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs | [optional] |
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
map[string,\GateApi\Model\SpotFee] getBatchSpotFee($currency_pairs)
Query a batch of user trading fee rates
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$currency_pairs = 'BTC_USDT,ETH_USDT'; // string | A request can only query up to 50 currency pairs
try {
$result = $apiInstance->getBatchSpotFee($currency_pairs);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->getBatchSpotFee: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
currency_pairs | string | A request can only query up to 50 currency pairs |
map[string,\GateApi\Model\SpotFee]
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\SpotAccount[] listSpotAccounts($currency)
List spot accounts
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$associate_array['currency'] = 'BTC'; // string | Retrieve data of the specified currency
try {
$result = $apiInstance->listSpotAccounts($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listSpotAccounts: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Retrieve data of the specified currency | [optional] |
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\BatchOrder[] createBatchOrders($order)
Create a batch of orders
Batch orders requirements: 1. custom order field text
is required 2. At most 4 currency pairs, maximum 10 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. account
must be identical for all orders
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$order = array(new \GateApi\Model\Order()); // \GateApi\Model\Order[] |
try {
$result = $apiInstance->createBatchOrders($order);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->createBatchOrders: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
order | \GateApi\Model\Order[] |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\OpenOrders[] listAllOpenOrders($page, $limit, $account)
List all open orders
List open orders in all currency pairs. Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned. Spot and margin orders are returned by default. To list cross margin orders, account
must be set to cross_margin
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$associate_array['page'] = 1; // int | Page number
$associate_array['limit'] = 100; // int | Maximum number of records returned in one page in each currency pair
$associate_array['account'] = 'cross_margin'; // string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
try {
$result = $apiInstance->listAllOpenOrders($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listAllOpenOrders: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
page | int | Page number | [optional] [default to 1] |
limit | int | Maximum number of records returned in one page in each currency pair | [optional] [default to 100] |
account | string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Order createCrossLiquidateOrder($liquidate_order)
close position when cross-currency is disabled
Currently, only cross-margin accounts are supported to close position when cross currencies are disabled. Maximum buy quantity = (unpaid principal and interest - currency balance - the amount of the currency in the order book) / 0.998
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$liquidate_order = new \GateApi\Model\LiquidateOrder(); // \GateApi\Model\LiquidateOrder |
try {
$result = $apiInstance->createCrossLiquidateOrder($liquidate_order);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->createCrossLiquidateOrder: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
liquidate_order | \GateApi\Model\LiquidateOrder |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Order[] listOrders($currency_pair, $status, $page, $limit, $account, $from, $to, $side)
List orders
Spot and margin orders are returned by default. If cross margin orders are needed, account
must be set to cross_margin
When status
is open
, i.e., listing open orders, only pagination parameters page
and limit
are supported and limit
cannot be larger than 100. Query by side
and time range parameters from
and to
are not supported. When status
is finished
, i.e., listing finished orders, pagination parameters, time range parameters from
and to
, and side
parameters are all supported. Time range parameters are handled as order finish time.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$associate_array['currency_pair'] = 'BTC_USDT'; // string | Retrieve results with specified currency pair. It is required for open orders, but optional for finished ones.
$associate_array['status'] = 'open'; // string | List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled
$associate_array['page'] = 1; // int | Page number
$associate_array['limit'] = 100; // int | Maximum number of records to be returned. If `status` is `open`, maximum of `limit` is 100
$associate_array['account'] = 'cross_margin'; // string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
$associate_array['from'] = 1627706330; // int | Start timestamp of the query
$associate_array['to'] = 1635329650; // int | Time range ending, default to current time
$associate_array['side'] = 'sell'; // string | All bids or asks. Both included if not specified
try {
$result = $apiInstance->listOrders($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listOrders: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Retrieve results with specified currency pair. It is required for open orders, but optional for finished ones. | |
status | string | List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled | |
page | int | Page number | [optional] [default to 1] |
limit | int | Maximum number of records to be returned. If `status` is `open`, maximum of `limit` is 100 | [optional] [default to 100] |
account | string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
from | int | Start timestamp of the query | [optional] |
to | int | Time range ending, default to current time | [optional] |
side | string | All bids or asks. Both included if not specified | [optional] |
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Order createOrder($order)
Create an order
You can place orders with spot, margin or cross margin account through setting the account
field. It defaults to spot
, which means spot account is used to place orders. When margin account is used, i.e., account
is margin
, auto_borrow
field can be set to true
to enable the server to borrow the amount lacked using POST /margin/loans
when your account's balance is not enough. Whether margin orders' fill will be used to repay margin loans automatically is determined by the auto repayment setting in your margin account, which can be updated or queried using /margin/auto_repay
API. When cross margin account is used, i.e., account
is cross_margin
, auto_borrow
can also be enabled to achieve borrowing the insufficient amount automatically if cross account's balance is not enough. But it differs from margin account that automatic repayment is determined by order's auto_repay
field and only current order's fill will be used to repay cross margin loans. Automatic repayment will be triggered when the order is finished, i.e., its status is either cancelled
or closed
. Order status An order waiting to be filled is open
, and it stays open
until it is filled totally. If fully filled, order is finished and its status turns to closed
.If the order is cancelled before it is totally filled, whether or not partially filled, its status is cancelled
. Iceberg order iceberg
field can be used to set the amount shown. Set to -1
to hide the order completely. Note that the hidden part's fee will be charged using taker's fee rate.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$order = new \GateApi\Model\Order(); // \GateApi\Model\Order |
try {
$result = $apiInstance->createOrder($order);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->createOrder: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
order | \GateApi\Model\Order |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Order[] cancelOrders($currency_pair, $side, $account)
Cancel all open
orders in specified currency pair
If account
is not set, all open orders, including spot, margin and cross margin ones, will be cancelled. You can set account
to cancel only orders within the specified account
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$currency_pair = 'BTC_USDT'; // string | Currency pair
$side = 'sell'; // string | All bids or asks. Both included if not specified
$account = 'spot'; // string | Specify account type - classic account:Default to all account types being included - portfolio margin account:`cross_margin` only
try {
$result = $apiInstance->cancelOrders($currency_pair, $side, $account);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->cancelOrders: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Currency pair | |
side | string | All bids or asks. Both included if not specified | [optional] |
account | string | Specify account type - classic account:Default to all account types being included - portfolio margin account:`cross_margin` only | [optional] |
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\CancelOrderResult[] cancelBatchOrders($cancel_order)
Cancel a batch of orders with an ID list
Multiple currency pairs can be specified, but maximum 20 orders are allowed per request
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$cancel_order = array(new \GateApi\Model\CancelOrder()); // \GateApi\Model\CancelOrder[] |
try {
$result = $apiInstance->cancelBatchOrders($cancel_order);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->cancelBatchOrders: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
cancel_order | \GateApi\Model\CancelOrder[] |
\GateApi\Model\CancelOrderResult[]
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Order getOrder($order_id, $currency_pair, $account)
Get a single order
Spot and margin orders are queried by default. If cross margin orders are needed or portfolio margin account are used, account must be set to cross_margin.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$order_id = '12345'; // string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted.
$currency_pair = 'BTC_USDT'; // string | Currency pair
$account = 'cross_margin'; // string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
try {
$result = $apiInstance->getOrder($order_id, $currency_pair, $account);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->getOrder: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
order_id | string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. | |
currency_pair | string | Currency pair | |
account | string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Order cancelOrder($order_id, $currency_pair, $account)
Cancel a single order
Spot and margin orders are cancelled by default. If trying to cancel cross margin orders or portfolio margin account are used, account must be set to cross_margin
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$order_id = '12345'; // string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted.
$currency_pair = 'BTC_USDT'; // string | Currency pair
$account = 'cross_margin'; // string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
try {
$result = $apiInstance->cancelOrder($order_id, $currency_pair, $account);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->cancelOrder: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
order_id | string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. | |
currency_pair | string | Currency pair | |
account | string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Order amendOrder($order_id, $currency_pair, $order_patch, $account)
Amend an order
By default, the orders of spot and margin account are updated. If you need to modify orders of the cross-margin
account, you must specify account as cross_margin
. For portfolio margin account, only cross_margin
account is supported. Currently, only supports modification of price
or amount
fields. Regarding rate limiting: modify order and create order sharing rate limiting rules. Regarding matching priority: only modifying the amount does not affect the priority. If the price is modified, the priority will be adjusted to the last of the new price. Note: If the modified amount is less than the fill amount, the order will be cancelled.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$order_id = '12345'; // string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted.
$currency_pair = 'BTC_USDT'; // string | Currency pair
$order_patch = new \GateApi\Model\OrderPatch(); // \GateApi\Model\OrderPatch |
$account = 'cross_margin'; // string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
try {
$result = $apiInstance->amendOrder($order_id, $currency_pair, $order_patch, $account);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->amendOrder: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
order_id | string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. | |
currency_pair | string | Currency pair | |
order_patch | \GateApi\Model\OrderPatch | ||
account | string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\Trade[] listMyTrades($currency_pair, $limit, $page, $order_id, $account, $from, $to)
List personal trading history
Spot and margin trades are queried by default. If cross margin trades are needed, account
must be set to cross_margin
You can also set from
and(or) to
to query by time range. If you don't specify from
and/or to
parameters, only the last 7 days of data will be retured. The range of from
and to
is not alloed to exceed 30 days. Time range parameters are handled as order finish time.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$associate_array['currency_pair'] = 'BTC_USDT'; // string | Retrieve results with specified currency pair
$associate_array['limit'] = 100; // int | Maximum number of records to be returned in a single list
$associate_array['page'] = 1; // int | Page number
$associate_array['order_id'] = '12345'; // string | Filter trades with specified order ID. `currency_pair` is also required if this field is present
$associate_array['account'] = 'cross_margin'; // string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
$associate_array['from'] = 1627706330; // int | Start timestamp of the query
$associate_array['to'] = 1635329650; // int | Time range ending, default to current time
try {
$result = $apiInstance->listMyTrades($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listMyTrades: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
currency_pair | string | Retrieve results with specified currency pair | [optional] |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
page | int | Page number | [optional] [default to 1] |
order_id | string | Filter trades with specified order ID. `currency_pair` is also required if this field is present | [optional] |
account | string | Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
from | int | Start timestamp of the query | [optional] |
to | int | Time range ending, default to current time | [optional] |
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\SystemTime getSystemTime()
Get server current time
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
try {
$result = $apiInstance->getSystemTime();
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->getSystemTime: ', $e->getMessage(), PHP_EOL;
}
?>
This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\TriggerTime countdownCancelAllSpot($countdown_cancel_all_spot_task)
Countdown cancel orders
When the timeout set by the user is reached, if there is no cancel or set a new countdown, the related pending orders will be automatically cancelled. This endpoint can be called repeatedly to set a new countdown or cancel the countdown. For example, call this endpoint at 30s intervals, each countdowntimeout
is set to 30s. If this endpoint is not called again within 30 seconds, all pending orders on the specified market
will be automatically cancelled, if no market
is specified, all market pending orders will be cancelled. If the timeout
is set to 0 within 30 seconds, the countdown timer will expire and the cacnel function will be cancelled.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$countdown_cancel_all_spot_task = new \GateApi\Model\CountdownCancelAllSpotTask(); // \GateApi\Model\CountdownCancelAllSpotTask |
try {
$result = $apiInstance->countdownCancelAllSpot($countdown_cancel_all_spot_task);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->countdownCancelAllSpot: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
countdown_cancel_all_spot_task | \GateApi\Model\CountdownCancelAllSpotTask |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\SpotPriceTriggeredOrder[] listSpotPriceTriggeredOrders($status, $market, $account, $limit, $offset)
Retrieve running auto order list
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$associate_array['status'] = 'status_example'; // string | Only list the orders with this status
$associate_array['market'] = 'BTC_USDT'; // string | Currency pair
$associate_array['account'] = 'account_example'; // string | Trading account type. Portfolio margin account must set to `cross_margin`
$associate_array['limit'] = 100; // int | Maximum number of records to be returned in a single list
$associate_array['offset'] = 0; // int | List offset, starting from 0
try {
$result = $apiInstance->listSpotPriceTriggeredOrders($associate_array);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->listSpotPriceTriggeredOrders: ', $e->getMessage(), PHP_EOL;
}
?>
Note: the input parameter is an associative array with the keys listed as the parameter name below.
Name | Type | Description | Notes |
---|---|---|---|
status | string | Only list the orders with this status | |
market | string | Currency pair | [optional] |
account | string | Trading account type. Portfolio margin account must set to `cross_margin` | [optional] |
limit | int | Maximum number of records to be returned in a single list | [optional] [default to 100] |
offset | int | List offset, starting from 0 | [optional] [default to 0] |
\GateApi\Model\SpotPriceTriggeredOrder[]
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\TriggerOrderResponse createSpotPriceTriggeredOrder($spot_price_triggered_order)
Create a price-triggered order
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$spot_price_triggered_order = new \GateApi\Model\SpotPriceTriggeredOrder(); // \GateApi\Model\SpotPriceTriggeredOrder |
try {
$result = $apiInstance->createSpotPriceTriggeredOrder($spot_price_triggered_order);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->createSpotPriceTriggeredOrder: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
spot_price_triggered_order | \GateApi\Model\SpotPriceTriggeredOrder |
\GateApi\Model\TriggerOrderResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\SpotPriceTriggeredOrder[] cancelSpotPriceTriggeredOrderList($market, $account)
Cancel all open orders
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$market = 'BTC_USDT'; // string | Currency pair
$account = 'account_example'; // string | Trading account type. Portfolio margin account must set to `cross_margin`
try {
$result = $apiInstance->cancelSpotPriceTriggeredOrderList($market, $account);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->cancelSpotPriceTriggeredOrderList: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
market | string | Currency pair | [optional] |
account | string | Trading account type. Portfolio margin account must set to `cross_margin` | [optional] |
\GateApi\Model\SpotPriceTriggeredOrder[]
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\SpotPriceTriggeredOrder getSpotPriceTriggeredOrder($order_id)
Get a price-triggered order
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$order_id = 'order_id_example'; // string | Retrieve the data of the order with the specified ID
try {
$result = $apiInstance->getSpotPriceTriggeredOrder($order_id);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->getSpotPriceTriggeredOrder: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
order_id | string | Retrieve the data of the order with the specified ID |
\GateApi\Model\SpotPriceTriggeredOrder
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\GateApi\Model\SpotPriceTriggeredOrder cancelSpotPriceTriggeredOrder($order_id)
cancel a price-triggered order
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Gate APIv4 authorization: apiv4
$config = GateApi\Configuration::getDefaultConfiguration()->setKey('YOUR_API_KEY')->setSecret('YOUR_API_SECRET');
$apiInstance = new GateApi\Api\SpotApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$order_id = 'order_id_example'; // string | Retrieve the data of the order with the specified ID
try {
$result = $apiInstance->cancelSpotPriceTriggeredOrder($order_id);
print_r($result);
} catch (GateApi\GateApiException $e) {
echo "Gate API Exception: label: {$e->getLabel()}, message: {$e->getMessage()}" . PHP_EOL;
} catch (Exception $e) {
echo 'Exception when calling SpotApi->cancelSpotPriceTriggeredOrder: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
order_id | string | Retrieve the data of the order with the specified ID |
\GateApi\Model\SpotPriceTriggeredOrder
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]