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 |
ListSpotAccountBook | Get /spot/account_book | Query account book |
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 |
AmendBatchOrders | Post /spot/amend_batch_orders | Batch modification of orders |
GetSpotInsuranceHistory | Get /spot/insurance_history | Query spot insurance fund historical data |
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 |
[]Currency ListCurrencies(ctx, )
List all currencies' details
When a currency corresponds to multiple chains, you can query the information of multiple chains through the chains
field, such as the charging and recharge status, identification, etc. of the chain.
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
result, _, err := client.SpotApi.ListCurrencies(ctx)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Currency GetCurrency(ctx, currency)
Get details of a specific currency
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
currency | string | Currency name |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
currency := "GT" // string - Currency name
result, _, err := client.SpotApi.GetCurrency(ctx, currency)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]CurrencyPair ListCurrencyPairs(ctx, )
List all currency pairs supported
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
result, _, err := client.SpotApi.ListCurrencyPairs(ctx)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
CurrencyPair GetCurrencyPair(ctx, currencyPair)
Get details of a specifc currency pair
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
currencyPair | string | Currency pair |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
currencyPair := "ETH_BTC" // string - Currency pair
result, _, err := client.SpotApi.GetCurrencyPair(ctx, currencyPair)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]Ticker ListTickers(ctx, optional)
Retrieve ticker information
Return only related data if currency_pair
is specified; otherwise return all of them
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
optional | ListTickersOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListTickersOpts struct
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | optional.String | Currency pair | |
timezone | optional.String | Timezone |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
result, _, err := client.SpotApi.ListTickers(ctx, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
OrderBook ListOrderBook(ctx, currencyPair, optional)
Retrieve order book
Order book will be sorted by price from high to low on bids; low to high on asks
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
currencyPair | string | Currency pair | |
optional | ListOrderBookOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListOrderBookOpts struct
Name | Type | Description | Notes |
---|---|---|---|
interval | optional.String | Order depth. 0 means no aggregation is applied. default to 0 | [default to 0] |
limit | optional.Int32 | Maximum number of order depth data in asks or bids | [default to 10] |
withId | optional.Bool | Return order book ID | [default to false] |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
currencyPair := "BTC_USDT" // string - Currency pair
result, _, err := client.SpotApi.ListOrderBook(ctx, currencyPair, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]Trade ListTrades(ctx, currencyPair, optional)
Retrieve market trades
Supports from
and to
by time range query or page-turn query based on last_id
. By default, query by time range is the last 30 days. The query method based on last_id
page turn is no longer recommended. If last_id
is specified, the time range query parameters will be ignored. The maximum number of pages when searching data using limit&page paging function is 100,000, that is, limit * (page - 1) <= 100,000.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
currencyPair | string | Currency pair | |
optional | ListTradesOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListTradesOpts struct
Name | Type | Description | Notes |
---|---|---|---|
limit | optional.Int32 | Maximum number of records to be returned in a single list. Default: 100, Minimum: 1, Maximum: 1000 | [default to 100] |
lastId | optional.String | Specify list staring point using the `id` of last record in previous list-query results | |
reverse | optional.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. | [default to false] |
from | optional.Int64 | Start timestamp of the query | |
to | optional.Int64 | Time range ending, default to current time | |
page | optional.Int32 | Page number | [default to 1] |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
currencyPair := "BTC_USDT" // string - Currency pair
result, _, err := client.SpotApi.ListTrades(ctx, currencyPair, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
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(ctx, currencyPair, optional)
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
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
currencyPair | string | Currency pair | |
optional | ListCandlesticksOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListCandlesticksOpts struct
Name | Type | Description | Notes |
---|---|---|---|
limit | optional.Int32 | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [default to 100] |
from | optional.Int64 | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | |
to | optional.Int64 | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | |
interval | optional.String | Interval time between data points. Note that `30d` means 1 natual month, not 30 days | [default to 30m] |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
currencyPair := "BTC_USDT" // string - Currency pair
result, _, err := client.SpotApi.ListCandlesticks(ctx, currencyPair, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
SpotFee GetFee(ctx, optional)
Query user trading fee rates
This API is deprecated in favour of new fee retrieving API /wallet/fee
.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
optional | GetFeeOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a GetFeeOpts struct
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | optional.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 |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
result, _, err := client.SpotApi.GetFee(ctx, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
map[string]SpotFee GetBatchSpotFee(ctx, currencyPairs)
Query a batch of user trading fee rates
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
currencyPairs | string | A request can only query up to 50 currency pairs |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
currencyPairs := "BTC_USDT,ETH_USDT" // string - A request can only query up to 50 currency pairs
result, _, err := client.SpotApi.GetBatchSpotFee(ctx, currencyPairs)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]SpotAccount ListSpotAccounts(ctx, optional)
List spot accounts
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
optional | ListSpotAccountsOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListSpotAccountsOpts struct
Name | Type | Description | Notes |
---|---|---|---|
currency | optional.String | Retrieve data of the specified currency |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
result, _, err := client.SpotApi.ListSpotAccounts(ctx, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]SpotAccountBook ListSpotAccountBook(ctx, optional)
Query account book
Record query time range is not allowed to exceed 30 days. The maximum number of pages when searching data using limit&page paging function is 100,000, that is, limit * (page - 1) <= 100,000.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
optional | ListSpotAccountBookOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListSpotAccountBookOpts struct
Name | Type | Description | Notes |
---|---|---|---|
currency | optional.String | Retrieve data of the specified currency | |
from | optional.Int64 | Start timestamp of the query | |
to | optional.Int64 | Time range ending, default to current time | |
page | optional.Int32 | Page number | [default to 1] |
limit | optional.Int32 | Maximum number of records to be returned in a single list | [default to 100] |
type_ | optional.String | Only retrieve changes of the specified type. All types will be returned if not specified. |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
result, _, err := client.SpotApi.ListSpotAccountBook(ctx, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]BatchOrder CreateBatchOrders(ctx, order, optional)
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
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
order | []Order | ||
optional | CreateBatchOrdersOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a CreateBatchOrdersOpts struct
Name | Type | Description | Notes |
---|---|---|---|
xGateExptime | optional.Int64 | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
order := []gateapi.Order{gateapi.Order{}} // []Order -
result, _, err := client.SpotApi.CreateBatchOrders(ctx, order, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]OpenOrders ListAllOpenOrders(ctx, optional)
List all open orders
Query the current order list of all trading pairs. Please note that the paging parameter controls the number of pending orders in each trading pair. There is no paging control for the number of trading pairs. All trading pairs with pending orders will be returned.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
optional | ListAllOpenOrdersOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListAllOpenOrdersOpts struct
Name | Type | Description | Notes |
---|---|---|---|
page | optional.Int32 | Page number | [default to 1] |
limit | optional.Int32 | Maximum number of records returned in one page in each currency pair | [default to 100] |
account | optional.String | Specify query account. |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
result, _, err := client.SpotApi.ListAllOpenOrders(ctx, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Order CreateCrossLiquidateOrder(ctx, liquidateOrder)
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
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
liquidateOrder | LiquidateOrder |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
liquidateOrder := gateapi.LiquidateOrder{} // LiquidateOrder -
result, _, err := client.SpotApi.CreateCrossLiquidateOrder(ctx, liquidateOrder)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]Order ListOrders(ctx, currencyPair, status, optional)
List orders
Note that the query results are spot order lists for spot, unified account and warehouse-by-site leverage accounts by default. status
is set to open
, that is, when querying the pending order list, only pagination control of page
and limit
is supported. limit
Maximum setting is only allowed to 100 . The side
and from
, to
parameters for time range query are not supported. status
is set to finished
, that is, when querying historical delegations, in addition to pagination queries, from
and to
are also supported by time range queries. In addition, it supports setting the side
parameter to filter one-side history. The parameters of the time range filtering are processed according to the order end time.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
currencyPair | 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 | |
optional | ListOrdersOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListOrdersOpts struct
Name | Type | Description | Notes |
---|---|---|---|
page | optional.Int32 | Page number | [default to 1] |
limit | optional.Int32 | Maximum number of records to be returned. If `status` is `open`, maximum of `limit` is 100 | [default to 100] |
account | optional.String | Specify query account. | |
from | optional.Int64 | Start timestamp of the query | |
to | optional.Int64 | Time range ending, default to current time | |
side | optional.String | All bids or asks. Both included if not specified |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
currencyPair := "BTC_USDT" // string - Retrieve results with specified currency pair. It is required for open orders, but optional for finished ones.
status := "open" // string - List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled
result, _, err := client.SpotApi.ListOrders(ctx, currencyPair, status, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Order CreateOrder(ctx, order, optional)
Create an order
Support spot, margin, leverage, and full-position leverage orders. Use different accounts through the account
field, default is spot
, that is, use the spot account to place an order if the user is unified
account, default is to place an order with a unified account When using leveraged account trading, that is, when account
is set to margin
, you can set auto_borrow
to true
, In the case of insufficient account balance, the system will automatically execute the POST /margin/uni/loans
to borrow the insufficient part. Whether the assets obtained after the leveraged order is automatically used to return the borrowing orders of the leveraged account in a position-by-store leverage account depends on the automatic repayment settings of the user's position-by-store leverage account**, The account automatic repayment settings can be queried and set through /margin/auto_repay
. Use unified account transactions, that is, when account
is set to unified
, auto_borrow
" can also be enableTo realize the insufficient part of automatic borrowing, but unlike the leverage account, whether the entrustment of a unified account is automatically repayable depends on the when placing an orderauto_repay
setting, this setting is only effective for the current entrustment, that is, only the assets obtained after the entrustment transaction will be used to repay the borrowing orders of the full-position leverage account. Unified account ordering currently supports auto_borrow
and auto_repay
at the same time. Auto repayment will be triggered at the end of the order, i.e. status
is cancelled
or closed
. Delegation Status The entrustment status in the pending order is open
, which remains at open
until all the quantity is traded. If it is eaten, the order ends and the status becomes closed
. If the order is cancelled before all transactions are completed, regardless of whether there are partial transactions, the status will become cancelled
Iceberg Entrustment iceberg
is used to set the number of iceberg delegations displayed, and does not support complete hiding. Note that when hidden part of the transaction is charged according to the taker's handling rate. Restrict user transactions Set stp_act
to decide to use strategies that limit user transactions
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
order | Order | ||
optional | CreateOrderOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a CreateOrderOpts struct
Name | Type | Description | Notes |
---|---|---|---|
xGateExptime | optional.Int64 | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
order := gateapi.Order{} // Order -
result, _, err := client.SpotApi.CreateOrder(ctx, order, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]OrderCancel CancelOrders(ctx, optional)
Cancel all open
orders in specified currency pair
When the account
parameter is not specified, all pending orders including spot, unified account, and position-by-position leverage will be cancelled. When currency_pair
is not specified, all transaction pairs are revoked You can specify a certain account separately to cancel all orders under the specified account
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
optional | CancelOrdersOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a CancelOrdersOpts struct
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | optional.String | Currency pair | |
side | optional.String | All bids or asks. Both included if not specified | |
account | optional.String | Specify Account Type - Classic Account: If not specified, all include - Unified Account: Specify `unified` | |
actionMode | optional.String | Processing Mode When placing an order, different fields are returned based on the action_mode - ACK: Asynchronous mode, returns only key order fields - RESULT: No clearing information - FULL: Full mode (default) | |
xGateExptime | optional.Int64 | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
result, _, err := client.SpotApi.CancelOrders(ctx, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]CancelOrderResult CancelBatchOrders(ctx, cancelBatchOrder, optional)
Cancel a batch of orders with an ID list
Multiple currency pairs can be specified, but maximum 20 orders are allowed per request
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
cancelBatchOrder | []CancelBatchOrder | ||
optional | CancelBatchOrdersOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a CancelBatchOrdersOpts struct
Name | Type | Description | Notes |
---|---|---|---|
xGateExptime | optional.Int64 | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
cancelBatchOrder := []gateapi.CancelBatchOrder{gateapi.CancelBatchOrder{}} // []CancelBatchOrder -
result, _, err := client.SpotApi.CancelBatchOrders(ctx, cancelBatchOrder, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Order GetOrder(ctx, orderId, currencyPair, optional)
Get a single order
By default, orders for spot, unified account and warehouse-by-site leverage account are checked.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
orderId | string | The order ID returned when the order was successfully created or the custom ID specified by the user's creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel) | |
currencyPair | string | Specify the transaction pair to query. If you are querying pending order records, this field is required. If you are querying traded records, this field can be left blank. | |
optional | GetOrderOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a GetOrderOpts struct
Name | Type | Description | Notes |
---|---|---|---|
account | optional.String | Specify query account. |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
orderId := "12345" // string - The order ID returned when the order was successfully created or the custom ID specified by the user's creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel)
currencyPair := "BTC_USDT" // string - Specify the transaction pair to query. If you are querying pending order records, this field is required. If you are querying traded records, this field can be left blank.
result, _, err := client.SpotApi.GetOrder(ctx, orderId, currencyPair, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Order CancelOrder(ctx, orderId, currencyPair, optional)
Cancel a single order
By default, orders for spot, unified accounts and leveraged accounts are revoked.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
orderId | string | The order ID returned when the order was successfully created or the custom ID specified by the user's creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel) | |
currencyPair | string | Currency pair | |
optional | CancelOrderOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a CancelOrderOpts struct
Name | Type | Description | Notes |
---|---|---|---|
account | optional.String | Specify query account. | |
actionMode | optional.String | Processing Mode When placing an order, different fields are returned based on the action_mode - ACK: Asynchronous mode, returns only key order fields - RESULT: No clearing information - FULL: Full mode (default) | |
xGateExptime | optional.Int64 | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
orderId := "12345" // string - The order ID returned when the order was successfully created or the custom ID specified by the user's creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel)
currencyPair := "BTC_USDT" // string - Currency pair
result, _, err := client.SpotApi.CancelOrder(ctx, orderId, currencyPair, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Order AmendOrder(ctx, orderId, orderPatch, optional)
Amend an order
By default modify orders for spot, unified account and leverage account. At present, both the request body and query support currency_pair and account parameters, but the request body has higher priority currency_pair must be filled in the request body or query Currently, only the price or quantity modification (choose one of two) About speed limit: Modify orders and create orders to share speed limit rules About matching priority: Only modifying the quantity will become smaller and will not affect the priority of matching. If the price is modified or the quantity is modified, the priority will be adjusted to the end of the new price Precautions: Modification quantity is less than the transaction quantity will trigger the order cancellation operation
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
orderId | string | The order ID returned when the order was successfully created or the custom ID specified by the user's creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel) | |
orderPatch | OrderPatch | ||
optional | AmendOrderOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a AmendOrderOpts struct
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | optional.String | Currency pair | |
account | optional.String | Specify query account. | |
xGateExptime | optional.Int64 | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
orderId := "12345" // string - The order ID returned when the order was successfully created or the custom ID specified by the user's creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel)
orderPatch := gateapi.OrderPatch{} // OrderPatch -
result, _, err := client.SpotApi.AmendOrder(ctx, orderId, orderPatch, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]Trade ListMyTrades(ctx, optional)
List personal trading history
By default query of transaction records for spot, unified account and warehouse-by-site leverage accounts. The history within a specified time range can be queried by specifying from
or (and) to
. - If no time parameters are specified, only data for the last 7 days can be obtained. - If only any parameter of from
or to
is specified, only 7-day data from the start (or end) of the specified time is returned. - The range of from
and to
is not allowed to exceed 30 days. The parameters of the time range filter are processed according to the order end time. The maximum number of pages when searching data using limit&page paging function is 100,000, that is, limit * (page - 1) <= 100,000.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
optional | ListMyTradesOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListMyTradesOpts struct
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | optional.String | Retrieve results with specified currency pair | |
limit | optional.Int32 | Maximum number of records to be returned in a single list. Default: 100, Minimum: 1, Maximum: 1000 | [default to 100] |
page | optional.Int32 | Page number | [default to 1] |
orderId | optional.String | Filter trades with specified order ID. `currency_pair` is also required if this field is present | |
account | optional.String | Specify query account. | |
from | optional.Int64 | Start timestamp of the query | |
to | optional.Int64 | Time range ending, default to current time |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
result, _, err := client.SpotApi.ListMyTrades(ctx, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
SystemTime GetSystemTime(ctx, )
Get server current time
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
result, _, err := client.SpotApi.GetSystemTime(ctx)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
TriggerTime CountdownCancelAllSpot(ctx, countdownCancelAllSpotTask)
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.
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
countdownCancelAllSpotTask | CountdownCancelAllSpotTask |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
countdownCancelAllSpotTask := gateapi.CountdownCancelAllSpotTask{} // CountdownCancelAllSpotTask -
result, _, err := client.SpotApi.CountdownCancelAllSpot(ctx, countdownCancelAllSpotTask)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]BatchOrder AmendBatchOrders(ctx, batchAmendItem, optional)
Batch modification of orders
By default modify orders for spot, unified account and leverage account. Currently, only the price or quantity modification (choose one of two) Modify unfinished orders, up to 5 orders can be modified in batches at a time. The request parameters should be passed in array format. When the order modification fails during batch modification, the modification of the order will continue to be executed. After execution, the failure information of the corresponding order will be carried The order of calling the batch modification order is consistent with the order list The order of return content of batch modification orders is consistent with the order list
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
batchAmendItem | []BatchAmendItem | ||
optional | AmendBatchOrdersOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a AmendBatchOrdersOpts struct
Name | Type | Description | Notes |
---|---|---|---|
xGateExptime | optional.Int64 | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
batchAmendItem := []gateapi.BatchAmendItem{gateapi.BatchAmendItem{}} // []BatchAmendItem -
result, _, err := client.SpotApi.AmendBatchOrders(ctx, batchAmendItem, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]SpotInsuranceHistory GetSpotInsuranceHistory(ctx, business, currency, from, to, optional)
Query spot insurance fund historical data
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
business | string | Leverage business, margin - position by position; unified - unified account | |
currency | string | Currency | |
from | int64 | Start timestamp, seconds | |
to | int64 | End timestamp, in seconds | |
optional | GetSpotInsuranceHistoryOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a GetSpotInsuranceHistoryOpts struct
Name | Type | Description | Notes |
---|---|---|---|
page | optional.Int32 | Page number | [default to 1] |
limit | optional.Int32 | The maximum number of items returned in the list, the default value is 30 | [default to 30] |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.Background()
business := "margin" // string - Leverage business, margin - position by position; unified - unified account
currency := "BTC" // string - Currency
from := 1547706332 // int64 - Start timestamp, seconds
to := 1547706332 // int64 - End timestamp, in seconds
result, _, err := client.SpotApi.GetSpotInsuranceHistory(ctx, business, currency, from, to, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
No authorization required
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]SpotPriceTriggeredOrder ListSpotPriceTriggeredOrders(ctx, status, optional)
Retrieve running auto order list
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
status | string | Only list the orders with this status | |
optional | ListSpotPriceTriggeredOrdersOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a ListSpotPriceTriggeredOrdersOpts struct
Name | Type | Description | Notes |
---|---|---|---|
market | optional.String | Currency pair | |
account | optional.String | Trading account type. Portfolio margin account must set to `unified` | |
limit | optional.Int32 | Maximum number of records to be returned in a single list | [default to 100] |
offset | optional.Int32 | List offset, starting from 0 | [default to 0] |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
status := "status_example" // string - Only list the orders with this status
result, _, err := client.SpotApi.ListSpotPriceTriggeredOrders(ctx, status, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
TriggerOrderResponse CreateSpotPriceTriggeredOrder(ctx, spotPriceTriggeredOrder)
Create a price-triggered order
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
spotPriceTriggeredOrder | SpotPriceTriggeredOrder |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
spotPriceTriggeredOrder := gateapi.SpotPriceTriggeredOrder{} // SpotPriceTriggeredOrder -
result, _, err := client.SpotApi.CreateSpotPriceTriggeredOrder(ctx, spotPriceTriggeredOrder)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
[]SpotPriceTriggeredOrder CancelSpotPriceTriggeredOrderList(ctx, optional)
Cancel all open orders
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
optional | CancelSpotPriceTriggeredOrderListOpts | optional parameters | nil if no parameters |
Optional parameters are passed through a pointer to a CancelSpotPriceTriggeredOrderListOpts struct
Name | Type | Description | Notes |
---|---|---|---|
market | optional.String | Currency pair | |
account | optional.String | Trading account type. Portfolio margin account must set to `unified` |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
result, _, err := client.SpotApi.CancelSpotPriceTriggeredOrderList(ctx, nil)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
SpotPriceTriggeredOrder GetSpotPriceTriggeredOrder(ctx, orderId)
Get a price-triggered order
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
orderId | string | Retrieve the data of the order with the specified ID |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
orderId := "orderId_example" // string - Retrieve the data of the order with the specified ID
result, _, err := client.SpotApi.GetSpotPriceTriggeredOrder(ctx, orderId)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
SpotPriceTriggeredOrder CancelSpotPriceTriggeredOrder(ctx, orderId)
cancel a price-triggered order
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
orderId | string | Retrieve the data of the order with the specified ID |
package main
import (
"context"
"fmt"
"github.com/gateio/gateapi-go/v6"
)
func main() {
client := gateapi.NewAPIClient(gateapi.NewConfiguration())
// uncomment the next line if your are testing against testnet
// client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4")
ctx := context.WithValue(context.Background(),
gateapi.ContextGateAPIV4,
gateapi.GateAPIV4{
Key: "YOUR_API_KEY",
Secret: "YOUR_API_SECRET",
}
)
orderId := "orderId_example" // string - Retrieve the data of the order with the specified ID
result, _, err := client.SpotApi.CancelSpotPriceTriggeredOrder(ctx, orderId)
if err != nil {
if e, ok := err.(gateapi.GateAPIError); ok {
fmt.Printf("gate api error: %s\n", e.Error())
} else {
fmt.Printf("generic error: %s\n", err.Error())
}
} else {
fmt.Println(result)
}
}
- Content-Type: Not defined
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]