Gate.io Python SDK

repository·master·Indexed 43 days ago

https://github.com/gateio/gateapi-python

A Python SDK for the Gate.io APIv4, providing programmatic access to spot, margin, and contract trading, as well as market data and automated trading interfaces. It includes specialized API classes such as SpotApi, FuturesApi, MarginApi, OptionsApi, and WalletApi to manage accounts, positions, and orders.

Tokens
260.9K
Snippets
449
Records
634
Agent score
56%

What's inside Gate.io

  1. Overview of gate_api.WalletApi

    master

    The WalletApi class provides methods for managing wallet-related operations, including querying currency chains, generating deposit addresses, managing withdrawals and deposits, performing transfers (including between main and sub-accounts), and checking balances.

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

  2. Use the OptionsApi to interact with options markets

    master

    The gate_api.OptionsApi class provides access to all options-related endpoints, including listing underlying assets, expiration dates, contracts, market data (tickers, order books, candlesticks), and managing orders and positions.

    All URIs are relative to https://api.gateio.ws/api/v4. You can initialize the API by creating a gate_api.Configuration object and passing it to a gate_api.ApiClient.

    import gate_api
    from gate_api.exceptions import ApiException, GateApiException
    
    configuration = gate_api.Configuration(
        host = "https://api.gateio.ws/api/v4"
    )
    
    api_client = gate_api.ApiClient(configuration)
    api_instance = gate_api.OptionsApi(api_client)
  3. Use gate_api.DeliveryApi for futures services

    master

    The gate_api.DeliveryApi class provides access to Gate.io's delivery (futures) market endpoints. This includes querying contract information, market depth (order books), trades, candlesticks, tickers, and managing user-specific delivery accounts, positions, and orders.

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

    import gate_api
    
    configuration = gate_api.Configuration(
        host = "https://api.gateio.ws/api/v4"
    )
    api_client = gate_api.ApiClient(configuration)
    api_instance = gate_api.DeliveryApi(api_client)
  4. Use gate_api.EarnUniApi

    master

    The EarnUniApi class provides access to Gate.io's Unified Lending (Earn Uni) services. It allows users to query lending currency lists, manage lending orders (create, amend, list), view transaction records, and check interest income/status.

    Endpoints are relative to https://api.gateio.ws/api/v4. Most endpoints require apiv4 authentication (API Key and Secret).

    import gate_api
    
    configuration = gate_api.Configuration(
        host = "https://api.gateio.ws/api/v4",
        key = "YOU_API_KEY",
        secret = "YOUR_API_SECRET"
    )
    
    api_client = gate_api.ApiClient(configuration)
    api_instance = gate_api.EarnUniApi(api_client)
  5. Use the UnifiedApi for unified account management

    master

    The gate_api.UnifiedApi class provides access to endpoints for managing unified accounts, including querying account information, checking borrowable/transferable amounts, managing loans, and configuring leverage and collateral. All URIs are relative to https://api.gateio.ws/api/v4.

    import gate_api
    
    configuration = gate_api.Configuration(
        host = "https://api.gateio.ws/api/v4",
        key = "YOU_API_KEY",
        secret = "YOUR_API_SECRET"
    )
    api_client = gate_api.ApiClient(configuration)
    api_instance = gate_api.UnifiedApi(api_client)
  6. Use gate_api.EarnApi for Earn products

    master

    The EarnApi class provides access to various Gate.io Earn products, including ETH2 swaps, Dual Investment, and Structured Products. Most methods require apiv4 authentication (API Key and Secret).

    import gate_api
    
    configuration = gate_api.Configuration(
        host = "https://api.gateio.ws/api/v4",
        key = "YOU_API_KEY",
        secret = "YOUR_API_SECRET"
    )
    api_client = gate_api.ApiClient(configuration)
    api_instance = gate_api.EarnApi(api_client)
  7. Understand the SubAccountMarginBalance model

    master

    The SubAccountMarginBalance model represents the margin account balances for a specific sub-account. It contains the user's unique identifier and a list of margin account details.

    Properties

    NameTypeDescriptionNotes
    uidstrUser ID[optional]
    availablelist[MarginAccount]Margin account balances[optional]

    Note that the available field returns a list of MarginAccount objects, which provide granular details about each specific margin account balance.

  8. Use the UnifiedDiscount model

    master

    The UnifiedDiscount model represents a unified account tiered discount. It is used to define the discount structure for a specific currency.

    It contains the following properties:

    • currency (str, optional): The name of the currency.
    • discount_tiers (list[UnifiedDiscountTiers], optional): A list of tiered discount configurations. Refer to the UnifiedDiscountTiers model for detailed tier specifications.
  9. Adjust collateral using CollateralAdjust

    master

    The CollateralAdjust model is used to manage collateral operations for an order. It supports two types of operations:

    • append: Adds collateral to the order.
    • redeem: Withdraws (redeems) collateral from the order.

    Properties

    NameTypeDescription
    order_idintThe unique identifier for the order.
    typestrThe operation type: append or redeem.
    collateralslist[CollateralCurrency]A list of collateral currency objects. (Optional)
  10. Use the UnifiedBorrowable1 model for batch querying maximum borrowable results

    master

    The UnifiedBorrowable1 model is used when performing batch queries for unified account maximum borrowable results. It allows you to specify specific currency details and amounts to filter or define the scope of the borrowable amount query.

    Properties

    NameTypeDescriptionNotes
    currencystrCurrency detail[optional]
    amountstrMaximum borrowable amount[optional]