Io.Gate.GateApi - the C# library for the Gate API v4

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.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 4.23.3
  • SDK version: 4.23.3
  • Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen For more information, please visit https://www.gate.io/page/contacts

Frameworks supported

  • .NET Core >=1.0
  • .NET Framework >=4.6
  • Mono/Xamarin >=vNext

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742

Installation

Install-Package Io.Gate.GateApi

Use the namespaces like this:

using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using Io.Gate.GateApi.Api;
using Io.Gate.GateApi.Client;
using Io.Gate.GateApi.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://api.gateio.ws/api/v4";
            var apiInstance = new DeliveryApi(config);
            var settle = "usdt";  // string | Settle currency

            try
            {
                // List all futures contracts
                List<DeliveryContract> result = apiInstance.ListDeliveryContracts(settle);
                Debug.WriteLine(result);
            }
            catch (GateApiException e)
            {
                Debug.Print("Exception when calling DeliveryApi.ListDeliveryContracts: " + e.Message);
                Debug.Print("Exception label: {0}, message: {1}", e.ErrorLabel, e.ErrorMessage);
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

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

Class Method HTTP request Description
DeliveryApi ListDeliveryContracts GET /delivery/{settle}/contracts List all futures contracts
DeliveryApi GetDeliveryContract GET /delivery/{settle}/contracts/{contract} Get a single contract
DeliveryApi ListDeliveryOrderBook GET /delivery/{settle}/order_book Futures order book
DeliveryApi ListDeliveryTrades GET /delivery/{settle}/trades Futures trading history
DeliveryApi ListDeliveryCandlesticks GET /delivery/{settle}/candlesticks Get futures candlesticks
DeliveryApi ListDeliveryTickers GET /delivery/{settle}/tickers List futures tickers
DeliveryApi ListDeliveryInsuranceLedger GET /delivery/{settle}/insurance Futures insurance balance history
DeliveryApi ListDeliveryAccounts GET /delivery/{settle}/accounts Query futures account
DeliveryApi ListDeliveryAccountBook GET /delivery/{settle}/account_book Query account book
DeliveryApi ListDeliveryPositions GET /delivery/{settle}/positions List all positions of a user
DeliveryApi GetDeliveryPosition GET /delivery/{settle}/positions/{contract} Get single position
DeliveryApi UpdateDeliveryPositionMargin POST /delivery/{settle}/positions/{contract}/margin Update position margin
DeliveryApi UpdateDeliveryPositionLeverage POST /delivery/{settle}/positions/{contract}/leverage Update position leverage
DeliveryApi UpdateDeliveryPositionRiskLimit POST /delivery/{settle}/positions/{contract}/risk_limit Update position risk limit
DeliveryApi ListDeliveryOrders GET /delivery/{settle}/orders List futures orders
DeliveryApi CreateDeliveryOrder POST /delivery/{settle}/orders Create a futures order
DeliveryApi CancelDeliveryOrders DELETE /delivery/{settle}/orders Cancel all open orders matched
DeliveryApi GetDeliveryOrder GET /delivery/{settle}/orders/{order_id} Get a single order
DeliveryApi CancelDeliveryOrder DELETE /delivery/{settle}/orders/{order_id} Cancel a single order
DeliveryApi GetMyDeliveryTrades GET /delivery/{settle}/my_trades List personal trading history
DeliveryApi ListDeliveryPositionClose GET /delivery/{settle}/position_close List position close history
DeliveryApi ListDeliveryLiquidates GET /delivery/{settle}/liquidates List liquidation history
DeliveryApi ListDeliverySettlements GET /delivery/{settle}/settlements List settlement history
DeliveryApi ListPriceTriggeredDeliveryOrders GET /delivery/{settle}/price_orders List all auto orders
DeliveryApi CreatePriceTriggeredDeliveryOrder POST /delivery/{settle}/price_orders Create a price-triggered order
DeliveryApi CancelPriceTriggeredDeliveryOrderList DELETE /delivery/{settle}/price_orders Cancel all open orders
DeliveryApi GetPriceTriggeredDeliveryOrder GET /delivery/{settle}/price_orders/{order_id} Get a single order
DeliveryApi CancelPriceTriggeredDeliveryOrder DELETE /delivery/{settle}/price_orders/{order_id} Cancel a single order
FuturesApi ListFuturesContracts GET /futures/{settle}/contracts List all futures contracts
FuturesApi GetFuturesContract GET /futures/{settle}/contracts/{contract} Get a single contract
FuturesApi ListFuturesOrderBook GET /futures/{settle}/order_book Futures order book
FuturesApi ListFuturesTrades GET /futures/{settle}/trades Futures trading history
FuturesApi ListFuturesCandlesticks GET /futures/{settle}/candlesticks Get futures candlesticks
FuturesApi ListFuturesTickers GET /futures/{settle}/tickers List futures tickers
FuturesApi ListFuturesFundingRateHistory GET /futures/{settle}/funding_rate Funding rate history
FuturesApi ListFuturesInsuranceLedger GET /futures/{settle}/insurance Futures insurance balance history
FuturesApi ListContractStats GET /futures/{settle}/contract_stats Futures stats
FuturesApi ListLiquidatedOrders GET /futures/{settle}/liq_orders Retrieve liquidation history
FuturesApi ListFuturesAccounts GET /futures/{settle}/accounts Query futures account
FuturesApi ListFuturesAccountBook GET /futures/{settle}/account_book Query account book
FuturesApi ListPositions GET /futures/{settle}/positions List all positions of a user
FuturesApi GetPosition GET /futures/{settle}/positions/{contract} Get single position
FuturesApi UpdatePositionMargin POST /futures/{settle}/positions/{contract}/margin Update position margin
FuturesApi UpdatePositionLeverage POST /futures/{settle}/positions/{contract}/leverage Update position leverage
FuturesApi UpdatePositionRiskLimit POST /futures/{settle}/positions/{contract}/risk_limit Update position risk limit
FuturesApi SetDualMode POST /futures/{settle}/dual_mode Enable or disable dual mode
FuturesApi GetDualModePosition GET /futures/{settle}/dual_comp/positions/{contract} Retrieve position detail in dual mode
FuturesApi UpdateDualModePositionMargin POST /futures/{settle}/dual_comp/positions/{contract}/margin Update position margin in dual mode
FuturesApi UpdateDualModePositionLeverage POST /futures/{settle}/dual_comp/positions/{contract}/leverage Update position leverage in dual mode
FuturesApi UpdateDualModePositionRiskLimit POST /futures/{settle}/dual_comp/positions/{contract}/risk_limit Update position risk limit in dual mode
FuturesApi ListFuturesOrders GET /futures/{settle}/orders List futures orders
FuturesApi CreateFuturesOrder POST /futures/{settle}/orders Create a futures order
FuturesApi CancelFuturesOrders DELETE /futures/{settle}/orders Cancel all open orders matched
FuturesApi GetFuturesOrder GET /futures/{settle}/orders/{order_id} Get a single order
FuturesApi CancelFuturesOrder DELETE /futures/{settle}/orders/{order_id} Cancel a single order
FuturesApi GetMyTrades GET /futures/{settle}/my_trades List personal trading history
FuturesApi ListPositionClose GET /futures/{settle}/position_close List position close history
FuturesApi ListLiquidates GET /futures/{settle}/liquidates List liquidation history
FuturesApi ListPriceTriggeredOrders GET /futures/{settle}/price_orders List all auto orders
FuturesApi CreatePriceTriggeredOrder POST /futures/{settle}/price_orders Create a price-triggered order
FuturesApi CancelPriceTriggeredOrderList DELETE /futures/{settle}/price_orders Cancel all open orders
FuturesApi GetPriceTriggeredOrder GET /futures/{settle}/price_orders/{order_id} Get a single order
FuturesApi CancelPriceTriggeredOrder DELETE /futures/{settle}/price_orders/{order_id} Cancel a single order
MarginApi ListMarginCurrencyPairs GET /margin/currency_pairs List all supported currency pairs supported in margin trading
MarginApi GetMarginCurrencyPair GET /margin/currency_pairs/{currency_pair} Query one single margin currency pair
MarginApi ListFundingBook GET /margin/funding_book Order book of lending loans
MarginApi ListMarginAccounts GET /margin/accounts Margin account list
MarginApi ListMarginAccountBook GET /margin/account_book List margin account balance change history
MarginApi ListFundingAccounts GET /margin/funding_accounts Funding account list
MarginApi ListLoans GET /margin/loans List all loans
MarginApi CreateLoan POST /margin/loans Lend or borrow
MarginApi MergeLoans POST /margin/merged_loans Merge multiple lending loans
MarginApi GetLoan GET /margin/loans/{loan_id} Retrieve one single loan detail
MarginApi CancelLoan DELETE /margin/loans/{loan_id} Cancel lending loan
MarginApi UpdateLoan PATCH /margin/loans/{loan_id} Modify a loan
MarginApi ListLoanRepayments GET /margin/loans/{loan_id}/repayment List loan repayment records
MarginApi RepayLoan POST /margin/loans/{loan_id}/repayment Repay a loan
MarginApi ListLoanRecords GET /margin/loan_records List repayment records of a specific loan
MarginApi GetLoanRecord GET /margin/loan_records/{loan_record_id} Get one single loan record
MarginApi UpdateLoanRecord PATCH /margin/loan_records/{loan_record_id} Modify a loan record
MarginApi GetAutoRepayStatus GET /margin/auto_repay Retrieve user auto repayment setting
MarginApi SetAutoRepay POST /margin/auto_repay Update user's auto repayment setting
MarginApi GetMarginTransferable GET /margin/transferable Get the max transferable amount for a specific margin currency
MarginApi GetMarginBorrowable GET /margin/borrowable Get the max borrowable amount for a specific margin currency
MarginApi ListCrossMarginCurrencies GET /margin/cross/currencies Currencies supported by cross margin.
MarginApi GetCrossMarginCurrency GET /margin/cross/currencies/{currency} Retrieve detail of one single currency supported by cross margin
MarginApi GetCrossMarginAccount GET /margin/cross/accounts Retrieve cross margin account
MarginApi ListCrossMarginAccountBook GET /margin/cross/account_book Retrieve cross margin account change history
MarginApi ListCrossMarginLoans GET /margin/cross/loans List cross margin borrow history
MarginApi CreateCrossMarginLoan POST /margin/cross/loans Create a cross margin borrow loan
MarginApi GetCrossMarginLoan GET /margin/cross/loans/{loan_id} Retrieve single borrow loan detail
MarginApi ListCrossMarginRepayments GET /margin/cross/repayments Retrieve cross margin repayments
MarginApi RepayCrossMarginLoan POST /margin/cross/repayments Repay cross margin loan
MarginApi GetCrossMarginTransferable GET /margin/cross/transferable Get the max transferable amount for a specific cross margin currency
MarginApi GetCrossMarginBorrowable GET /margin/cross/borrowable Get the max borrowable amount for a specific cross margin currency
OptionsApi ListOptionsUnderlyings GET /options/underlyings List all underlyings
OptionsApi ListOptionsExpirations GET /options/expirations List all expiration times
OptionsApi ListOptionsContracts GET /options/contracts List all the contracts with specified underlying and expiration time
OptionsApi GetOptionsContract GET /options/contracts/{contract} Query specified contract detail
OptionsApi ListOptionsSettlements GET /options/settlements List settlement history
OptionsApi GetOptionsSettlement GET /options/settlements/{contract} Get specified contract's settlement
OptionsApi ListOptionsOrderBook GET /options/order_book Futures order book
OptionsApi ListOptionsTickers GET /options/tickers List tickers of options contracts
OptionsApi ListOptionsUnderlyingTickers GET /options/underlying/tickers/{underlying} Get underlying ticker
OptionsApi ListOptionsCandlesticks GET /options/candlesticks Get futures candlesticks
OptionsApi ListOptionsUnderlyingCandlesticks GET /options/underlying/candlesticks Mark price candlesticks of an underlying
OptionsApi ListOptionsTrades GET /options/trades Options trade history
OptionsApi ListOptionsAccount GET /options/accounts List options account
OptionsApi ListOptionsAccountBook GET /options/account_book List account changing history
OptionsApi ListOptionsPositions GET /options/positions List user's positions of specified underlying
OptionsApi GetOptionsPosition GET /options/positions/{contract} Get specified contract position
OptionsApi ListOptionsPositionClose GET /options/position_close List user's liquidation history of specified underlying
OptionsApi ListOptionsOrders GET /options/orders List futures orders
OptionsApi CreateOptionsOrder POST /options/orders Create an options order
OptionsApi CancelOptionsOrders DELETE /options/orders Cancel all open orders matched
OptionsApi GetOptionsOrder GET /options/orders/{order_id} Get a single order
OptionsApi CancelOptionsOrder DELETE /options/orders/{order_id} Cancel a single order
OptionsApi ListMyOptionsTrades GET /options/my_trades List personal trading history
SpotApi ListCurrencies GET /spot/currencies List all currencies' details
SpotApi GetCurrency GET /spot/currencies/{currency} Get details of a specific currency
SpotApi ListCurrencyPairs GET /spot/currency_pairs List all currency pairs supported
SpotApi GetCurrencyPair GET /spot/currency_pairs/{currency_pair} Get details of a specifc order
SpotApi ListTickers GET /spot/tickers Retrieve ticker information
SpotApi ListOrderBook GET /spot/order_book Retrieve order book
SpotApi ListTrades GET /spot/trades Retrieve market trades
SpotApi ListCandlesticks GET /spot/candlesticks Market candlesticks
SpotApi GetFee GET /spot/fee Query user trading fee rates
SpotApi ListSpotAccounts GET /spot/accounts List spot accounts
SpotApi CreateBatchOrders POST /spot/batch_orders Create a batch of orders
SpotApi ListAllOpenOrders GET /spot/open_orders List all open orders
SpotApi ListOrders GET /spot/orders List orders
SpotApi CreateOrder POST /spot/orders Create an order
SpotApi CancelOrders DELETE /spot/orders Cancel all open orders in specified currency pair
SpotApi CancelBatchOrders POST /spot/cancel_batch_orders Cancel a batch of orders with an ID list
SpotApi GetOrder GET /spot/orders/{order_id} Get a single order
SpotApi CancelOrder DELETE /spot/orders/{order_id} Cancel a single order
SpotApi ListMyTrades GET /spot/my_trades List personal trading history
SpotApi ListSpotPriceTriggeredOrders GET /spot/price_orders Retrieve running auto order list
SpotApi CreateSpotPriceTriggeredOrder POST /spot/price_orders Create a price-triggered order
SpotApi CancelSpotPriceTriggeredOrderList DELETE /spot/price_orders Cancel all open orders
SpotApi GetSpotPriceTriggeredOrder GET /spot/price_orders/{order_id} Get a single order
SpotApi CancelSpotPriceTriggeredOrder DELETE /spot/price_orders/{order_id} Cancel a single order
WalletApi ListCurrencyChains GET /wallet/currency_chains List chains supported for specified currency
WalletApi GetDepositAddress GET /wallet/deposit_address Generate currency deposit address
WalletApi ListWithdrawals GET /wallet/withdrawals Retrieve withdrawal records
WalletApi ListDeposits GET /wallet/deposits Retrieve deposit records
WalletApi Transfer POST /wallet/transfers Transfer between trading accounts
WalletApi ListSubAccountTransfers GET /wallet/sub_account_transfers Retrieve transfer records between main and sub accounts
WalletApi TransferWithSubAccount POST /wallet/sub_account_transfers Transfer between main and sub accounts
WalletApi ListWithdrawStatus GET /wallet/withdraw_status Retrieve withdrawal status
WalletApi ListSubAccountBalances GET /wallet/sub_account_balances Retrieve sub account balances
WalletApi GetTradeFee GET /wallet/fee Retrieve personal trading fee
WalletApi GetTotalBalance GET /wallet/total_balance Retrieve user's total balances
WithdrawalApi Withdraw POST /withdrawals Withdraw
WithdrawalApi CancelWithdrawal DELETE /withdrawals/{withdrawal_id} Cancel withdrawal with specified ID

Documentation for Models

Documentation for Authorization

apiv4

  • Type: Gate APIv4 authentication

For details, refer to: APIv4 signed request requirements