Categorygithub.com/gateio/gateapi-go/v5
package
5.20.2
Repository: https://github.com/gateio/gateapi-go.git
Documentation: pkg.go.dev

# README

Go API client for gateapi

Welcome to Gate.io API

APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 4.20.2
  • Package version: 5.20.2
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://www.gate.io/page/contacts

Versioning

Trying our best to follow the semantic versioning, while enjoying recent features provided by programming language and libraries, from 4.15.2, one major versioning difference will be introduced:

If extra code rewrite is required when you upgrade the SDK, such as:

  • some outdated programming language version support is dropped
  • API method signature has breaking changes.

the MAJOR version will be incremented, but the MINOR and PATCH version are still following REST API's instead of resetting to 0, so that you can recognize it has some breaking changes, but still getting the idea of from which REST API version the change is introduced.

For example, the previous REST API and SDK version are both 4.14.0. But if we decide to introduce some breaking changes in SDK along with REST API 4.15.2 upgrade, then the version of next SDK release will be 5.15.2(the MAJOR version is incremented to denote breaking changes, but the MINOR and PATCH version are identical to REST API's instead of resetting them to 0)

If MAJOR version is incremented, make sure you read the release note on Releases page

Installation

go get github.com/gateio/gateapi-go/v5

Getting Started

Please follow the installation instruction and execute the following Go code:

package main

import (
    "context"
    "fmt"

    "github.com/gateio/gateapi-go/v5"
)

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()
    settle := "usdt" // string - Settle currency
    
    result, _, err := client.DeliveryApi.ListDeliveryContracts(ctx, settle)
    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)
    }
}

For a more complete API usage example, refer to the demo application in example directory

Documentation for API Endpoints

All URIs are relative to https://api.gateio.ws/api/v4

ClassMethodHTTP requestDescription
DeliveryApiListDeliveryContractsGet /delivery/{settle}/contractsList all futures contracts
DeliveryApiGetDeliveryContractGet /delivery/{settle}/contracts/{contract}Get a single contract
DeliveryApiListDeliveryOrderBookGet /delivery/{settle}/order_bookFutures order book
DeliveryApiListDeliveryTradesGet /delivery/{settle}/tradesFutures trading history
DeliveryApiListDeliveryCandlesticksGet /delivery/{settle}/candlesticksGet futures candlesticks
DeliveryApiListDeliveryTickersGet /delivery/{settle}/tickersList futures tickers
DeliveryApiListDeliveryInsuranceLedgerGet /delivery/{settle}/insuranceFutures insurance balance history
DeliveryApiListDeliveryAccountsGet /delivery/{settle}/accountsQuery futures account
DeliveryApiListDeliveryAccountBookGet /delivery/{settle}/account_bookQuery account book
DeliveryApiListDeliveryPositionsGet /delivery/{settle}/positionsList all positions of a user
DeliveryApiGetDeliveryPositionGet /delivery/{settle}/positions/{contract}Get single position
DeliveryApiUpdateDeliveryPositionMarginPost /delivery/{settle}/positions/{contract}/marginUpdate position margin
DeliveryApiUpdateDeliveryPositionLeveragePost /delivery/{settle}/positions/{contract}/leverageUpdate position leverage
DeliveryApiUpdateDeliveryPositionRiskLimitPost /delivery/{settle}/positions/{contract}/risk_limitUpdate position risk limit
DeliveryApiListDeliveryOrdersGet /delivery/{settle}/ordersList futures orders
DeliveryApiCreateDeliveryOrderPost /delivery/{settle}/ordersCreate a futures order
DeliveryApiCancelDeliveryOrdersDelete /delivery/{settle}/ordersCancel all `open` orders matched
DeliveryApiGetDeliveryOrderGet /delivery/{settle}/orders/{order_id}Get a single order
DeliveryApiCancelDeliveryOrderDelete /delivery/{settle}/orders/{order_id}Cancel a single order
DeliveryApiGetMyDeliveryTradesGet /delivery/{settle}/my_tradesList personal trading history
DeliveryApiListDeliveryPositionCloseGet /delivery/{settle}/position_closeList position close history
DeliveryApiListDeliveryLiquidatesGet /delivery/{settle}/liquidatesList liquidation history
DeliveryApiListDeliverySettlementsGet /delivery/{settle}/settlementsList settlement history
DeliveryApiListPriceTriggeredDeliveryOrdersGet /delivery/{settle}/price_ordersList all auto orders
DeliveryApiCreatePriceTriggeredDeliveryOrderPost /delivery/{settle}/price_ordersCreate a price-triggered order
DeliveryApiCancelPriceTriggeredDeliveryOrderListDelete /delivery/{settle}/price_ordersCancel all open orders
DeliveryApiGetPriceTriggeredDeliveryOrderGet /delivery/{settle}/price_orders/{order_id}Get a single order
DeliveryApiCancelPriceTriggeredDeliveryOrderDelete /delivery/{settle}/price_orders/{order_id}Cancel a single order
FuturesApiListFuturesContractsGet /futures/{settle}/contractsList all futures contracts
FuturesApiGetFuturesContractGet /futures/{settle}/contracts/{contract}Get a single contract
FuturesApiListFuturesOrderBookGet /futures/{settle}/order_bookFutures order book
FuturesApiListFuturesTradesGet /futures/{settle}/tradesFutures trading history
FuturesApiListFuturesCandlesticksGet /futures/{settle}/candlesticksGet futures candlesticks
FuturesApiListFuturesTickersGet /futures/{settle}/tickersList futures tickers
FuturesApiListFuturesFundingRateHistoryGet /futures/{settle}/funding_rateFunding rate history
FuturesApiListFuturesInsuranceLedgerGet /futures/{settle}/insuranceFutures insurance balance history
FuturesApiListContractStatsGet /futures/{settle}/contract_statsFutures stats
FuturesApiListLiquidatedOrdersGet /futures/{settle}/liq_ordersRetrieve liquidation history
FuturesApiListFuturesAccountsGet /futures/{settle}/accountsQuery futures account
FuturesApiListFuturesAccountBookGet /futures/{settle}/account_bookQuery account book
FuturesApiListPositionsGet /futures/{settle}/positionsList all positions of a user
FuturesApiGetPositionGet /futures/{settle}/positions/{contract}Get single position
FuturesApiUpdatePositionMarginPost /futures/{settle}/positions/{contract}/marginUpdate position margin
FuturesApiUpdatePositionLeveragePost /futures/{settle}/positions/{contract}/leverageUpdate position leverage
FuturesApiUpdatePositionRiskLimitPost /futures/{settle}/positions/{contract}/risk_limitUpdate position risk limit
FuturesApiSetDualModePost /futures/{settle}/dual_modeEnable or disable dual mode
FuturesApiGetDualModePositionGet /futures/{settle}/dual_comp/positions/{contract}Retrieve position detail in dual mode
FuturesApiUpdateDualModePositionMarginPost /futures/{settle}/dual_comp/positions/{contract}/marginUpdate position margin in dual mode
FuturesApiUpdateDualModePositionLeveragePost /futures/{settle}/dual_comp/positions/{contract}/leverageUpdate position leverage in dual mode
FuturesApiUpdateDualModePositionRiskLimitPost /futures/{settle}/dual_comp/positions/{contract}/risk_limitUpdate position risk limit in dual mode
FuturesApiListFuturesOrdersGet /futures/{settle}/ordersList futures orders
FuturesApiCreateFuturesOrderPost /futures/{settle}/ordersCreate a futures order
FuturesApiCancelFuturesOrdersDelete /futures/{settle}/ordersCancel all `open` orders matched
FuturesApiGetFuturesOrderGet /futures/{settle}/orders/{order_id}Get a single order
FuturesApiCancelFuturesOrderDelete /futures/{settle}/orders/{order_id}Cancel a single order
FuturesApiGetMyTradesGet /futures/{settle}/my_tradesList personal trading history
FuturesApiListPositionCloseGet /futures/{settle}/position_closeList position close history
FuturesApiListLiquidatesGet /futures/{settle}/liquidatesList liquidation history
FuturesApiListPriceTriggeredOrdersGet /futures/{settle}/price_ordersList all auto orders
FuturesApiCreatePriceTriggeredOrderPost /futures/{settle}/price_ordersCreate a price-triggered order
FuturesApiCancelPriceTriggeredOrderListDelete /futures/{settle}/price_ordersCancel all open orders
FuturesApiGetPriceTriggeredOrderGet /futures/{settle}/price_orders/{order_id}Get a single order
FuturesApiCancelPriceTriggeredOrderDelete /futures/{settle}/price_orders/{order_id}Cancel a single order
MarginApiListMarginCurrencyPairsGet /margin/currency_pairsList all supported currency pairs supported in margin trading
MarginApiGetMarginCurrencyPairGet /margin/currency_pairs/{currency_pair}Query one single margin currency pair
MarginApiListFundingBookGet /margin/funding_bookOrder book of lending loans
MarginApiListMarginAccountsGet /margin/accountsMargin account list
MarginApiListMarginAccountBookGet /margin/account_bookList margin account balance change history
MarginApiListFundingAccountsGet /margin/funding_accountsFunding account list
MarginApiListLoansGet /margin/loansList all loans
MarginApiCreateLoanPost /margin/loansLend or borrow
MarginApiMergeLoansPost /margin/merged_loansMerge multiple lending loans
MarginApiGetLoanGet /margin/loans/{loan_id}Retrieve one single loan detail
MarginApiCancelLoanDelete /margin/loans/{loan_id}Cancel lending loan
MarginApiUpdateLoanPatch /margin/loans/{loan_id}Modify a loan
MarginApiListLoanRepaymentsGet /margin/loans/{loan_id}/repaymentList loan repayment records
MarginApiRepayLoanPost /margin/loans/{loan_id}/repaymentRepay a loan
MarginApiListLoanRecordsGet /margin/loan_recordsList repayment records of specified loan
MarginApiGetLoanRecordGet /margin/loan_records/{loan_record_id}Get one single loan record
MarginApiUpdateLoanRecordPatch /margin/loan_records/{loan_record_id}Modify a loan record
MarginApiGetAutoRepayStatusGet /margin/auto_repayRetrieve user auto repayment setting
MarginApiSetAutoRepayPost /margin/auto_repayUpdate user's auto repayment setting
SpotApiListCurrenciesGet /spot/currenciesList all currencies' detail
SpotApiGetCurrencyGet /spot/currencies/{currency}Get detail of one particular currency
SpotApiListCurrencyPairsGet /spot/currency_pairsList all currency pairs supported
SpotApiGetCurrencyPairGet /spot/currency_pairs/{currency_pair}Get detail of one single order
SpotApiListTickersGet /spot/tickersRetrieve ticker information
SpotApiListOrderBookGet /spot/order_bookRetrieve order book
SpotApiListTradesGet /spot/tradesRetrieve market trades
SpotApiListCandlesticksGet /spot/candlesticksMarket candlesticks
SpotApiGetFeeGet /spot/feeQuery user trading fee rates
SpotApiListSpotAccountsGet /spot/accountsList spot accounts
SpotApiCreateBatchOrdersPost /spot/batch_ordersCreate a batch of orders
SpotApiListAllOpenOrdersGet /spot/open_ordersList all open orders
SpotApiListOrdersGet /spot/ordersList orders
SpotApiCreateOrderPost /spot/ordersCreate an order
SpotApiCancelOrdersDelete /spot/ordersCancel all `open` orders in specified currency pair
SpotApiCancelBatchOrdersPost /spot/cancel_batch_ordersCancel a batch of orders with an ID list
SpotApiGetOrderGet /spot/orders/{order_id}Get a single order
SpotApiCancelOrderDelete /spot/orders/{order_id}Cancel a single order
SpotApiListMyTradesGet /spot/my_tradesList personal trading history
SpotApiListSpotPriceTriggeredOrdersGet /spot/price_ordersRetrieve running auto order list
SpotApiCreateSpotPriceTriggeredOrderPost /spot/price_ordersCreate a price-triggered order
SpotApiCancelSpotPriceTriggeredOrderListDelete /spot/price_ordersCancel all open orders
SpotApiGetSpotPriceTriggeredOrderGet /spot/price_orders/{order_id}Get a single order
SpotApiCancelSpotPriceTriggeredOrderDelete /spot/price_orders/{order_id}Cancel a single order
WalletApiGetDepositAddressGet /wallet/deposit_addressGenerate currency deposit address
WalletApiListWithdrawalsGet /wallet/withdrawalsRetrieve withdrawal records
WalletApiListDepositsGet /wallet/depositsRetrieve deposit records
WalletApiTransferPost /wallet/transfersTransfer between trading accounts
WalletApiListSubAccountTransfersGet /wallet/sub_account_transfersTransfer records between main and sub accounts
WalletApiTransferWithSubAccountPost /wallet/sub_account_transfersTransfer between main and sub accounts
WalletApiListWithdrawStatusGet /wallet/withdraw_statusRetrieve withdrawal status
WalletApiListSubAccountBalancesGet /wallet/sub_account_balancesRetrieve sub account balances
WalletApiGetTradeFeeGet /wallet/feeRetrieve personal trading fee
WithdrawalApiWithdrawPost /withdrawalsWithdraw

Documentation For Models

Documentation For Authorization

apiv4

  • Type: Gate APIv4

Example

ctx := context.WithValue(context.Background(), gateapi.ContextAPIKey, gateapi.GateAPIV4{
    Key:    "YOUR_API_KEY",
    Secret: "YOUR_API_SECRET",
})
r, err := client.Service.Operation(ctx, args)

Author

[email protected]