Giter VIP home page Giter VIP logo

gateapi-python's Introduction

gate-api

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 Python package is automatically generated by the OpenAPI Generator project:

  • API version: 4.70.0
  • Package version: 4.70.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen 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

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

You can install directly using:

pip install --user gate-api

Then import the package:

import gate_api

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import gate_api

Getting Started

Please follow the installation procedure and then run the following:

from __future__ import print_function

import gate_api
from gate_api.exceptions import ApiException, GateApiException

# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
    host = "https://api.gateio.ws/api/v4"
)


api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_instance = gate_api.EarnUniApi(api_client)

try:
    # List currencies for lending
    api_response = api_instance.list_uni_currencies()
    print(api_response)
except GateApiException as ex:
    print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
    print("Exception when calling EarnUniApi->list_uni_currencies: %s\n" % e)

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
EarnUniApi list_uni_currencies GET /earn/uni/currencies List currencies for lending
EarnUniApi get_uni_currency GET /earn/uni/currencies/{currency} Get currency detail for lending
EarnUniApi list_user_uni_lends GET /earn/uni/lends List user's lending orders
EarnUniApi create_uni_lend POST /earn/uni/lends Lend or redeem
EarnUniApi change_uni_lend PATCH /earn/uni/lends Amend lending order
EarnUniApi list_uni_lend_records GET /earn/uni/lend_records List records of lending
EarnUniApi get_uni_interest GET /earn/uni/interests/{currency} Get the user's total interest income of specified currency
EarnUniApi list_uni_interest_records GET /earn/uni/interest_records List interest records
EarnUniApi switch_interest_reinvest PUT /earn/uni/interest_reinvest Set interest reinvestment toggle
EarnUniApi get_uni_interest_status GET /earn/uni/interest_status/{currency} query currency interest compounding status
MarginUniApi list_uni_currency_pairs GET /margin/uni/currency_pairs List lending markets
MarginUniApi get_uni_currency_pair GET /margin/uni/currency_pairs/{currency_pair} Get detail of lending market
MarginUniApi get_margin_uni_estimate_rate GET /margin/uni/estimate_rate Estimate interest Rate
MarginUniApi list_uni_loans GET /margin/uni/loans List loans
MarginUniApi create_uni_loan POST /margin/uni/loans Borrow or repay
MarginUniApi list_uni_loan_records GET /margin/uni/loan_records Get load records
MarginUniApi list_uni_loan_interest_records GET /margin/uni/interest_records List interest records
MarginUniApi get_uni_borrowable GET /margin/uni/borrowable Get maximum borrowable
SubAccountApi list_sub_accounts GET /sub_accounts List sub-accounts
SubAccountApi create_sub_accounts POST /sub_accounts Create a new sub-account
SubAccountApi get_sub_account GET /sub_accounts/{user_id} Get the sub-account
SubAccountApi list_sub_account_keys GET /sub_accounts/{user_id}/keys List all API Key of the sub-account
SubAccountApi create_sub_account_keys POST /sub_accounts/{user_id}/keys Create API Key of the sub-account
SubAccountApi get_sub_account_key GET /sub_accounts/{user_id}/keys/{key} Get the API Key of the sub-account
SubAccountApi update_sub_account_keys PUT /sub_accounts/{user_id}/keys/{key} Update API key of the sub-account
SubAccountApi delete_sub_account_keys DELETE /sub_accounts/{user_id}/keys/{key} Delete API key of the sub-account
SubAccountApi lock_sub_account POST /sub_accounts/{user_id}/lock Lock the sub-account
SubAccountApi unlock_sub_account POST /sub_accounts/{user_id}/unlock Unlock the sub-account
UnifiedApi list_unified_accounts GET /unified/accounts Get unified account information
UnifiedApi list_unified_account_mode GET /unified/account_mode Query mode of the unified account
UnifiedApi set_unified_account_mode POST /unified/account_mode Set mode of the unified account
UnifiedApi get_unified_borrowable GET /unified/borrowable Query about the maximum borrowing for the unified account
UnifiedApi get_unified_transferable GET /unified/transferable Query about the maximum transferable for the unified account
UnifiedApi list_unified_loans GET /unified/loans List loans
UnifiedApi create_unified_loan POST /unified/loans Borrow or repay
UnifiedApi list_unified_loan_records GET /unified/loan_records Get load records
UnifiedApi list_unified_loan_interest_records GET /unified/interest_records List interest records
UnifiedApi get_unified_estimate_rate GET /unified/estimate_rate Get unified estimate rate
UnifiedApi list_currency_discount_tiers GET /unified/currency_discount_tiers list currency discount tiers
AccountApi get_account_detail GET /account/detail Get account detail
AccountApi list_stp_groups GET /account/stp_groups List STP Groups
AccountApi create_stp_group POST /account/stp_groups Create STP Group
AccountApi list_stp_groups_users GET /account/stp_groups/{stp_id}/users List users of the STP group
AccountApi add_stp_group_users POST /account/stp_groups/{stp_id}/users Add users to the STP group
AccountApi delete_stp_group_users DELETE /account/stp_groups/{stp_id}/users Delete the user in the STP group
CollateralLoanApi list_collateral_loan_orders GET /loan/collateral/orders List Orders
CollateralLoanApi create_collateral_loan POST /loan/collateral/orders Place order
CollateralLoanApi get_collateral_loan_order_detail GET /loan/collateral/orders/{order_id} Get a single order
CollateralLoanApi repay_collateral_loan POST /loan/collateral/repay Repayment
CollateralLoanApi list_repay_records GET /loan/collateral/repay_records Repayment history
CollateralLoanApi list_collateral_records GET /loan/collateral/collaterals Query collateral adjustment records
CollateralLoanApi operate_collateral POST /loan/collateral/collaterals Increase or redeem collateral
CollateralLoanApi get_user_total_amount GET /loan/collateral/total_amount Query the total borrowing and collateral amount for the user
CollateralLoanApi get_user_ltv_info GET /loan/collateral/ltv Query user's collateralization ratio
CollateralLoanApi list_collateral_currencies GET /loan/collateral/currencies Query supported borrowing and collateral currencies
DeliveryApi list_delivery_contracts GET /delivery/{settle}/contracts List all futures contracts
DeliveryApi get_delivery_contract GET /delivery/{settle}/contracts/{contract} Get a single contract
DeliveryApi list_delivery_order_book GET /delivery/{settle}/order_book Futures order book
DeliveryApi list_delivery_trades GET /delivery/{settle}/trades Futures trading history
DeliveryApi list_delivery_candlesticks GET /delivery/{settle}/candlesticks Get futures candlesticks
DeliveryApi list_delivery_tickers GET /delivery/{settle}/tickers List futures tickers
DeliveryApi list_delivery_insurance_ledger GET /delivery/{settle}/insurance Futures insurance balance history
DeliveryApi list_delivery_accounts GET /delivery/{settle}/accounts Query futures account
DeliveryApi list_delivery_account_book GET /delivery/{settle}/account_book Query account book
DeliveryApi list_delivery_positions GET /delivery/{settle}/positions List all positions of a user
DeliveryApi get_delivery_position GET /delivery/{settle}/positions/{contract} Get single position
DeliveryApi update_delivery_position_margin POST /delivery/{settle}/positions/{contract}/margin Update position margin
DeliveryApi update_delivery_position_leverage POST /delivery/{settle}/positions/{contract}/leverage Update position leverage
DeliveryApi update_delivery_position_risk_limit POST /delivery/{settle}/positions/{contract}/risk_limit Update position risk limit
DeliveryApi list_delivery_orders GET /delivery/{settle}/orders List futures orders
DeliveryApi create_delivery_order POST /delivery/{settle}/orders Create a futures order
DeliveryApi cancel_delivery_orders DELETE /delivery/{settle}/orders Cancel all `open` orders matched
DeliveryApi get_delivery_order GET /delivery/{settle}/orders/{order_id} Get a single order
DeliveryApi cancel_delivery_order DELETE /delivery/{settle}/orders/{order_id} Cancel a single order
DeliveryApi get_my_delivery_trades GET /delivery/{settle}/my_trades List personal trading history
DeliveryApi list_delivery_position_close GET /delivery/{settle}/position_close List position close history
DeliveryApi list_delivery_liquidates GET /delivery/{settle}/liquidates List liquidation history
DeliveryApi list_delivery_settlements GET /delivery/{settle}/settlements List settlement history
DeliveryApi list_price_triggered_delivery_orders GET /delivery/{settle}/price_orders List all auto orders
DeliveryApi create_price_triggered_delivery_order POST /delivery/{settle}/price_orders Create a price-triggered order
DeliveryApi cancel_price_triggered_delivery_order_list DELETE /delivery/{settle}/price_orders Cancel all open orders
DeliveryApi get_price_triggered_delivery_order GET /delivery/{settle}/price_orders/{order_id} Get a price-triggered order
DeliveryApi cancel_price_triggered_delivery_order DELETE /delivery/{settle}/price_orders/{order_id} cancel a price-triggered order
EarnApi swap_eth2 POST /earn/staking/eth2/swap ETH2 swap
EarnApi list_dual_investment_plans GET /earn/dual/investment_plan Dual Investment product list
EarnApi list_dual_orders GET /earn/dual/orders Dual Investment order list
EarnApi place_dual_order POST /earn/dual/orders Place Dual Investment order
EarnApi list_structured_products GET /earn/structured/products Structured Product List
EarnApi list_structured_orders GET /earn/structured/orders Structured Product Order List
EarnApi place_structured_order POST /earn/structured/orders Place Structured Product Order
FlashSwapApi list_flash_swap_currencies GET /flash_swap/currencies List All Supported Currencies In Flash Swap (deprecated)
FlashSwapApi list_flash_swap_currency_pair GET /flash_swap/currency_pairs List All Supported Currency Pairs In Flash Swap
FlashSwapApi list_flash_swap_orders GET /flash_swap/orders List all flash swap orders
FlashSwapApi create_flash_swap_order POST /flash_swap/orders Create a flash swap order
FlashSwapApi get_flash_swap_order GET /flash_swap/orders/{order_id} Get a single flash swap order's detail
FlashSwapApi preview_flash_swap_order POST /flash_swap/orders/preview Initiate a flash swap order preview
FuturesApi list_futures_contracts GET /futures/{settle}/contracts List all futures contracts
FuturesApi get_futures_contract GET /futures/{settle}/contracts/{contract} Get a single contract
FuturesApi list_futures_order_book GET /futures/{settle}/order_book Futures order book
FuturesApi list_futures_trades GET /futures/{settle}/trades Futures trading history
FuturesApi list_futures_candlesticks GET /futures/{settle}/candlesticks Get futures candlesticks
FuturesApi list_futures_premium_index GET /futures/{settle}/premium_index Premium Index K-Line
FuturesApi list_futures_tickers GET /futures/{settle}/tickers List futures tickers
FuturesApi list_futures_funding_rate_history GET /futures/{settle}/funding_rate Funding rate history
FuturesApi list_futures_insurance_ledger GET /futures/{settle}/insurance Futures insurance balance history
FuturesApi list_contract_stats GET /futures/{settle}/contract_stats Futures stats
FuturesApi get_index_constituents GET /futures/{settle}/index_constituents/{index} Get index constituents
FuturesApi list_liquidated_orders GET /futures/{settle}/liq_orders Retrieve liquidation history
FuturesApi list_risk_limit_tiers GET /futures/{settle}/risk_limit_tiers List risk limit tiers
FuturesApi list_futures_accounts GET /futures/{settle}/accounts Query futures account
FuturesApi list_futures_account_book GET /futures/{settle}/account_book Query account book
FuturesApi list_positions GET /futures/{settle}/positions List all positions of a user
FuturesApi get_position GET /futures/{settle}/positions/{contract} Get single position
FuturesApi update_position_margin POST /futures/{settle}/positions/{contract}/margin Update position margin
FuturesApi update_position_leverage POST /futures/{settle}/positions/{contract}/leverage Update position leverage
FuturesApi update_position_risk_limit POST /futures/{settle}/positions/{contract}/risk_limit Update position risk limit
FuturesApi set_dual_mode POST /futures/{settle}/dual_mode Enable or disable dual mode
FuturesApi get_dual_mode_position GET /futures/{settle}/dual_comp/positions/{contract} Retrieve position detail in dual mode
FuturesApi update_dual_mode_position_margin POST /futures/{settle}/dual_comp/positions/{contract}/margin Update position margin in dual mode
FuturesApi update_dual_mode_position_leverage POST /futures/{settle}/dual_comp/positions/{contract}/leverage Update position leverage in dual mode
FuturesApi update_dual_mode_position_risk_limit POST /futures/{settle}/dual_comp/positions/{contract}/risk_limit Update position risk limit in dual mode
FuturesApi list_futures_orders GET /futures/{settle}/orders List futures orders
FuturesApi create_futures_order POST /futures/{settle}/orders Create a futures order
FuturesApi cancel_futures_orders DELETE /futures/{settle}/orders Cancel all `open` orders matched
FuturesApi get_orders_with_time_range GET /futures/{settle}/orders_timerange List Futures Orders By Time Range
FuturesApi create_batch_futures_order POST /futures/{settle}/batch_orders Create a batch of futures orders
FuturesApi get_futures_order GET /futures/{settle}/orders/{order_id} Get a single order
FuturesApi amend_futures_order PUT /futures/{settle}/orders/{order_id} Amend an order
FuturesApi cancel_futures_order DELETE /futures/{settle}/orders/{order_id} Cancel a single order
FuturesApi get_my_trades GET /futures/{settle}/my_trades List personal trading history
FuturesApi get_my_trades_with_time_range GET /futures/{settle}/my_trades_timerange List personal trading history by time range
FuturesApi list_position_close GET /futures/{settle}/position_close List position close history
FuturesApi list_liquidates GET /futures/{settle}/liquidates List liquidation history
FuturesApi list_auto_deleverages GET /futures/{settle}/auto_deleverages List Auto-Deleveraging History
FuturesApi countdown_cancel_all_futures POST /futures/{settle}/countdown_cancel_all Countdown cancel orders
FuturesApi get_futures_fee GET /futures/{settle}/fee Query user trading fee rates
FuturesApi cancel_batch_future_orders POST /futures/{settle}/batch_cancel_orders Cancel a batch of orders with an ID list
FuturesApi list_price_triggered_orders GET /futures/{settle}/price_orders List all auto orders
FuturesApi create_price_triggered_order POST /futures/{settle}/price_orders Create a price-triggered order
FuturesApi cancel_price_triggered_order_list DELETE /futures/{settle}/price_orders Cancel all open orders
FuturesApi get_price_triggered_order GET /futures/{settle}/price_orders/{order_id} Get a price-triggered order
FuturesApi cancel_price_triggered_order DELETE /futures/{settle}/price_orders/{order_id} cancel a price-triggered order
MarginApi list_margin_accounts GET /margin/accounts Margin account list
MarginApi list_margin_account_book GET /margin/account_book List margin account balance change history
MarginApi list_funding_accounts GET /margin/funding_accounts Funding account list
MarginApi get_auto_repay_status GET /margin/auto_repay Retrieve user auto repayment setting
MarginApi set_auto_repay POST /margin/auto_repay Update user's auto repayment setting
MarginApi get_margin_transferable GET /margin/transferable Get the max transferable amount for a specific margin currency
MarginApi list_margin_currency_pairs GET /margin/currency_pairs List all supported currency pairs supported in margin trading(Deprecated)
MarginApi get_margin_currency_pair GET /margin/currency_pairs/{currency_pair} Query one single margin currency pair(Deprecated)
MarginApi list_funding_book GET /margin/funding_book Order book of lending loans(Deprecated)
MarginApi list_loans GET /margin/loans List all loans(Deprecated)
MarginApi create_loan POST /margin/loans Lend or borrow(Deprecated)
MarginApi merge_loans POST /margin/merged_loans Merge multiple lending loans(Deprecated)
MarginApi get_loan GET /margin/loans/{loan_id} Retrieve one single loan detail(Deprecated)
MarginApi cancel_loan DELETE /margin/loans/{loan_id} Cancel lending loan(Deprecated)
MarginApi update_loan PATCH /margin/loans/{loan_id} Modify a loan(Deprecated)
MarginApi list_loan_repayments GET /margin/loans/{loan_id}/repayment List loan repayment records(Deprecated)
MarginApi repay_loan POST /margin/loans/{loan_id}/repayment Repay a loan(Deprecated)
MarginApi list_loan_records GET /margin/loan_records List repayment records of a specific loan(Deprecated)
MarginApi get_loan_record GET /margin/loan_records/{loan_record_id} Get one single loan record(Deprecated)
MarginApi update_loan_record PATCH /margin/loan_records/{loan_record_id} Modify a loan record(Deprecated)
MarginApi get_margin_borrowable GET /margin/borrowable Get the max borrowable amount for a specific margin currency(Deprecated)
MarginApi list_cross_margin_currencies GET /margin/cross/currencies Currencies supported by cross margin.
MarginApi get_cross_margin_currency GET /margin/cross/currencies/{currency} Retrieve detail of one single currency supported by cross margin
MarginApi get_cross_margin_account GET /margin/cross/accounts Retrieve cross margin account
MarginApi list_cross_margin_account_book GET /margin/cross/account_book Retrieve cross margin account change history
MarginApi list_cross_margin_loans GET /margin/cross/loans List cross margin borrow history
MarginApi create_cross_margin_loan POST /margin/cross/loans Create a cross margin borrow loan
MarginApi get_cross_margin_loan GET /margin/cross/loans/{loan_id} Retrieve single borrow loan detail
MarginApi list_cross_margin_repayments GET /margin/cross/repayments Retrieve cross margin repayments
MarginApi repay_cross_margin_loan POST /margin/cross/repayments Cross margin repayments
MarginApi get_cross_margin_interest_records GET /margin/cross/interest_records Interest records for the cross margin account
MarginApi get_cross_margin_transferable GET /margin/cross/transferable Get the max transferable amount for a specific cross margin currency
MarginApi get_cross_margin_estimate_rate GET /margin/cross/estimate_rate Estimated interest rates
MarginApi get_cross_margin_borrowable GET /margin/cross/borrowable Get the max borrowable amount for a specific cross margin currency
MultiCollateralLoanApi list_multi_collateral_orders GET /loan/multi_collateral/orders List Multi-Collateral Orders
MultiCollateralLoanApi create_multi_collateral POST /loan/multi_collateral/orders Create Multi-Collateral Order
MultiCollateralLoanApi get_multi_collateral_order_detail GET /loan/multi_collateral/orders/{order_id} Get Multi-Collateral Order Detail
MultiCollateralLoanApi list_multi_repay_records GET /loan/multi_collateral/repay List Multi-Collateral Repay Records
MultiCollateralLoanApi repay_multi_collateral_loan POST /loan/multi_collateral/repay Repay Multi-Collateral Loan
MultiCollateralLoanApi list_multi_collateral_records GET /loan/multi_collateral/mortgage Query collateral adjustment records
MultiCollateralLoanApi operate_multi_collateral POST /loan/multi_collateral/mortgage Operate Multi-Collateral
MultiCollateralLoanApi list_user_currency_quota GET /loan/multi_collateral/currency_quota List User Currency Quota
MultiCollateralLoanApi list_multi_collateral_currencies GET /loan/multi_collateral/currencies Query supported borrowing and collateral currencies in Multi-Collateral
MultiCollateralLoanApi get_multi_collateral_ltv GET /loan/multi_collateral/ltv Get Multi-Collateral ratio
MultiCollateralLoanApi get_multi_collateral_fix_rate GET /loan/multi_collateral/fixed_rate Query fixed interest rates for the currency for 7 days and 30 days
OptionsApi list_options_underlyings GET /options/underlyings List all underlyings
OptionsApi list_options_expirations GET /options/expirations List all expiration times
OptionsApi list_options_contracts GET /options/contracts List all the contracts with specified underlying and expiration time
OptionsApi get_options_contract GET /options/contracts/{contract} Query specified contract detail
OptionsApi list_options_settlements GET /options/settlements List settlement history
OptionsApi get_options_settlement GET /options/settlements/{contract} Get specified contract's settlement
OptionsApi list_my_options_settlements GET /options/my_settlements List my options settlements
OptionsApi list_options_order_book GET /options/order_book Options order book
OptionsApi list_options_tickers GET /options/tickers List tickers of options contracts
OptionsApi list_options_underlying_tickers GET /options/underlying/tickers/{underlying} Get underlying ticker
OptionsApi list_options_candlesticks GET /options/candlesticks Get options candlesticks
OptionsApi list_options_underlying_candlesticks GET /options/underlying/candlesticks Mark price candlesticks of an underlying
OptionsApi list_options_trades GET /options/trades Options trade history
OptionsApi list_options_account GET /options/accounts List options account
OptionsApi list_options_account_book GET /options/account_book List account changing history
OptionsApi list_options_positions GET /options/positions List user's positions of specified underlying
OptionsApi get_options_position GET /options/positions/{contract} Get specified contract position
OptionsApi list_options_position_close GET /options/position_close List user's liquidation history of specified underlying
OptionsApi list_options_orders GET /options/orders List options orders
OptionsApi create_options_order POST /options/orders Create an options order
OptionsApi cancel_options_orders DELETE /options/orders Cancel all `open` orders matched
OptionsApi get_options_order GET /options/orders/{order_id} Get a single order
OptionsApi cancel_options_order DELETE /options/orders/{order_id} Cancel a single order
OptionsApi list_my_options_trades GET /options/my_trades List personal trading history
RebateApi agency_transaction_history GET /rebate/agency/transaction_history The agency obtains the transaction history of the recommended user
RebateApi agency_commissions_history GET /rebate/agency/commission_history The agency obtains the commission history of the recommended user
RebateApi rebate_broker_commission_history GET /rebate/broker/commission_history The broker obtains the user's commission rebate records
RebateApi rebate_broker_transaction_history GET /rebate/broker/transaction_history The broker obtains the user's trading history
SpotApi list_currencies GET /spot/currencies List all currencies' details
SpotApi get_currency GET /spot/currencies/{currency} Get details of a specific currency
SpotApi list_currency_pairs GET /spot/currency_pairs List all currency pairs supported
SpotApi get_currency_pair GET /spot/currency_pairs/{currency_pair} Get details of a specifc currency pair
SpotApi list_tickers GET /spot/tickers Retrieve ticker information
SpotApi list_order_book GET /spot/order_book Retrieve order book
SpotApi list_trades GET /spot/trades Retrieve market trades
SpotApi list_candlesticks GET /spot/candlesticks Market candlesticks
SpotApi get_fee GET /spot/fee Query user trading fee rates
SpotApi get_batch_spot_fee GET /spot/batch_fee Query a batch of user trading fee rates
SpotApi list_spot_accounts GET /spot/accounts List spot accounts
SpotApi list_spot_account_book GET /spot/account_book Query account book
SpotApi create_batch_orders POST /spot/batch_orders Create a batch of orders
SpotApi list_all_open_orders GET /spot/open_orders List all open orders
SpotApi create_cross_liquidate_order POST /spot/cross_liquidate_orders close position when cross-currency is disabled
SpotApi list_orders GET /spot/orders List orders
SpotApi create_order POST /spot/orders Create an order
SpotApi cancel_orders DELETE /spot/orders Cancel all `open` orders in specified currency pair
SpotApi cancel_batch_orders POST /spot/cancel_batch_orders Cancel a batch of orders with an ID list
SpotApi get_order GET /spot/orders/{order_id} Get a single order
SpotApi cancel_order DELETE /spot/orders/{order_id} Cancel a single order
SpotApi amend_order PATCH /spot/orders/{order_id} Amend an order
SpotApi list_my_trades GET /spot/my_trades List personal trading history
SpotApi get_system_time GET /spot/time Get server current time
SpotApi countdown_cancel_all_spot POST /spot/countdown_cancel_all Countdown cancel orders
SpotApi amend_batch_orders POST /spot/amend_batch_orders Batch modification of orders
SpotApi list_spot_price_triggered_orders GET /spot/price_orders Retrieve running auto order list
SpotApi create_spot_price_triggered_order POST /spot/price_orders Create a price-triggered order
SpotApi cancel_spot_price_triggered_order_list DELETE /spot/price_orders Cancel all open orders
SpotApi get_spot_price_triggered_order GET /spot/price_orders/{order_id} Get a price-triggered order
SpotApi cancel_spot_price_triggered_order DELETE /spot/price_orders/{order_id} cancel a price-triggered order
WalletApi list_currency_chains GET /wallet/currency_chains List chains supported for specified currency
WalletApi get_deposit_address GET /wallet/deposit_address Generate currency deposit address
WalletApi list_withdrawals GET /wallet/withdrawals Retrieve withdrawal records
WalletApi list_deposits GET /wallet/deposits Retrieve deposit records
WalletApi transfer POST /wallet/transfers Transfer between trading accounts
WalletApi list_sub_account_transfers GET /wallet/sub_account_transfers Retrieve transfer records between main and sub accounts
WalletApi transfer_with_sub_account POST /wallet/sub_account_transfers Transfer between main and sub accounts
WalletApi sub_account_to_sub_account POST /wallet/sub_account_to_sub_account Sub-account transfers to sub-account
WalletApi list_withdraw_status GET /wallet/withdraw_status Retrieve withdrawal status
WalletApi list_sub_account_balances GET /wallet/sub_account_balances Retrieve sub account balances
WalletApi list_sub_account_margin_balances GET /wallet/sub_account_margin_balances Query sub accounts' margin balances
WalletApi list_sub_account_futures_balances GET /wallet/sub_account_futures_balances Query sub accounts' futures account balances
WalletApi list_sub_account_cross_margin_balances GET /wallet/sub_account_cross_margin_balances Query subaccount's cross_margin account info
WalletApi list_saved_address GET /wallet/saved_address Query saved address
WalletApi get_trade_fee GET /wallet/fee Retrieve personal trading fee
WalletApi get_total_balance GET /wallet/total_balance Retrieve user's total balances
WalletApi list_small_balance GET /wallet/small_balance List small balance
WalletApi convert_small_balance POST /wallet/small_balance Convert small balance
WalletApi list_small_balance_history GET /wallet/small_balance_history List small balance history
WithdrawalApi withdraw POST /withdrawals Withdrawals to Gate addresses do not incur transaction fees.
WithdrawalApi cancel_withdrawal DELETE /withdrawals/{withdrawal_id} Cancel withdrawal with specified ID

Documentation For Models

Documentation For Authorization

apiv4

Authentication with APIv4 key and secret

For details, refer to: APIv4 signed request requirements

Author

[email protected]

gateapi-python's People

Contributors

gateio avatar revilwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gateapi-python's Issues

关于sdk的问题

想问一下。
Gate API v4 v4.11.0中提供的python sdk 和 网页版API是一样的吗?
api版本更新,网页版的和sdk都是同步更新吗?
访问端口,反馈速度等都是没差别的吗。

POST /spot/orders 中的type参数

如题。api说明中,仅提供了limit一个说明,没有别的type值了吗?
如我想以固定价格买入而非当前价交易,该如何输入?

合约API收到401错误 Missing required header: Timestamp

之前已经调试通过的Python代码,最近执行遇到API报错:
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Date': 'Sat, 11 Apr 2020 16:17:12 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty'})
HTTP response body: {"label":"MISSING_REQUIRED_HEADER","message":"Missing required header: Timestamp"}
已经更新Python版本的API代码4.11版本,咨询一下如何解决。

Full Futures Position Close History

Hello,

Is there any way to get a full paginated list of closed position history? I am using futures list position close history method however it has a limit of 100 entries, I couldn't find any kind of pagination.

Regards

'/api2/1/coininfo' 获取USDT_ETH, USDT_TRX可提币状态不对

您好,通过'/api2/1/coininfo'这个api path获取USDT_ETH和USDT_TRX的可提币状态不对,api获取到的是不可提币状态,实际上是可以提币的,请检查一下,谢谢。

{
    "USDT_TRX": {
        "delisted": 0,
        "withdraw_disabled": 1,
        "withdraw_delayed": 0,
        "deposit_disabled": 0,
        "trade_disabled": 0
    },
    "USDT_ETH": {
        "delisted": 0,
        "withdraw_disabled": 1,
        "withdraw_delayed": 0,
        "deposit_disabled": 0,
        "trade_disabled": 1
    }
}

Gate api exception, label: INVALID_SIGNATURE, message: Signature mismatch

请问哪里有问题会导致签名不匹配, key和secret分别改成1和2了。

import gate_api
from gate_api.exceptions import ApiException, GateApiException

HOST = "https://api.gateio.ws/api/v4"
API_KEY = "1"
API_SECRET = "2"

# Defining the host is optional and defaults to https://api.gateio.ws/api/v4
# See configuration.py for a list of all supported configuration parameters.
configuration = gate_api.Configuration(
    host=HOST,
    key=API_KEY,
    secret=API_SECRET,
)

api_client = gate_api.ApiClient(configuration)
# Create an instance of the API class
api_withdrawal = gate_api.WithdrawalApi(api_client)

try:
    # List all futures contracts
    api_response = api_withdrawal.withdraw(
        ledger_record='{"currency":"ttt","address":"tttt","amount":"10.1","memo":""}'
    )
    print(api_response)
except GateApiException as ex:
    print("Gate api exception, label: %s, message: %s\n" % (
    ex.label, ex.message))
except ApiException as e:
    print(
        "Exception when calling DeliveryApi->list_delivery_contracts: %s\n" % e)

请教api字段含义

1、change_percentage/mark_price/index_price 代表什么意思
2、资金费率剩余时间怎么获取

futures contracts websocket signature method

合约交易获取交易的订单,需要权限部分,签名是如何实现的,SIGN怎么生成的。websocket方式,不是rest方式。
from websocket import create_connection
ws = create_connection("wss://fx-ws-testnet.gateio.ws/v4/ws")
ws.send('{
"time" : 123456,
"channel" : "futures.orders",
"event": "subscribe",
"payload" : ["20011", "BTC_USD"],
"auth": {
"method": "api_key",
"KEY":"xxxx",
"SIGN": "xxxx"
}}')

Scientific notation price

Hello, I have encountered a weird thing. Why can't I pass price as scientific notation? It's not a case for all other exchanges, I get an "Invalid requests parameter 'price' value: 6.521e-05" (here is an example for HSC/USDT) error, how is it possible that endpoint doesn't accept scientific notation? Making it a string doesn't help. How can I solve that?

撤单频率有限制吗

撤单频率有限制嘛?{'label': 'METHOD_NOT_ALLOWED', 'message': 'Cancel order too fast, please wait 1 min and try again.'}是什么触发的?

websocket的接口库能不能重写一下啊!

3大所的websocket接口库都有!你只要把火币和币安的库看一下!然后套一下就可以发布了吧!比现在这个12个月都不更新的好多了!期待。。。。

b'{"label":"INVALID_SIGNATURE","message":"Signature mismatch"}\n'

def gen_sign(method, url, query_string=None, payload_string=None):
    key = 'xxxxx'  # api_key
    secret = 'xxxxx'  # api_secret

    current_time = time.time()
    m = hashlib.sha512()
    if payload_string is not None:
        m.update(payload_string.encode('utf-8'))
    hashed_payload = m.hexdigest()
    s = '%s\n%s\n%s\n%s\n%s' % (method, url, query_string or "", hashed_payload, current_time)
    sign = hmac.new(secret.encode('utf-8'), s.encode('utf-8'), hashlib.sha512).hexdigest()
    return {'KEY': key, 'Timestamp': str(current_time), 'SIGN': sign}


if __name__ == "__main__":
    host = "https://api.gateio.ws"
    prefix = "/api/v4"
    common_headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

    url = '/futures/accounts'
    sign_headers = gen_sign('GET', prefix + url, "", None)
    sign_headers.update(common_headers)
    print('signature headers: %s' % sign_headers)
    res = requests.post(host + prefix + url, headers=sign_headers, data=None)
    print(res.status_code)
    print(res.content)

深度数据咨询

[{'p': '3.097', 's': 0, 'c': 'EOS_USD', 'id': 24679122}, {'p': '3.078', 's': 981, 'c': 'EOS_USD', 'id': 24679123}]
[{'p': '3.082', 's': 0, 'c': 'EOS_USD', 'id': 24679264}, {'p': '3.088', 's': 516, 'c': 'EOS_USD', 'id': 24679265}]
[{'p': '3.099', 's': -78, 'c': 'EOS_USD', 'id': 24679124}, {'p': '3.11', 's': -779, 'c': 'EOS_USD', 'id': 24679125}]
1、深度更新的时候,0代表是卖盘还是买盘
2、更新的数据如何对于第几档位上

auth faild , auth data : \u0026{{87260}

订阅futures.orders和futures.balances的websocket,都报如下错误,不知道什么意思
{"time":1570513208,"channel":"futures.orders","event":"subscribe","error":{"code":2,"message":"auth faild , auth data : \u0026{{87260}}"},"result":{"status":"failed"}}

Transfer api不可用

您好,我参照github上gateio-python的api进行spot到margin的划转操作,提示404 not found
https://github.com/gateio/gateapi-python/blob/937548602284c1a7a0192b1eef0e882520b7441c/gate_api/models/transfer.py

参数和请求:
post /api/v4/wallet/transfers params={'currency': 'USDT', 'currency_pair': 'ETH_USDT', 'amount': '51', '_from': 'spot', 'to': 'margin’}

响应:
Get a error on http POST request for url https://api.gateio.ws/api/v4/wallet/transfers, HTTP 404: Not Found b'{"label":"NOT_FOUND"}\n’

请问是哪里设置的不对吗,还是这个api没有上线?

关于k线数据获取api

/spot/candlesticks
这个api如果设置1d,则返回的开盘价是24小时前开盘价,还是上午8点(当日)开盘价?
是否有时区区分?

超时time怎么设置

环境:python
问题:由于默认timeout时间太长 导致拉不到数据容易卡死,怎么设置timeout在python api里

内存溢出问题!

我用concurrent.futures模块使用多线程,内存就一直增加,然后ccxt改写脚本,内存没有问题!用objgraph和memory_profiler模块找脚本内存增加的原因!脚本所有的变量都没有问题!哎。。。。

Rebasing info

Hello! Is there any part where API endpoints inform about currency "rebasing"? (whatever it is)? trade_status in list_currency_pairs() gives "tradable" status even tho I wouldn't call it tradable as not all actions can be taken on the pair then.

how to use this api to trade with my margin funds

The MarginApi don't provide the "create order" method, is there any way i can use to trade on margin.

I try this:

  1. create an order
    order=gate_api.Order(currency_pair='ATOM_USDT',price=4.82,account='margin',amount=1,side='sell')
    spot = gate_api.SpotApi(gate_api.ApiClient(configuration))

  2. then passing the order to spot.create_order
    api_response=spot.create_order(order=order)

This method raises exception below:
ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Fri, 03 May 2019 13:25:20 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '61', 'Connection': 'keep-alive', 'Server': 'openresty/1.13.6.1', 'X-Request-Id': '[1879f505]'})
HTTP response body: {"label":"BALANCE_NOT_ENOUGH","message":"balance not enough"}

撤单频率又被限制了

你好!
我目前在gate的七个交易对上做市(日交易量达到60btc了,还能往上加)做到昨天都很顺畅,但是今天11:49撤单又被限频了。。
我的uid是2541076
我的七个程序,每个程序每分钟调用撤单接口(参数有account=margin)撤单10~30次。今天做到11:49之前都正常,11:49开始返回{'label': 'METHOD_NOT_ALLOWED', 'message': 'Cancel order too fast, please wait 1 min and try again.'},此后就一直这个状态。
然后我关掉所有程序,等待了十分钟,重启其中一个程序后,第一次撤单 依然返回{'message': 'Cancel order too fast, please wait 1 min and try again.', 'label': 'METHOD_NOT_ALLOWED'}

个别杠杆账户出现无法下单的情况

你好 我的uid是2541076 我在七个币种上做杠杆下单,六个币种完全正常,但是xrp币种有个问题。

xrp杠杆账户余额是一万个xrp,网页版杠杆页面可以挂一万xrp的卖单并撤掉,但是通过api挂3000个xrp的卖单,显示 {'label': 'MARGIN_BALANCE_NOT_ENOUGH', 'message': 'No margin account or margin balance is not enough'}
这个是个别币种的现象,不是普遍的。

获取个人已经成交的订单

获取个人已经成交的订单(现货,合约,期货),能不能接口加一个字段text也跟着返回?(就是下单时候的字段text)

杠杆交易撤单 'Cancel order too fast, please wait 1 min and try again.'

我在币币交易15个品种上做市挂单,杠杆交易7个品种上做市挂单
挂单撤单的策略和频率应该是一样差不多的
然后 币币交易的所有品种 撤单都没有超频率限制,但是杠杆交易的品种 昨晚开始 一直返回{'label': 'METHOD_NOT_ALLOWED', 'message': 'Cancel order too fast, please wait 1 min and try again.'}

撤单被限制

你好!我的uid是2541076

交易了七天 交易量做到了1846.80694 BTC 103417495.03 CNY

我还是七个品种 杠杆账户交易撤单接口撤单,每分钟其实加起来不会超过300次的。

从今天04:50左右开始,又一直显示{'message': 'Cancel order too fast, please wait 1 min and try again.', 'label': 'METHOD_NOT_ALLOWED'

请问能不能解决一下...行情这么好 有点郁闷... 目前我停掉所有程序后五六分钟 重启了下 还是返回Cancel order too fast

[Question] How to list main spot account balances?

From the API, I found the following method for listing sub-account balances:

def list_sub_account_balances(self, **kwargs): # noqa: E501
. I am not using sub-accounts and it returns an empty list for me.

I also tried the websocket API described here: https://www.gate.io/docs/apiv4/ws/index.html#client-subscription-9. This one only seems to deliver updates to balances, but cannot provide current snapshot of all balances.

How to list balances for main spot account? Should I use v2 REST API instead?

合约函数有问题!

官方应该加了双向合约,导致有些函数有问题,目前发现update_position_leverage(settle, contract, leverage) # 调整合约杠杆倍数,这个函数有问题,应该是少了参数了!

不能创建永续合约订单,提示: INVALID_PROTOCOL / Can't Create FuturesOrder

代码是这样的:
Code:

   print(symbol)
    futures_order = gate_api.FuturesOrder(contract=symbol, size=-1 * quantity, price=price,reduce_only=False,tif="gtc")  # FuturesOrder

    try:

        # Create a futures order

        api_response = self.api_instance.create_futures_order(futures_order)
        print(api_response)
        return api_response
    except ApiException as e:
        print("Exception when calling FuturesApi->create_futures_order: %s\n" % e)
        raise e

输出是这样的:
Output:

BTC_USD

Exception when calling FuturesApi->create_futures_order: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Sun, 26 May 2019 06:10:07 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'openresty/1.13.6.1'})
HTTP response body: {"label":"INVALID_PROTOCOL","detail":"invalid argument: #3"}

How to place a market order?

This question is not about the Python API per se but the REST API in general.

Following the docs at https://www.gate.io/docs/apiv4/en/index.html#create-an-order, only "type": "limit" is a valid value. Can it also be used to place a market order? Intuitively, for a market order, I would set "time_in_force": "ioc", but I don't know what to set the price.

I could query the orderbook for current prices and pick a price that would immediately fill, but perhaps there is an easier way?

永续合约Rest返回结果json后面多了'\n'

你好,Rest下单或者cancel的时候,返回的json数据后面多了一个'\n',在用其它语言(非python,例如Rust decode from bytes)的时候会失败,麻烦把这个\n去掉

{ "id": 13045871072, "contract": "ALGO_USDT", "mkfr": "-0.0002", "tkfr": "0.0003", "tif": "poc", "is_reduce_only": false, "create_time": 1614832119.068, "price": "1.175", "size": 35, "refr": "0", "left": 35, "text": "t-474367393834", "fill_price": "0", "user": 3114850, "status": "open", "is_liq": false, "refu": 0, "is_close": false, "iceberg": 0 }\n

请求延迟是多长时间?

我看了一下rest模块下面的request函数的_request_timeout参数的None!是这个_request_timeout参数设置post和get等等返回的延迟时间吗?我写了个脚本,然后直接死了哪里,try也没有错误出来,肯定是没有超时设置时间吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.