Class: Bitget::V2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/Bitget/V2/Client.rb

Direct Known Subclasses

Client

Constant Summary collapse

API_HOST =
'api.bitget.com'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



1806
1807
1808
# File 'lib/Bitget/V2/Client.rb', line 1806

def api_key
  @api_key
end

#api_passphraseObject

Returns the value of attribute api_passphrase.



1806
1807
1808
# File 'lib/Bitget/V2/Client.rb', line 1806

def api_passphrase
  @api_passphrase
end

#api_secretObject

Returns the value of attribute api_secret.



1806
1807
1808
# File 'lib/Bitget/V2/Client.rb', line 1806

def api_secret
  @api_secret
end

#debugObject

Returns the value of attribute debug.



1806
1807
1808
# File 'lib/Bitget/V2/Client.rb', line 1806

def debug
  @debug
end

#loggerObject

Returns the value of attribute logger.



1806
1807
1808
# File 'lib/Bitget/V2/Client.rb', line 1806

def logger
  @logger
end

Class Method Details

.path_prefixObject



22
23
24
# File 'lib/Bitget/V2/Client.rb', line 22

def path_prefix
  '/api/v2'
end

Instance Method Details

#spot_account_assets(coin: nil, asset_type: nil) ⇒ Hash

Get Account Assets GET /api/v2/spot/account/assets

Frequency limit: 10 times/1s (User ID) Note: This endpoint retrieves detailed balance information for all assets in the spot account

Parameters:

  • coin (String) (defaults to: nil)

    Optional. Cryptocurrency code e.g. 'BTC'

  • asset_type (String) (defaults to: nil)

    Optional. Type of asset

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] List of account assets with the following fields:
      • coin [String] The coin symbol
      • available [String] Available balance
      • limitAvailable [String] Limit available balance
      • frozen [String] Frozen balance
      • locked [String] Locked balance
      • uTime [String] Last update time in Unix milliseconds


1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
# File 'lib/Bitget/V2/Client.rb', line 1157

def (coin: nil, asset_type: nil)
  response = get(
    path: '/spot/account/assets',
    args: {
      coin: coin,
      assetType: asset_type,
    }
  )
  handle_response(response)
end

#spot_account_bills(coin: nil, group_type: nil, business_type: nil, start_time: nil, end_time: nil, limit: nil, id_less_than: nil) ⇒ Hash

Get Account Bills GET /api/v2/spot/account/bills

Frequency limit: 10 times/1s (User ID) Note: This endpoint retrieves the account's transaction history including deposits, withdrawals, trades, etc.

Parameters:

  • coin (String) (defaults to: nil)

    Optional coin name

  • group_type (String) (defaults to: nil)

    Optional group type (e.g., 'transaction', 'withdraw', 'transfer', 'other')

  • business_type (String) (defaults to: nil)

    Optional business type (e.g., 'ORDER_DEALT_FROZEN_OUT', 'ORDER_DEALT_IN', 'WITHDRAW', 'TRANSFER_IN')

  • start_time (Integer) (defaults to: nil)

    Optional start time

  • end_time (Integer) (defaults to: nil)

    Optional end time

  • limit (Integer) (defaults to: nil)

    Optional limit

  • id_less_than (Integer) (defaults to: nil)

    Optional filter for records with ID less than this value

Returns:

  • (Hash)

    Response hash

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Array] List of bills
      • cTime [String] Creation timestamp in Unix milliseconds
      • coin [String] Currency name
      • groupType [String] Group type (e.g., 'transaction', 'withdraw', 'transfer', 'other')
      • businessType [String] Business type (e.g., 'ORDER_DEALT_FROZEN_OUT', 'ORDER_DEALT_IN', 'WITHDRAW', 'TRANSFER_IN')
      • size [String] Transaction size/amount
      • balance [String] Account balance after transaction
      • fees [String] Transaction fees
      • billId [String] Bill ID
      • bizOrderId [String] Business order ID


1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
# File 'lib/Bitget/V2/Client.rb', line 1259

def (coin: nil, group_type: nil, business_type: nil, start_time: nil, end_time: nil, limit: nil, id_less_than: nil)
  response = get(
    path: '/spot/account/bills',
    args: {
      coin: coin,
      groupType: group_type,
      businessType: business_type,
      startTime: start_time,
      endTime: end_time,
      limit: limit,
      idLessThan: id_less_than,
    }
  )
  handle_response(response)
end

#spot_account_deduct_infoHash

Get BGB Deduct Info GET /api/v2/spot/account/deduct-info

Rate limit: 5 req/sec/UID Note: This endpoint retrieves the current BGB fee deduction settings

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Hash] Response data
      • deduct [String] Current BGB fee deduction status ('on' or 'off')


1647
1648
1649
1650
# File 'lib/Bitget/V2/Client.rb', line 1647

def 
  response = get(path: '/spot/account/deduct-info')
  handle_response(response)
end

#spot_account_infoHash

Get Account Information GET /api/v2/spot/account/info

Frequency limit: 1 time/1s (User ID) Note: This endpoint retrieves basic information about the user's spot account

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Account information containing:
      • userId [String] User ID
      • inviterId [String, nil] Inviter's ID if any
      • channelCode [String] Channel code
      • channel [String] Channel name
      • ips [String] IP addresses
      • authorities [Array] List of user authorities
      • parentId [Integer] Parent account ID
      • traderType [String] Trader type
      • regisTime [String] Registration time in milliseconds


1133
1134
1135
1136
# File 'lib/Bitget/V2/Client.rb', line 1133

def 
  response = get(path: '/spot/account/info')
  handle_response(response)
end

#spot_account_sub_main_trans_record(coin: nil, role: nil, subaccount_user_id: nil, start_time: nil, end_time: nil, client_order_id: nil, limit: nil, id_less_than: nil) ⇒ Hash

Get MainSub Transfer Record GET /api/v2/spot/account/sub-main-trans-record

Rate limit: 20 req/sec/UID Note: This endpoint retrieves transfer records between main and sub-accounts

Parameters:

  • coin (String) (defaults to: nil)

    Optional. Cryptocurrency code e.g. 'BTC'

  • role (String) (defaults to: nil)

    Optional. Account role

  • subaccount_user_id (String) (defaults to: nil)

    Optional. Sub-account user ID

  • start_time (Integer) (defaults to: nil)

    Optional. Start time in Unix milliseconds

  • end_time (Integer) (defaults to: nil)

    Optional. End time in Unix milliseconds

  • client_order_id (String) (defaults to: nil)

    Optional. Client-supplied order ID

  • limit (Integer) (defaults to: nil)

    Optional. Number of results per request. Default: 100

  • id_less_than (String) (defaults to: nil)

    Optional. Filter records with ID less than this value

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Array] List of transfer records
      • coin [String] Cryptocurrency code
      • status [String] Transfer status. Valid values:
        • 'Successful': Successful
        • 'Failed': Failed
        • 'Processing': Processing
      • toType [String] Destination account type
      • fromType [String] Source account type
      • size [String] Transfer amount
      • ts [String] Timestamp in Unix milliseconds
      • clientOid [String] Client order ID
      • transferId [String] Transfer ID
      • fromUserId [String] Source account ID
      • toUserId [String] Target account ID


1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
# File 'lib/Bitget/V2/Client.rb', line 1478

def (coin: nil, role: nil, subaccount_user_id: nil, start_time: nil, end_time: nil, client_order_id: nil, limit: nil, id_less_than: nil)
  response = get(
    path: '/spot/account/sub-main-trans-record',
    args: {
      coin: coin,
      role: role,
      subUid: subaccount_user_id,
      startTime: start_time,
      endTime: end_time,
      clientOid: client_order_id,
      limit: limit,
      idLessThan: id_less_than,
    }
  )
  handle_response(response)
end

#spot_account_subaccount_assets(id_less_than: nil, limit: nil) ⇒ Hash

Get Sub-accounts Assets GET /api/v2/spot/account/subaccount-assets

Frequency limit: 10 times/1s (User ID) Note: This endpoint retrieves asset information for all sub-accounts Returns only sub-accounts which have assets > 0 Note: ND Brokers are not allowed to call this endpoint

Parameters:

  • id_less_than (String) (defaults to: nil)

    Optional.

  • limit (String) (defaults to: nil)

    Optional.

Returns:

  • (Hash)

    Response hash

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Array] List of assets
      • id [Integer] Sub-account ID
      • userId [Integer] User ID of the sub-account
      • assetsList [Array] List of assets
        • coin [String] Currency name
        • available [String] Available balance
        • limitAvailable [String] Limited available balance
        • frozen [String] Frozen balance
        • locked [String] Locked balance
        • uTime [String] Last update time in Unix milliseconds


1192
1193
1194
1195
1196
1197
1198
1199
1200
# File 'lib/Bitget/V2/Client.rb', line 1192

def (id_less_than: nil, limit: nil)
  response = get(path: '/spot/account/subaccount-assets',
    args: {
      idLessThan: id_less_than,
      limit: limit
    }
  )
  handle_response(response)
end

#spot_account_switch_deduct(deduct:) ⇒ Hash

Switch BGB Deduct POST /api/v2/spot/account/switch-deduct

Rate Limit: 1 req/sec/UID Note: This endpoint enables or disables BGB fee deduction for spot trading

Parameters:

  • deduct (String)

    Required. Whether to enable BGB fee deduction. Valid values:

    • 'on': Enable BGB fee deduction
    • 'off': Disable BGB fee deduction

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Hash] Response data
      • deduct [String] Current BGB fee deduction status ('on' or 'off')


1566
1567
1568
1569
# File 'lib/Bitget/V2/Client.rb', line 1566

def (deduct:)
  response = post(path: '/spot/account/switch-deduct', args: {deduct: deduct})
  handle_response(response)
end

#spot_account_transfer_records(coin: nil, from_type: nil, start_time: nil, end_time: nil, client_order_id: nil, page_number: nil, limit: nil, id_less_than: nil) ⇒ Hash

Get Transfer Record GET /api/v2/spot/account/transferRecords

Frequency limit: 20 times/1s (User ID) Note: This endpoint retrieves transfer records between different account types

Parameters:

  • coin (String) (defaults to: nil)

    Optional. Cryptocurrency code e.g. 'BTC'

  • from_type (String) (defaults to: nil)

    Optional. Source account type. Valid values:

    • 'spot': Spot account
    • 'p2p': P2P/funding account
    • 'coin_futures': Coin-M futures account
    • 'usdt_futures': USDT-M futures account
    • 'usdc_futures': USDC-M futures account
    • 'crossed_margin': Cross margin account
    • 'isolated_margin': Isolated margin account
  • start_time (Integer) (defaults to: nil)

    Optional. Start time in Unix milliseconds

  • end_time (Integer) (defaults to: nil)

    Optional. End time in Unix milliseconds

  • client_order_id (String) (defaults to: nil)

    Optional. Client-supplied order ID

  • page_number (Integer) (defaults to: nil)

    Optional. Page number for pagination

  • limit (Integer) (defaults to: nil)

    Optional. Number of results per request. Default: 100

  • id_less_than (String) (defaults to: nil)

    Optional. Filter records with ID less than this value

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Array] List of transfer records
      • coin [String] Cryptocurrency code
      • status [String] Transfer status. Valid values:
        • 'Successful': Successful
        • 'Failed': Failed
        • 'Processing': Processing
      • toType [String] Target account type
      • toSymbol [String] Target symbol
      • fromType [String] Source account type
      • fromSymbol [String] Source symbol
      • size [String] Transfer amount
      • ts [String] Timestamp in Unix milliseconds
      • clientOid [String] Client order ID
      • transferId [String] Transfer ID


1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
# File 'lib/Bitget/V2/Client.rb', line 1534

def (coin: nil, from_type: nil, start_time: nil, end_time: nil, client_order_id: nil, page_number: nil, limit: nil, id_less_than: nil)
  response = get(
    path: '/spot/account/transferRecords',
    args: {
      coin: coin,
      fromType: from_type,
      startTime: start_time,
      endTime: end_time,
      clientOid: client_order_id,
      pageNum: page_number,
      limit: limit,
      idLessThan: id_less_than,
    }
  )
  handle_response(response)
end

#spot_market_candles(symbol:, granularity:, start_time: nil, end_time: nil, limit: nil) ⇒ Hash

Get Candlestick Data GET /api/v2/spot/market/candles

Rate Limit: 20 times/1s (IP) Note: This endpoint retrieves candlestick/kline data for a trading pair

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. BTCUSDT

  • granularity (String)

    Required. Time interval for candles Common values: '1min', '5min', '15min', '30min', '1h', '4h', '6h', '12h', '1d', '1w'

  • start_time (Integer) (defaults to: nil)

    Optional. Start time in Unix milliseconds e.g. 1659076670000

  • end_time (Integer) (defaults to: nil)

    Optional. End time in Unix milliseconds e.g. 1659080270000

  • limit (Integer) (defaults to: nil)

    Optional. Number of candles to return (default: 100)

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of candles, each array containing:
      • [0] [String] Timestamp in milliseconds
      • [1] [String] Opening price
      • [2] [String] Highest price
      • [3] [String] Lowest price
      • [4] [String] Closing price
      • [5] [String] Volume
      • [6] [String] Quote currency volume
      • [7] [String] Quote currency volume (duplicate)


250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/Bitget/V2/Client.rb', line 250

def spot_market_candles(symbol:, granularity:, start_time: nil, end_time: nil, limit: nil)
  response = get(
    path: '/spot/market/candles',
    args: {
      symbol: symbol,
      granularity: granularity,
      startTime: start_time,
      endTime: end_time,
      limit: limit,
    }
  )
  handle_response(response)
end

#spot_market_fills(symbol:, limit: nil) ⇒ Hash

Get Recent Trades GET /api/v2/spot/market/fills

Rate Limit: 10 times/1s (IP) Note: This endpoint retrieves recent trades for a trading pair

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. BTCUSDT

  • limit (Integer) (defaults to: nil)

    Optional. Number of trades to return (default: 100)

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of trades, each with:
      • symbol [String] Trading pair name
      • tradeId [String] Trade ID
      • side [String] Trade side ('buy' or 'sell')
      • price [String] Trade price
      • size [String] Trade size
      • ts [String] Timestamp in milliseconds


320
321
322
323
# File 'lib/Bitget/V2/Client.rb', line 320

def spot_market_fills(symbol:, limit: nil)
  response = get(path: '/spot/market/fills', args: {symbol: symbol, limit: limit})
  handle_response(response)
end

#spot_market_fills_history(symbol:, limit: nil, id_less_than: nil, start_time: nil, end_time: nil) ⇒ Hash

Get Market Trades GET /api/v2/spot/market/fills-history

Rate Limit: 10 req/sec/IP Note: This endpoint retrieves historical trades for a trading pair

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. BTCUSDT

  • limit (Integer) (defaults to: nil)

    Optional. Number of trades to return (default: 100)

  • id_less_than (String) (defaults to: nil)

    Optional. Return trades with ID less than this value

  • start_time (Integer) (defaults to: nil)

    Optional. Start time in Unix milliseconds

  • end_time (Integer) (defaults to: nil)

    Optional. End time in Unix milliseconds

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of trades, each with:
      • symbol [String] Trading pair name
      • tradeId [String] Trade ID
      • side [String] Trade side ('Buy' or 'Sell')
      • price [String] Trade price
      • size [String] Trade size
      • ts [String] Timestamp in milliseconds


347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/Bitget/V2/Client.rb', line 347

def spot_market_fills_history(symbol:, limit: nil, id_less_than: nil, start_time: nil, end_time: nil)
  response = get(
    path: '/spot/market/fills-history',
    args: {
      symbol: symbol,
      limit: limit,
      idLessThan: id_less_than,
      startTime: start_time,
      endTime: end_time,
    }
  )
  handle_response(response)
end

#spot_market_history_candles(symbol:, granularity:, end_time:, limit: nil) ⇒ Hash

Get History Candlestick Data GET /api/v2/spot/market/history-candles

Rate Limit: 20 times/1s (IP) Note: This endpoint retrieves historical candlestick/kline data for a trading pair

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. BTCUSDT

  • granularity (String)

    Required. Time interval for candles Common values: '1min', '5min', '15min', '30min', '1h', '4h', '6h', '12h', '1d', '1w'

  • end_time (Integer)

    Required. End time in Unix milliseconds e.g. 1659080270000

  • limit (Integer) (defaults to: nil)

    Optional. Number of candles to return (default: 100)

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of candles, each array containing:
      • [0] [String] Timestamp in milliseconds
      • [1] [String] Opening price
      • [2] [String] Highest price
      • [3] [String] Lowest price
      • [4] [String] Closing price
      • [5] [String] Volume
      • [6] [String] Quote currency volume
      • [7] [String] Quote currency volume (duplicate)


288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/Bitget/V2/Client.rb', line 288

def spot_market_history_candles(symbol:, granularity:, end_time:, limit: nil)
  response = get(
    path: '/spot/market/history-candles',
    args: {
      symbol: symbol,
      granularity: granularity,
      endTime: end_time,
      limit: limit,
    }
  )
  handle_response(response)
end

#spot_market_merge_depth(symbol:, precision: nil, limit: nil) ⇒ Hash

Get Merge Depth GET /api/v2/spot/market/merge-depth

Rate Limit: 20 times/1s (IP) Note: This endpoint retrieves the merged order book depth for a trading pair

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. BTCUSDT

  • precision (String) (defaults to: nil)

    Optional. Price aggregation level (default: scale0)

    • scale0: No merge
    • scale1: Merge by quotation accuracy 10
    • scale2: Merge by quotation accuracy 100 Note: Some pairs may not support all scales. Requests for unavailable scales will use the maximum available scale for that pair.
  • limit (Integer) (defaults to: nil)

    Optional. Number of bids and asks to return

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order book data containing:
      • asks [Array] Array of ask orders [price, size]
      • bids [Array] Array of bid orders [price, size]
      • ts [String] Timestamp in milliseconds
      • scale [String] Price scale (e.g. '0.01')
      • precision [String] Price aggregation level used (e.g. 'scale0')
      • isMaxPrecision [String] Whether maximum precision is used ('YES'/'NO')


183
184
185
186
187
188
189
190
191
192
193
# File 'lib/Bitget/V2/Client.rb', line 183

def spot_market_merge_depth(symbol:, precision: nil, limit: nil)
  response = get(
    path: '/spot/market/merge-depth',
    args: {
      symbol: symbol,
      precision: precision,
      limit: limit,
    }
  )
  handle_response(response)
end

#spot_market_orderbook(symbol:, type: nil, limit: nil) ⇒ Hash

Get OrderBook Depth GET /api/v2/spot/market/orderbook

Rate Limit: 20 times/1s (IP) Note: This endpoint retrieves the order book depth for a trading pair

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. BTCUSDT

  • type (String) (defaults to: nil)

    Optional. Price aggregation level (default: step0) Values: step0, step1, step2, step3, step4, step5

  • limit (Integer) (defaults to: nil)

    Optional. Number of bids and asks to return (default: 100, max: 200)

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order book data containing:
      • asks [Array] Array of ask orders [price, size]
      • bids [Array] Array of bid orders [price, size]
      • ts [String] Timestamp in milliseconds


213
214
215
216
217
218
219
220
221
222
223
# File 'lib/Bitget/V2/Client.rb', line 213

def spot_market_orderbook(symbol:, type: nil, limit: nil)
  response = get(
    path: '/spot/market/orderbook',
    args: {
      symbol: symbol,
      type: type,
      limit: limit,
    }
  )
  handle_response(response)
end

#spot_market_tickers(symbol: nil) ⇒ Hash

Get Ticker Information GET /api/v2/spot/market/tickers

Rate Limit: 20 times/1s (IP) Note: This endpoint retrieves 24-hour trading information for trading pairs

Parameters:

  • symbol (String) (defaults to: nil)

    Optional. Filter by trading pair e.g. 'BTCUSDT'

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success, error description for failure)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of ticker information:
      • symbol [String] Trading pair name (e.g. 'BTCUSDT')
      • high24h [String] Highest price in last 24 hours (e.g. '37775.65')
      • open [String] Opening price (e.g. '35134.2')
      • low24h [String] Lowest price in last 24 hours (e.g. '34413.1')
      • lastPr [String] Latest price (e.g. '34413.1')
      • quoteVolume [String] Quote currency volume (e.g. '0')
      • baseVolume [String] Base currency volume (e.g. '0')
      • usdtVolume [String] Volume in USDT equivalent (e.g. '0')
      • bidPr [String] Best bid price (e.g. '0')
      • askPr [String] Best ask price (e.g. '0')
      • bidSz [String] Best bid size (e.g. '0.0663')
      • askSz [String] Best ask size (e.g. '0.0119')
      • openUtc [String] UTC opening price (e.g. '23856.72')
      • ts [String] Timestamp in milliseconds (e.g. '1625125755277')
      • changeUtc24h [String] 24h price change in UTC (e.g. '0.00301')
      • change24h [String] 24h price change (e.g. '0.00069')


153
154
155
156
# File 'lib/Bitget/V2/Client.rb', line 153

def spot_market_tickers(symbol: nil)
  response = get(path: '/spot/market/tickers', args: {symbol: symbol})
  handle_response(response)
end

#spot_market_vip_fee_rateHash

Get VIP Fee Rate GET /api/v2/spot/market/vip-fee-rate

Rate Limit: 10 times/1s (IP) Note: This endpoint retrieves the current VIP fee rates for the user

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success, error description for failure)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of VIP level information:
      • level [Integer] VIP level (e.g. 1)
      • dealAmount [String] Trading volume requirement (e.g. '1000000')
      • assetAmount [String] Asset requirement (e.g. '50000')
      • takerFeeRate [String] Taker fee rate (e.g. '0')
      • makerFeeRate [String] Maker fee rate (e.g. '0')
      • btcWithdrawAmount [String] BTC withdrawal limit (e.g. '300')
      • usdtWithdrawAmount [String] USDT withdrawal limit (e.g. '5000000')


120
121
122
123
# File 'lib/Bitget/V2/Client.rb', line 120

def spot_market_vip_fee_rate
  response = get(path: '/spot/market/vip-fee-rate')
  handle_response(response)
end

#spot_public_coins(coin: nil) ⇒ Hash

Get Coin Info GET /api/v2/spot/public/coins

Rate Limit: 3 times/1s (IP) Note: This endpoint retrieves information about supported cryptocurrencies

Parameters:

  • coin (String) (defaults to: nil)

    Optional. Filter by cryptocurrency code e.g. 'BTC', 'USDT'

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success, error description for failure)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of coin information:
      • coinId [String] Internal coin ID (e.g. '1' for BTC)
      • coin [String] Cryptocurrency code (e.g. 'BTC', 'USDT')
      • transfer [String] Whether transfers are enabled ('true'/'false')
      • areaCoin [String] Area coin status ('yes'/'no') - Note: Not documented in official API
      • chains [Array] List of supported blockchain networks:
        • chain [String] Blockchain network name (e.g. 'BTC', 'BEP20', 'LIGHTNING')
        • needTag [String] Whether memo/tag is required ('true'/'false')
        • withdrawable [String] Whether withdrawals are enabled ('true'/'false')
        • rechargeable [String] Whether deposits are enabled ('true'/'false')
        • withdrawFee [String] Base withdrawal fee (e.g. '0.005')
        • extraWithdrawFee [String] Additional withdrawal fee (e.g. '0')
        • depositConfirm [String] Required confirmations for deposit (e.g. '1')
        • withdrawConfirm [String] Required confirmations for withdrawal (e.g. '1', '5', '15')
        • minDepositAmount [String] Minimum deposit amount (e.g. '0.00001')
        • minWithdrawAmount [String] Minimum withdrawal amount (e.g. '0.0005')
        • browserUrl [String] Block explorer URL (e.g. 'https://www.blockchain.com/explorer/transactions/btc/')
        • contractAddress [String] Token contract address if applicable (e.g. '0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c')
        • withdrawStep [String] Withdrawal step (e.g. '0')
        • withdrawMinScale [String] Withdrawal amount precision (e.g. '8')
        • congestion [String] Network congestion status ('normal'/'congested')


62
63
64
65
# File 'lib/Bitget/V2/Client.rb', line 62

def spot_public_coins(coin: nil)
  response = get(path: '/spot/public/coins', args: {coin: coin})
  handle_response(response)
end

#spot_public_symbols(symbol: nil) ⇒ Hash

Get Symbol Info GET /api/v2/spot/public/symbols

Rate Limit: 20 times/1s (IP) Note: This endpoint retrieves information about supported trading pairs

Parameters:

  • symbol (String) (defaults to: nil)

    Optional. Filter by trading pair e.g. 'BTCUSDT'

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success, error description for failure)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of symbol information:
      • symbol [String] Trading pair name (e.g. 'BTCUSDT')
      • baseCoin [String] Base currency code (e.g. 'BTC')
      • quoteCoin [String] Quote currency code (e.g. 'USDT')
      • minTradeAmount [String] Minimum trade amount (e.g. '0')
      • maxTradeAmount [String] Maximum trade amount (e.g. '900000000000000000000')
      • takerFeeRate [String] Taker fee rate (e.g. '0.002')
      • makerFeeRate [String] Maker fee rate (e.g. '0.002')
      • pricePrecision [String] Price precision (decimal places) (e.g. '2')
      • quantityPrecision [String] Quantity precision (decimal places) (e.g. '6')
      • quotePrecision [String] Quote precision (decimal places) (e.g. '8')
      • status [String] Trading pair status (e.g. 'online')
      • minTradeUSDT [String] Minimum trade amount in USDT (e.g. '1')
      • buyLimitPriceRatio [String] Maximum buy price ratio (e.g. '0.05')
      • sellLimitPriceRatio [String] Maximum sell price ratio (e.g. '0.05')
      • areaSymbol [String] Area symbol status ('yes'/'no')
      • orderQuantity [String] Maximum order quantity (e.g. '200')
      • openTime [String] Trading pair open time in milliseconds (e.g. '1532454360000')
      • offTime [String] Trading pair off time in milliseconds (empty if active)


97
98
99
100
# File 'lib/Bitget/V2/Client.rb', line 97

def spot_public_symbols(symbol: nil)
  response = get(path: '/spot/public/symbols', args: {symbol: symbol})
  handle_response(response)
end

#spot_trade_batch_cancel_order(symbol: nil, batch_mode: nil, order_list:) ⇒ Hash

Batch Cancel Orders POST /api/v2/spot/trade/batch-cancel-order

Frequency limit:10 times/1s (UID) Note: This endpoint cancels multiple orders in a single request

Parameters:

  • symbol (String) (defaults to: nil)

    Optional. Trading pair name for single currency mode

  • batch_mode (String) (defaults to: nil)

    Optional. Batch mode type: 'single' (default) or 'multiple'

    • single: single currency mode (symbol in orderList will be ignored)
    • multiple: cross-currency mode
  • order_list (Array<Hash>)

    Required. Collection of orders to cancel Each order hash must contain:

    • symbol: [String] Required. Trading pair name e.g. BTCUSDT
    • orderId: [String] Optional. Order ID (either orderId or clientOid required)
    • clientOid: [String] Optional. Client Order ID (either orderId or clientOid required) Example order hash: { symbol: 'BTCUSDT', orderId: '123456', clientOid: 'my_order_1' }

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • message [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order results:
      • successList [Array] Successfully cancelled orders:
        • orderId [String] Order ID
        • clientOid [String] Client order ID if provided
      • failureList [Array] Failed orders (if any):
        • orderId [String] Order ID
        • clientOid [String] Client order ID if provided
        • errorMsg [String] Error message explaining the failure


644
645
646
647
648
649
650
651
652
653
654
# File 'lib/Bitget/V2/Client.rb', line 644

def spot_trade_batch_cancel_order(symbol: nil, batch_mode: nil, order_list:)
  response = post(
    path: '/spot/trade/batch-cancel-order',
    args: {
      symbol: symbol,
      batchMode: batch_mode,
      orderList: order_list,
    }
  )
  handle_response(response)
end

#spot_trade_batch_cancel_plan_order(symbol_list:) ⇒ Hash

Cancel Plan Orders in Batch POST /api/v2/spot/trade/batch-cancel-plan-order

Rate limit: 5 req/sec/UID Note: This endpoint cancels all trigger/plan orders for the specified trading pairs

Parameters:

  • symbol_list (Array<String>)

    Required. List of trading pair names e.g. ['BTCUSDT', 'ETHUSDT']

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Cancellation results containing:
      • successList [Array] List of successfully cancelled order IDs
      • failureList [Array] List of failed order IDs


1103
1104
1105
1106
1107
1108
1109
# File 'lib/Bitget/V2/Client.rb', line 1103

def spot_trade_batch_cancel_plan_order(symbol_list:)
  response = post(
    path: '/spot/trade/batch-cancel-plan-order',
    args: {symbolList: symbol_list}
  )
  handle_response(response)
end

#spot_trade_batch_cancel_replace_order(order_list:) ⇒ Hash

Batch Cancel Existing Order and Send New Orders POST /api/v2/spot/trade/batch-cancel-replace-order

Rate Limit: 5 requests/second/UID Note: This endpoint cancels multiple existing orders and places new ones atomically

Parameters:

  • order_list (Array<Hash>)

    Collection of orders to place (max 50) Each order hash must contain:

    • symbol: [String] Required. Trading pair name e.g. BTCUSDT
    • price: [String] Required. Limit price
    • size: [String] Required. Order size
    • clientOid: [String] Optional. Client Order ID
    • orderId: [String] Optional. Order ID to cancel (either orderId or clientOid required)
    • newClientOid: [String] Optional. New client order ID for the replacement order Example order hash: { symbol: 'BTCUSDT', price: '25000.1', size: '0.01', orderId: '123456', newClientOid: 'my_new_order_1' }

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of order results, each containing:
      • orderId [String] Order ID
      • clientOid [String] Client order ID if provided
      • success [String] Operation result ('success' or 'failure')
      • msg [String] Additional message about the operation


526
527
528
529
# File 'lib/Bitget/V2/Client.rb', line 526

def spot_trade_batch_cancel_replace_order(order_list:)
  response = post(path: '/spot/trade/batch-cancel-replace-order', args: {orderList: order_list})
  handle_response(response)
end

#spot_trade_batch_orders(symbol: nil, batch_mode: nil, order_list:) ⇒ Hash

Batch Place Orders POST /api/v2/spot/trade/batch-orders

Rate limit: Frequency limit: 5 times/1s (UID)Trader frequency limit: 1 times/1s (UID) Note: This endpoint places multiple orders in a single request

Parameters:

  • symbol (String) (defaults to: nil)

    Optional. Trading pair name e.g. 'BTCUSDT'

  • batch_mode (String) (defaults to: nil)

    Optional. Batch mode type:

    • single: Single currency mode (symbol in orderList will be ignored)
    • multiple: Cross-currency mode
  • order_list (Array<Hash>)

    Collection of orders to place (max 50) Each order hash must contain:

    • side: [String] Required. Order direction ('buy' or 'sell')
    • orderType: [String] Required. Order type ('limit', 'market', 'post_only', 'fok', 'ioc')
    • force: [String] Required. Time in force ('gtc', 'ioc', 'fok', 'post_only')
    • price: [String] Required for limit orders. Order price
    • size: [String] Required. Order size
    • clientOid: [String] Optional. Client order ID
    • symbol: [String] Required if batch_mode is 'multiple'. Trading pair Example order hash: { side: 'buy', orderType: 'limit', force: 'normal', price: '25000.1', size: '0.01', clientOid: 'my_order_1' }

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order results:
      • successList [Array] Successfully placed orders:
        • orderId [String] Order ID
        • clientOid [String] Client order ID if provided
      • failureList [Array] Failed orders (if any)


599
600
601
602
603
604
605
606
607
608
609
# File 'lib/Bitget/V2/Client.rb', line 599

def spot_trade_batch_orders(symbol: nil, batch_mode: nil, order_list:)
  response = post(
    path: '/spot/trade/batch-orders',
    args: {
      symbol: symbol,
      batchMode: batch_mode,
      orderList: order_list,
    }
  )
  handle_response(response)
end

#spot_trade_cancel_order(symbol:, tpsl_type: nil, order_id: nil, client_order_id: nil) ⇒ Hash

Cancel Order POST /api/v2/spot/trade/cancel-order

Frequency limit:10 times/1s (UID) Note: This endpoint cancels an existing order

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. 'BTCUSDT'

  • tpsl_type (String) (defaults to: nil)

    Optional. Take profit/stop loss type: 'normal' or 'tpsl'

  • order_id (String) (defaults to: nil)

    Optional. Order ID to cancel

  • client_order_id (String) (defaults to: nil)

    Optional. Client order ID to cancel Note: Either order_id or client_order_id must be provided

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • message [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order details:
      • orderId [String] Order ID
      • clientOid [String] Client order ID if provided


549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/Bitget/V2/Client.rb', line 549

def spot_trade_cancel_order(symbol:, tpsl_type: nil, order_id: nil, client_order_id: nil)
  response = post(
    path: '/spot/trade/cancel-order',
    args: {
      symbol: symbol,
      tpslType: tpsl_type,
      orderId: order_id,
      clientOid: client_order_id,
    }
  )
  handle_response(response)
end

#spot_trade_cancel_plan_order(order_id:) ⇒ Hash

Cancel Plan Order POST /api/v2/spot/trade/cancel-plan-order

Frequency limit: 20 times/1s (UID) Note: This endpoint cancels an existing trigger/plan order

Parameters:

  • order_id (String)

    Required. Plan order ID to cancel

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Cancellation result containing:
      • result [String] Cancellation result ('success' if successful)


977
978
979
980
981
982
983
# File 'lib/Bitget/V2/Client.rb', line 977

def spot_trade_cancel_plan_order(order_id:)
  response = post(
    path: '/spot/trade/cancel-plan-order',
    args: {orderId: order_id}
  )
  handle_response(response)
end

#spot_trade_cancel_replace_order(symbol:, price:, size:, client_order_id: nil, order_id: nil, new_client_order_id: nil, preset_take_profit_price: nil, execute_take_profit_price: nil, preset_stop_loss_price: nil, execute_stop_loss_price: nil) ⇒ Hash

Cancel an Existing Order and Send a New Order POST /api/v2/spot/trade/cancel-replace-order

Rate Limit: Rate limit: 5 requests/second/UID Note: This endpoint cancels an existing order and places a new one atomically

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. 'BTCUSDT'

  • price (String)

    Required. Price for the new order

  • size (String)

    Required. Size for the new order

  • client_order_id (String) (defaults to: nil)

    Optional. Client order ID of the order to cancel

  • order_id (String) (defaults to: nil)

    Optional. Order ID of the order to cancel Note: Either client_order_id or order_id must be provided

  • new_client_order_id (String) (defaults to: nil)

    Optional. Client order ID for the new order

  • preset_take_profit_price (String) (defaults to: nil)

    Optional. Preset take profit price

  • execute_take_profit_price (String) (defaults to: nil)

    Optional. Execute take profit price

  • preset_stop_loss_price (String) (defaults to: nil)

    Optional. Preset stop loss price

  • execute_stop_loss_price (String) (defaults to: nil)

    Optional. Execute stop loss price

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order details:
      • orderId [String] Order ID
      • clientOid [String] Client order ID if provided
      • success [String] Operation result ('success' or 'failure')
      • msg [String] Additional message about the operation


465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/Bitget/V2/Client.rb', line 465

def spot_trade_cancel_replace_order(
  symbol:,
  price:,
  size:,
  client_order_id: nil,
  order_id: nil,
  new_client_order_id: nil,
  preset_take_profit_price: nil,
  execute_take_profit_price: nil,
  preset_stop_loss_price: nil,
  execute_stop_loss_price: nil
)
  response = post(
    path: '/spot/trade/cancel-replace-order',
    args: {
      symbol: symbol,
      price: price,
      size: size,
      clientOid: client_order_id,
      orderId: order_id,
      newClientOid: new_client_order_id,
      presetTakeProfitPrice: preset_take_profit_price,
      executeTakeProfitPrice: execute_take_profit_price,
      presetStopLossPrice: preset_stop_loss_price,
      executeStopLossPrice: execute_stop_loss_price,
    }
  )
  handle_response(response)
end

#spot_trade_cancel_symbol_order(symbol:) ⇒ Hash

Cancel Order by Symbol POST /api/v2/spot/trade/cancel-symbol-order

Rate Limit: Frequency limit: 5 times/1s (UID) Note: This endpoint cancels all orders for a specific trading pair

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. 'BTCUSDT'

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Cancellation details:
      • symbol [String] Trading pair name
      • canceledList [Array] List of cancelled orders
      • failedList [Array] List of failed orders


671
672
673
674
# File 'lib/Bitget/V2/Client.rb', line 671

def spot_trade_cancel_symbol_order(symbol:)
  response = post(path: '/spot/trade/cancel-symbol-order', args: {symbol: symbol})
  handle_response(response)
end

#spot_trade_current_plan_order(symbol:, order_type: nil, side: nil, start_time: nil, end_time: nil, limit: nil) ⇒ Hash

Get Current Plan Orders GET /api/v2/spot/trade/current-plan-order

Frequency limit: 20 times/1s (UID) Note: This endpoint retrieves all active trigger/plan orders

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. 'BTCUSDT'

  • order_type (String) (defaults to: nil)

    Optional. Order type: 'limit' or 'market'

  • side (String) (defaults to: nil)

    Optional. Order direction: 'buy' or 'sell'

  • start_time (Integer) (defaults to: nil)

    Optional. Start time in Unix milliseconds

  • end_time (Integer) (defaults to: nil)

    Optional. End time in Unix milliseconds

  • limit (Integer) (defaults to: nil)

    Optional. Number of results per request. Maximum 100. Default 100

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order list details containing:
      • nextFlag [Boolean] Whether there are more orders to fetch
      • idLessThan [String] ID to use for pagination
      • orderList [Array] List of plan orders


1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
# File 'lib/Bitget/V2/Client.rb', line 1005

def spot_trade_current_plan_order(symbol:, order_type: nil, side: nil, start_time: nil, end_time: nil, limit: nil)
  response = get(
    path: '/spot/trade/current-plan-order',
    args: {
      symbol: symbol,
      orderType: order_type,
      side: side,
      startTime: start_time,
      endTime: end_time,
      limit: limit,
    }
  )
  handle_response(response)
end

#spot_trade_fills(symbol: nil, order_id: nil, start_time: nil, end_time: nil, limit: nil, id_less_than: nil) ⇒ Hash

Get Fills GET /api/v2/spot/trade/fills

Frequency limit:10 times/1s (UID) Note: This endpoint retrieves trade execution details for orders

Parameters:

  • symbol (String) (defaults to: nil)

    Optional. Trading pair name e.g. 'BTCUSDT'

  • order_id (String) (defaults to: nil)

    Optional. Filter by order ID

  • start_time (Integer) (defaults to: nil)

    Optional. Start timestamp in milliseconds

  • end_time (Integer) (defaults to: nil)

    Optional. End timestamp in milliseconds

  • limit (Integer) (defaults to: nil)

    Optional. Number of results per request. Maximum 100. Default 100

  • id_less_than (String) (defaults to: nil)

    Optional. Pagination of data to return records earlier than the requested fillId

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of fills, each containing:
      • userId [String] User ID
      • symbol [String] Trading pair
      • orderId [String] Order ID
      • tradeId [String] Trade ID
      • orderType [String] Order type
      • side [String] Trade side ('buy' or 'sell')
      • priceAvg [String] Average fill price
      • size [String] Fill size
      • amount [String] Fill amount
      • feeDetail [Hash] Fee details:
        • deduction [String] Fee deduction type
        • feeCoin [String] Fee currency
        • totalDeductionFee [String] Total deduction fee
        • totalFee [String] Total fee
      • tradeScope [String] Trade scope (e.g. 'taker')
      • cTime [String] Creation time
      • uTime [String] Update time


873
874
875
876
877
878
879
880
881
882
883
884
885
886
# File 'lib/Bitget/V2/Client.rb', line 873

def spot_trade_fills(symbol: nil, order_id: nil, start_time: nil, end_time: nil, limit: nil, id_less_than: nil)
  response = get(
    path: '/spot/trade/fills',
    args: {
      symbol: symbol,
      orderId: order_id,
      startTime: start_time,
      endTime: end_time,
      limit: limit,
      idLessThan: id_less_than,
    }
  )
  handle_response(response)
end

#spot_trade_history_orders(symbol: nil, start_time: nil, end_time: nil, id_less_than: nil, limit: nil, order_id: nil, tpsl_type: nil, request_time: nil, receive_window: nil) ⇒ Hash

Get History Orders GET /api/v2/spot/trade/history-orders

Frequency limit: 20 times/1s (UID) Note: This endpoint retrieves historical orders (filled, cancelled, etc.)

Parameters:

  • symbol (String) (defaults to: nil)

    Optional. Trading pair name e.g. 'BTCUSDT'

  • start_time (Integer) (defaults to: nil)

    Optional. Start timestamp in milliseconds

  • end_time (Integer) (defaults to: nil)

    Optional. End timestamp in milliseconds

  • id_less_than (String) (defaults to: nil)

    Optional. Pagination of data to return records earlier than the requested orderId

  • limit (Integer) (defaults to: nil)

    Optional. Number of results per request. Maximum 100. Default 100

  • order_id (String) (defaults to: nil)

    Optional. Filter by order ID

  • tpsl_type (String) (defaults to: nil)

    Optional. Take profit/stop loss type: 'normal' or 'tpsl'

  • request_time (Integer) (defaults to: nil)

    Optional. Current timestamp in milliseconds

  • receive_window (Integer) (defaults to: nil)

    Optional. The value cannot be greater than 60000

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • message [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of historical orders, each containing:
      • userId [String] User ID
      • symbol [String] Trading pair
      • orderId [String] Order ID
      • clientOid [String] Client order ID if provided
      • price [String] Order price
      • size [String] Order size
      • orderType [String] Order type
      • side [String] Order side ('buy' or 'sell')
      • status [String] Order status
      • priceAvg [String] Average fill price
      • baseVolume [String] Base asset volume
      • quoteVolume [String] Quote asset volume
      • enterPointSource [String] Entry point source
      • feeDetail [String] Fee details JSON string
      • orderSource [String] Order source
      • cTime [String] Creation time
      • uTime [String] Update time
      • tpslType [String] Take profit/stop loss type
      • cancelReason [String] Reason for cancellation if cancelled
      • triggerPrice [String] Trigger price


821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
# File 'lib/Bitget/V2/Client.rb', line 821

def spot_trade_history_orders(symbol: nil, start_time: nil, end_time: nil, id_less_than: nil, limit: nil, order_id: nil, tpsl_type: nil, request_time: nil, receive_window: nil)
  response = get(
    path: '/spot/trade/history-orders',
    args: {
      symbol: symbol,
      startTime: start_time,
      endTime: end_time,
      idLessThan: id_less_than,
      limit: limit,
      orderId: order_id,
      tpslType: tpsl_type,
      requestTime: request_time,
      receiveWindow: receive_window,
    }
  )
  handle_response(response)
end

#spot_trade_history_plan_order(symbol:, start_time:, end_time:, limit: nil) ⇒ Hash

Get History Plan Orders GET /api/v2/spot/trade/history-plan-order

Frequency limit: 20 times/1s (UID) Note: This endpoint retrieves historical trigger/plan orders (executed, cancelled, etc.)

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. 'BTCUSDT'

  • start_time (Integer)

    Required. Start time in Unix milliseconds

  • end_time (Integer)

    Required. End time in Unix milliseconds

  • limit (Integer) (defaults to: nil)

    Optional. Number of results per request. Maximum 100. Default 100

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order list details containing:
      • nextFlag [Boolean] Whether there are more orders to fetch
      • idLessThan [String] ID to use for pagination
      • orderList [Array] List of historical orders, each containing:
        • orderId [String] Plan order ID
        • clientOid [String] Client order ID if provided
        • symbol [String] Trading pair
        • size [String] Order size
        • executePrice [String] Execution price
        • triggerPrice [String] Trigger price
        • status [String] Order status
        • orderType [String] Order type
        • side [String] Order side ('buy' or 'sell')
        • planType [String] Plan type
        • triggerType [String] Trigger type
        • enterPointSource [String] Entry point source
        • uTime [String] Update time
        • cTime [String] Creation time


1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
# File 'lib/Bitget/V2/Client.rb', line 1076

def spot_trade_history_plan_order(symbol:, start_time:, end_time:, limit: nil)
  response = get(
    path: '/spot/trade/history-plan-order',
    args: {
      symbol: symbol,
      startTime: start_time,
      endTime: end_time,
      limit: limit,
    }
  )
  handle_response(response)
end

#spot_trade_modify_plan_order(order_id:, trigger_price: nil, execute_price: nil, size: nil, order_type: nil) ⇒ Hash

Modify Plan Order POST /api/v2/spot/trade/modify-plan-order

Frequency limit: 20 times/1s (UID) Note: This endpoint modifies an existing trigger/plan order

Parameters:

  • order_id (String)

    Required. Order ID to modify

  • trigger_price (String) (defaults to: nil)

    Optional. New trigger price

  • execute_price (String) (defaults to: nil)

    Optional. New execution price

  • size (String) (defaults to: nil)

    Optional. New order quantity

  • order_type (String) (defaults to: nil)

    Optional. Order type: 'limit' or 'market'

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order details containing:
      • orderId [String] Plan order ID
      • clientOid [String] Client order ID if provided


950
951
952
953
954
955
956
957
958
959
960
961
962
# File 'lib/Bitget/V2/Client.rb', line 950

def spot_trade_modify_plan_order(order_id:, trigger_price: nil, execute_price: nil, size: nil, order_type: nil)
  response = post(
    path: '/spot/trade/modify-plan-order',
    args: {
      orderId: order_id,
      triggerPrice: trigger_price,
      executePrice: execute_price,
      size: size,
      orderType: order_type,
    }
  )
  handle_response(response)
end

#spot_trade_order_info(order_id: nil, client_order_id: nil, request_time: nil, receive_window: nil) ⇒ Hash

Get Order Info GET /api/v2/spot/trade/orderInfo

Frequency limit: 20 times/1s (UID) Note: This endpoint retrieves detailed information about a specific order

Parameters:

  • order_id (String) (defaults to: nil)

    Optional. Order ID to query

  • client_order_id (String) (defaults to: nil)

    Optional. Client order ID to query Note: Either order_id or client_order_id must be provided

  • request_time (Integer) (defaults to: nil)

    Optional. Current timestamp in milliseconds

  • receive_window (Integer) (defaults to: nil)

    Optional. The value cannot be greater than 60000

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of order details, each containing:
      • userId [String] User ID
      • symbol [String] Trading pair
      • orderId [String] Order ID
      • clientOid [String] Client order ID
      • price [String] Order price
      • size [String] Order size
      • orderType [String] Order type
      • side [String] Order side ('buy' or 'sell')
      • status [String] Order status
      • priceAvg [String] Average fill price
      • baseVolume [String] Base asset volume
      • quoteVolume [String] Quote asset volume
      • enterPointSource [String] Entry point source
      • feeDetail [String] Fee details JSON string
      • orderSource [String] Order source
      • cancelReason [String] Reason for cancellation if cancelled
      • cTime [String] Creation time
      • uTime [String] Update time


710
711
712
713
714
715
716
717
718
719
720
721
# File 'lib/Bitget/V2/Client.rb', line 710

def spot_trade_order_info(order_id: nil, client_order_id: nil, request_time: nil, receive_window: nil)
  response = get(
    path: '/spot/trade/orderInfo',
    args: {
      orderId: order_id,
      clientOid: client_order_id,
      requestTime: request_time,
      receiveWindow: receive_window,
    }
  )
  handle_response(response)
end

#spot_trade_place_order(symbol:, side:, order_type:, force:, price: nil, size:, client_order_id: nil, trigger_price: nil, tpsl_type: nil, request_time: nil, receive_window: nil, stp_mode: nil, preset_take_profit_price: nil, execute_take_profit_price: nil, preset_stop_loss_price: nil, execute_stop_loss_price: nil) ⇒ Hash

Place Order POST /api/v2/spot/trade/place-order

Rate limit: 10 requests/second/UID Rate limit: 1 request/second/UID for copy trading traders Note: This endpoint places a new order for spot trading

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. 'BTCUSDT'

  • side (String)

    Required. Order direction: 'buy' or 'sell'

  • order_type (String)

    Required. Order type:

    • limit: Limit order
    • market: Market order
  • size (String)

    Required. Order size

  • price (String) (defaults to: nil)

    Optional. Order price, required for limit orders

  • client_order_id (String) (defaults to: nil)

    Optional. Client-supplied order ID

  • force (String)

    Optional. Time in force:

    • gtc: Good till cancelled
    • fok: Fill or kill
    • ioc: Immediate or cancel
    • post_only: Post only
  • stp_mode (String) (defaults to: nil)

    Optional. Self-trade prevention mode

  • stp_id (String)

    Optional. Self-trade prevention ID

  • request_time (Integer) (defaults to: nil)

    Optional. Request timestamp in milliseconds

  • receive_window (Integer) (defaults to: nil)

    Optional. Number of milliseconds after request_time the request is valid for

  • execute_take_profit_price (String) (defaults to: nil)

    Optional. Execute take profit price

  • preset_stop_loss_price (String) (defaults to: nil)

    Optional. Preset stop loss price

  • execute_stop_loss_price (String) (defaults to: nil)

    Optional. Execute stop loss price

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order details:
      • orderId [String] Order ID
      • clientOid [String] Client order ID if provided


397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/Bitget/V2/Client.rb', line 397

def spot_trade_place_order(
  symbol:,
  side:,
  order_type:,
  force:,
  price: nil,
  size:,
  client_order_id: nil,
  trigger_price: nil,
  tpsl_type: nil,
  request_time: nil,
  receive_window: nil,
  stp_mode: nil,
  preset_take_profit_price: nil,
  execute_take_profit_price: nil,
  preset_stop_loss_price: nil,
  execute_stop_loss_price: nil
)
  response = post(
    path: '/spot/trade/place-order',
    args: {
      symbol: symbol,
      side: side,
      orderType: order_type,
      force: force,
      price: price,
      size: size,
      clientOid: client_order_id,
      triggerPrice: trigger_price,
      tpslType: tpsl_type,
      requestTime: request_time,
      receiveWindow: receive_window,
      stpMode: stp_mode,
      presetTakeProfitPrice: preset_take_profit_price,
      executeTakeProfitPrice: execute_take_profit_price,
      presetStopLossPrice: preset_stop_loss_price,
      executeStopLossPrice: execute_stop_loss_price,
    }
  )
  handle_response(response)
end

#spot_trade_place_plan_order(symbol:, side:, trigger_price:, order_type:, execute_price: nil, plan_type: nil, size: nil, trigger_type: nil, client_order_id: nil, stp_mode: nil) ⇒ Hash

Place Plan Order POST /api/v2/spot/trade/place-plan-order

Frequency limit: 20 times/1s (UID) Note: This endpoint places a trigger/plan order that executes when price conditions are met

Parameters:

  • symbol (String)

    Required. Trading pair name e.g. 'BTCUSDT'

  • side (String)

    Required. Order direction: 'buy' or 'sell'

  • trigger_price (String)

    Required. Price to trigger the order

  • order_type (String)

    Required. Order type: 'limit' or 'market'

  • execute_price (String) (defaults to: nil)

    Optional. Order execution price (required for limit orders)

  • plan_type (String) (defaults to: nil)

    Optional. Plan type: 'limit' or 'market'

  • size (String) (defaults to: nil)

    Required. Order quantity

  • trigger_type (String) (defaults to: nil)

    Optional. Trigger type: 'mark_price' or 'market_price'

  • client_order_id (String) (defaults to: nil)

    Optional. Client-supplied order ID

  • stp_mode (String) (defaults to: nil)

    Optional. STP mode: 'cancel_maker', 'cancel_taker', or 'cancel_both'

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Hash] Order details containing:
      • orderId [String] Plan order ID
      • clientOid [String] Client order ID if provided


913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
# File 'lib/Bitget/V2/Client.rb', line 913

def spot_trade_place_plan_order(symbol:, side:, trigger_price:, order_type:, execute_price: nil, plan_type: nil, size: nil, trigger_type: nil, client_order_id: nil, stp_mode: nil)
  response = post(
    path: '/spot/trade/place-plan-order',
    args: {
      symbol: symbol,
      side: side,
      triggerPrice: trigger_price,
      orderType: order_type,
      executePrice: execute_price,
      planType: plan_type,
      size: size,
      triggerType: trigger_type,
      clientOid: client_order_id,
      stpMode: stp_mode,
    }
  )
  handle_response(response)
end

#spot_trade_plan_sub_order(order_id:) ⇒ Hash

Get Plan Sub Order GET /api/v2/spot/trade/plan-sub-order

Frequency limit: 20 times/1s (UID) Note: This endpoint retrieves the executed sub-orders of a trigger/plan order

Parameters:

  • order_id (String)

    Required. Plan order ID to query

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • msg [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] List of sub-orders, each containing:
      • orderId [String] Sub-order ID
      • price [String] Order price
      • type [String] Order type
      • status [String] Order status


1036
1037
1038
1039
1040
1041
1042
# File 'lib/Bitget/V2/Client.rb', line 1036

def spot_trade_plan_sub_order(order_id:)
  response = get(
    path: '/spot/trade/plan-sub-order',
    args: {orderId: order_id}
  )
  handle_response(response)
end

#spot_trade_unfilled_orders(symbol: nil, start_time: nil, end_time: nil, id_less_than: nil, limit: nil, order_id: nil, tpsl_type: nil, request_time: nil, receive_window: nil) ⇒ Hash

Get Current Orders GET /api/v2/spot/trade/unfilled-orders

Frequency limit: 20 times/1s (UID) Note: This endpoint retrieves all unfilled (open) orders for the account

Parameters:

  • symbol (String) (defaults to: nil)

    Optional. Trading pair name e.g. 'BTCUSDT'

  • start_time (Integer) (defaults to: nil)

    Optional. Start timestamp in milliseconds

  • end_time (Integer) (defaults to: nil)

    Optional. End timestamp in milliseconds

  • id_less_than (String) (defaults to: nil)

    Optional. Pagination of data to return records earlier than the requested orderId

  • limit (Integer) (defaults to: nil)

    Optional. Number of results per request. Maximum 100. Default 100

  • order_id (String) (defaults to: nil)

    Optional. Filter by order ID

  • tpsl_type (String) (defaults to: nil)

    Optional. Take profit/stop loss type: 'normal' or 'tpsl'

  • request_time (Integer) (defaults to: nil)

    Optional. Current timestamp in milliseconds

  • receive_window (Integer) (defaults to: nil)

    Optional. The value cannot be greater than 60000

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code ('00000' for success)
    • message [String] Response message ('success' for success)
    • requestTime [Integer] Request timestamp in milliseconds
    • data [Array] Array of unfilled orders, each containing:
      • userId [String] User ID
      • symbol [String] Trading pair
      • orderId [String] Order ID
      • clientOid [String] Client order ID if provided
      • priceAvg [String] Average fill price
      • size [String] Order size
      • orderType [String] Order type
      • side [String] Order side ('buy' or 'sell')
      • status [String] Order status
      • basePrice [String] Base price
      • baseVolume [String] Base asset volume
      • quoteVolume [String] Quote asset volume
      • enterPointSource [String] Entry point source
      • presetTakeProfitPrice [String] Preset take profit price
      • executeTakeProfitPrice [String] Execute take profit price
      • presetStopLossPrice [String] Preset stop loss price
      • executeStopLossPrice [String] Execute stop loss price
      • cTime [String] Creation time
      • tpslType [String] Take profit/stop loss type
      • triggerPrice [String] Trigger price


763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
# File 'lib/Bitget/V2/Client.rb', line 763

def spot_trade_unfilled_orders(symbol: nil, start_time: nil, end_time: nil, id_less_than: nil, limit: nil, order_id: nil, tpsl_type: nil, request_time: nil, receive_window: nil)
  response = get(
    path: '/spot/trade/unfilled-orders',
    args: {
      symbol: symbol,
      startTime: start_time,
      endTime: end_time,
      idLessThan: id_less_than,
      limit: limit,
      orderId: order_id,
      tpslType: tpsl_type,
      requestTime: request_time,
      receiveWindow: receive_window,
    }
  )
  handle_response(response)
end

#spot_wallet_cancel_withdrawal(order_id:) ⇒ Hash

Cancel Withdrawal POST /api/v2/spot/wallet/cancel-withdrawal

Frequency limit:10 times/1s (User ID) Note: This endpoint cancels a pending withdrawal request

Parameters:

  • order_id (String)

    Required. The withdrawal order ID to cancel

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [String] 'success' if withdrawal was cancelled


1664
1665
1666
1667
# File 'lib/Bitget/V2/Client.rb', line 1664

def spot_wallet_cancel_withdrawal(order_id:)
  response = post(path: '/spot/wallet/cancel-withdrawal', args: {orderId: order_id})
  handle_response(response)
end

#spot_wallet_deposit_address(coin:, chain: nil, size: nil) ⇒ Hash

Get Deposit Address GET /api/v2/spot/wallet/deposit-address

Frequency limit: 10 times/1s (User ID) Note: This endpoint retrieves the deposit address for a specific cryptocurrency

Parameters:

  • coin (String)

    Required. Cryptocurrency code e.g. 'BTC', 'USDT'

  • chain (String) (defaults to: nil)

    Optional. Blockchain network e.g. 'BTC-Bitcoin', 'ETH-ERC20'

  • size (Integer) (defaults to: nil)

    Optional. Number of addresses to generate

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Hash] Response data
      • coin [String] Cryptocurrency code
      • chain [String] Blockchain network
      • address [String] Deposit address
      • tag [String, nil] Memo/Tag if required by the coin
      • url [String] Block explorer URL


1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
# File 'lib/Bitget/V2/Client.rb', line 1590

def spot_wallet_deposit_address(coin:, chain: nil, size: nil)
  response = get(
    path: '/spot/wallet/deposit-address',
    args: {
      coin: coin,
      chain: chain,
      size: size,
    }
  )
  handle_response(response)
end

#spot_wallet_deposit_records(coin: nil, order_id: nil, start_time:, end_time:, id_less_than: nil, limit: nil) ⇒ Hash

Get Deposit Records GET /api/v2/spot/wallet/deposit-records

Frequency limit:10 times/1s (UID) Note: This endpoint retrieves deposit records for the account

Parameters:

  • coin (String) (defaults to: nil)

    Optional. Filter by cryptocurrency code e.g. 'BTC', 'USDT'

  • order_id (String) (defaults to: nil)

    Optional. Filter by deposit order ID

  • start_time (Integer)

    Required. Filter by start time in milliseconds

  • end_time (Integer)

    Required. Filter by end time in milliseconds

  • id_less_than (Integer) (defaults to: nil)

    Optional. Filter by records with ID less than this value

  • limit (Integer) (defaults to: nil)

    Optional. Number of records to return (default: 100, max: 500)

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Array] List of deposit records containing:
      • orderId [String] Deposit order ID
      • tradeId [String] TX ID
      • coin [String] Cryptocurrency code
      • type [String] 'deposit'
      • size [String] Quantity
      • status [String] Deposit status (e.g. 'success')
      • toAddress [String] Chain address if dest is on_chain or UID, email, or phone number if dest is internal_transfer
      • dest [String] Destination type (e.g. 'on_chain')
      • chain [String] Blockchain network
      • fromAddress [String] Chain address if dest is on_chain or UID, email, or phone number if dest is internal_transfer
      • cTime [String] Creation timestamp
      • uTime [String] Last update timestamp


1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
# File 'lib/Bitget/V2/Client.rb', line 1791

def spot_wallet_deposit_records(coin: nil, order_id: nil, start_time:, end_time:, id_less_than: nil, limit: nil)
  response = get(
    path: '/spot/wallet/deposit-records',
    args: {
      coin: coin,
      orderId: order_id,
      startTime: start_time,
      endTime: end_time,
      idLessThan: id_less_than,
      limit: limit,
    }
  )
  handle_response(response)
end

#spot_wallet_modify_deposit_account(account_type:, coin:) ⇒ Hash

Modify Deposit Account POST /api/v2/spot/wallet/modify-deposit-account

Frequency limit:10 times/1s (User ID) Note: This endpoint modifies the deposit account type for a specific cryptocurrency

Parameters:

  • account_type (String)

    Required. Account type. Valid values:

    • 'spot': Spot account
    • 'funding': Funding account
    • 'coin-futures': Coin-M futures account
    • 'mix_usdt': USDT-M futures account
    • 'usdc-futures': USDC-M futures account
  • coin (String)

    Required. The cryptocurrency code e.g. 'BTC', 'USDT'

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [String] 'success' if successful


1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
# File 'lib/Bitget/V2/Client.rb', line 1220

def (account_type:, coin:)
  response = post(
    path: '/spot/wallet/modify-deposit-account',
    args: {
      accountType: ,
      coin: coin,
    }
  )
  handle_response(response)
end

#spot_wallet_subaccount_deposit_address(subaccount_user_id:, coin:, chain: nil, size: nil) ⇒ Hash

Get SubAccount Deposit Address GET /api/v2/spot/wallet/subaccount-deposit-address

Rate limit: 10 req/sec/UID Note: This endpoint retrieves the deposit address for a specific cryptocurrency in a sub-account

Parameters:

  • subaccount_user_id (String)

    Required. Sub-account user ID (uid)

  • coin (String)

    Required. Cryptocurrency code e.g. 'BTC', 'USDT'

  • chain (String) (defaults to: nil)

    Optional. Blockchain network e.g. 'BTC-Bitcoin', 'ETH-ERC20'

  • size (Integer) (defaults to: nil)

    Optional. Number of addresses to generate

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Hash] Response data
      • coin [String] Cryptocurrency code
      • chain [String] Blockchain network
      • address [String] Deposit address
      • tag [String, nil] Memo/Tag if required by the coin
      • url [String] Block explorer URL


1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
# File 'lib/Bitget/V2/Client.rb', line 1622

def spot_wallet_subaccount_deposit_address(subaccount_user_id:, coin:, chain: nil, size: nil)
  response = get(
    path: '/spot/wallet/subaccount-deposit-address',
    args: {
      subUid: subaccount_user_id,
      coin: coin,
      chain: chain,
      size: size,
   }
  )
  handle_response(response)
end

#spot_wallet_subaccount_deposit_records(subaccount_user_id:, coin: nil, start_time: nil, end_time: nil, id_less_than: nil, limit: nil) ⇒ Hash

Get SubAccount Deposit Records GET /api/v2/spot/wallet/subaccount-deposit-records

Frequency limit:10 times/1s (UID) Note: This endpoint retrieves deposit records for a specific sub-account

Parameters:

  • subaccount_user_id (String)

    Required. Sub-account user ID (uid)

  • coin (String) (defaults to: nil)

    Optional. Filter by cryptocurrency code e.g. 'BTC', 'USDT'

  • start_time (Integer) (defaults to: nil)

    Optional. Filter by start time in milliseconds

  • end_time (Integer) (defaults to: nil)

    Optional. Filter by end time in milliseconds

  • id_less_than (Integer) (defaults to: nil)

    Optional. Filter by records with ID less than this value

  • limit (Integer) (defaults to: nil)

    Optional. Number of records to return (default: 100, max: 500)

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Array] List of deposit records containing:
      • orderId [String] Record ID
      • tradeId [String] Trade ID
      • coin [String] Cryptocurrency code
      • size [String] Deposit amount
      • status [String] Deposit status (e.g. 'success')
      • toAddress [String] Destination address
      • dest [String] Destination type (e.g. 'on_chain')
      • chain [String] Blockchain network
      • fromAddress [String] Source address
      • cTime [String] Creation timestamp
      • uTime [String] Last update timestamp


1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
# File 'lib/Bitget/V2/Client.rb', line 1697

def spot_wallet_subaccount_deposit_records(subaccount_user_id:, coin: nil, start_time: nil, end_time: nil, id_less_than: nil, limit: nil)
  response = get(
    path: '/spot/wallet/subaccount-deposit-records',
    args: {
      subUid: subaccount_user_id,
      coin: coin,
      startTime: start_time,
      endTime: end_time,
      idLessThan: id_less_than,
      limit: limit,
    }
  )
  handle_response(response)
end

#spot_wallet_subaccount_transfer(from_type:, to_type:, amount:, coin:, symbol: nil, client_order_id: nil, from_user_id: nil, to_user_id: nil) ⇒ Hash

Sub Transfer POST /api/v2/spot/wallet/subaccount-transfer

Rate limit: 10 req/sec/UID Note: This endpoint requires IP whitelist. Transfer between fromUserId and toUserId should have direct/brother relationship.

Parameters:

  • from_type (String)

    Required. Source account type. Valid values:

    • 'spot': Spot account
    • 'p2p': P2P/funding account
    • 'coin_futures': Coin-M futures account
    • 'usdt_futures': USDT-M futures account
    • 'usdc_futures': USDC-M futures account
    • 'crossed_margin': Cross margin account
    • 'isolated_margin': Isolated margin account
  • to_type (String)

    Required. Destination account type (same valid values as from_type)

  • amount (String)

    Required. Amount to transfer

  • coin (String)

    Required. Cryptocurrency code e.g. 'BTC', 'USDT'

  • symbol (String) (defaults to: nil)

    Optional. Trading pair symbol e.g. 'BTCUSDT'

  • client_order_id (String) (defaults to: nil)

    Optional. Client-supplied order ID

  • from_user_id (String) (defaults to: nil)

    Optional. Source user ID. Required for cross-user transfers

  • to_user_id (String) (defaults to: nil)

    Optional. Destination user ID. Required for cross-user transfers

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Hash] Response data
      • transferId [String] Transfer ID assigned by Bitget
      • clientOid [String] Client-supplied order ID


1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
# File 'lib/Bitget/V2/Client.rb', line 1373

def spot_wallet_subaccount_transfer(from_type:, to_type:, amount:, coin:, symbol: nil, client_order_id: nil, from_user_id: nil, to_user_id: nil)
  response = post(
    path: '/spot/wallet/subaccount-transfer',
    args: {
      fromType: from_type,
      toType: to_type,
      amount: amount,
      coin: coin,
      clientOid: client_order_id,
      fromUserId: from_user_id,
      toUserId: to_user_id,
    }
  )
  handle_response(response)
end

#spot_wallet_transfer(from_type:, to_type:, amount:, coin:, symbol:, client_order_id: nil) ⇒ Hash

Transfer POST /api/v2/spot/wallet/transfer

RRate limit: 10 requests/second/UID Note: This endpoint transfers assets between different account types within Bitget Note: Only available for main accounts, not sub-accounts

Parameters:

  • from_type (String)

    Required. Source account type. Valid values:

    • 'spot': Spot account
    • 'p2p': P2P/funding account
    • 'coin_futures': Coin-M futures account
    • 'usdt_futures': USDT-M futures account
    • 'usdc_futures': USDC-M futures account
    • 'crossed_margin': Cross margin account
    • 'isolated_margin': Isolated margin account
  • to_type (String)

    Required. Destination account type (same valid values as from_type)

  • amount (String)

    Required. Amount to transfer

  • coin (String)

    Required. Cryptocurrency code e.g. 'BTC', 'USDT'

  • symbol (String)

    Required. Trading pair symbol e.g. 'BTCUSDT'

  • client_order_id (String) (defaults to: nil)

    Optional. Client-supplied order ID

Returns:

  • (Hash)

    Response containing:

    • transferId [String] Transfer ID assigned by Bitget
    • clientOid [String] Client-supplied order ID


1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
# File 'lib/Bitget/V2/Client.rb', line 1298

def spot_wallet_transfer(from_type:, to_type:, amount:, coin:, symbol:, client_order_id: nil)
  response = post(
    path: '/spot/wallet/transfer',
    args: {
      fromType: from_type,
      toType: to_type,
      amount: amount,
      coin: coin,
      symbol: symbol,
      clientOid: client_order_id,
    }
  )
  handle_response(response)
end

#spot_wallet_transfer_coin_info(from_type:, to_type:) ⇒ Array<Hash>

GET Transferable Coin List GET /api/v2/spot/wallet/transfer-coin-info

Frequency limit:10 times/1s (User ID) Note: This endpoint retrieves the list of coins that can be transferred between specified account types

Parameters:

  • from_type (String)

    Required. Source account type. Valid values:

    • 'spot': Spot account
    • 'p2p': P2P/funding account
    • 'coin_futures': Coin-M futures account
    • 'usdt_futures': USDT-M futures account
    • 'usdc_futures': USDC-M futures account
    • 'crossed_margin': Cross margin account
    • 'isolated_margin': Isolated margin account
  • to_type (String)

    Required. Destination account type (same valid values as from_type)

Returns:

  • (Array<Hash>)

    List of transferable coins with their details:

    • coin [String] Cryptocurrency code
    • chain [String] Blockchain network
    • fromMin [String] Minimum transfer amount from source account
    • toMin [String] Minimum transfer amount to destination account


1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
# File 'lib/Bitget/V2/Client.rb', line 1333

def spot_wallet_transfer_coin_info(from_type:, to_type:)
  response = get(
    path: '/spot/wallet/transfer-coin-info',
    args: {
      fromType: from_type,
      toType: to_type,
    }
  )
  handle_response(response)
end

#spot_wallet_withdrawal(coin:, transfer_type:, address:, chain: nil, inner_to_type: nil, area_code: nil, tag: nil, size:, remark: nil, client_order_id: nil, member_code: nil, identity_type: nil, company_name: nil, first_name: nil, last_name: nil) ⇒ Hash

Withdraw POST /api/v2/spot/wallet/withdrawal

Rate limit:5 req/sec/UID Note: This endpoint requires withdrawal permission and IP whitelist.

Parameters:

  • coin (String)

    Required. Cryptocurrency code e.g. 'BTC', 'USDT'

  • transfer_type (String)

    Required. Type of withdrawal. Valid values:

    • 'on_chain': Withdraw to external address
    • 'internal_transfer': Internal transfer
  • address (String)

    Required. Withdrawal address

  • chain (String) (defaults to: nil)

    Optional. Blockchain network e.g. 'BTC-Bitcoin', 'ETH-ERC20'

  • inner_to_type (String) (defaults to: nil)

    Optional. Type of address for internal withdrawals. Valid values:

    • 'email': Email address
    • 'mobile': Mobile phone number
    • 'uid': UID (default)
  • area_code (String) (defaults to: nil)

    Optional. Area code for the recipient

  • tag (String) (defaults to: nil)

    Optional. Memo/Tag for coins that require it

  • size (String)

    Required. Withdrawal amount

  • remark (String) (defaults to: nil)

    Optional. Withdrawal remark/note

  • client_order_id (String) (defaults to: nil)

    Optional. Client-supplied order ID

  • member_code (String) (defaults to: nil)

    Optional. Member code

  • identity_type (String) (defaults to: nil)

    Optional. Identity type

  • company_name (String) (defaults to: nil)

    Optional. Company name for business accounts

  • first_name (String) (defaults to: nil)

    Optional. First name for individual accounts

  • last_name (String) (defaults to: nil)

    Optional. Last name for individual accounts

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Hash] Response data
      • orderId [String] Withdrawal ID
      • clientOid [String] Client-supplied order ID


1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
# File 'lib/Bitget/V2/Client.rb', line 1422

def spot_wallet_withdrawal(coin:, transfer_type:, address:, chain: nil, inner_to_type: nil, area_code: nil, tag: nil, size:, remark: nil, client_order_id: nil, member_code: nil, identity_type: nil, company_name: nil, first_name: nil, last_name: nil)
  response = post(
    path: '/spot/wallet/withdrawal',
    args: {
      coin: coin,
      transferType: transfer_type,
      address: address,
      chain: chain,
      innerToType: inner_to_type,
      areaCode: area_code,
      tag: tag,
      size: size,
      remark: remark,
      clientOid: client_order_id,
      memberCode: member_code,
      identityType: identity_type,
      companyName: company_name,
      firstName: first_name,
      lastName: last_name,
    }
  )
  handle_response(response)
end

#spot_wallet_withdrawal_records(coin: nil, client_order_id: nil, start_time:, end_time:, id_less_than: nil, order_id: nil, limit: nil) ⇒ Hash

Get Withdrawal Records GET /api/v2/spot/wallet/withdrawal-records

Frequency limit:10 times/1s (User ID) Note: This endpoint retrieves withdrawal records for the account

Parameters:

  • coin (String) (defaults to: nil)

    Optional. Filter by cryptocurrency code e.g. 'BTC', 'USDT'

  • client_order_id (String) (defaults to: nil)

    Optional. Filter by client order ID

  • start_time (Integer)

    Required. Filter by start time in milliseconds

  • end_time (Integer)

    Optional. Filter by end time in milliseconds

  • id_less_than (Integer) (defaults to: nil)

    Optional. Filter by records with ID less than this value

  • order_id (String) (defaults to: nil)

    Optional. Filter by withdrawal order ID

  • limit (Integer) (defaults to: nil)

    Optional. Number of records to return (default: 100, max: 500)

Returns:

  • (Hash)

    Response containing:

    • code [String] Response code, '00000' means success
    • msg [String] Response message
    • requestTime [Integer] Request timestamp
    • data [Array] List of withdrawal records containing:
      • orderId [String] Withdrawal order ID
      • tradeId [String] Trade ID
      • coin [String] Cryptocurrency code
      • dest [String] Destination type
      • clientOid [String] Client order ID if provided
      • type [String] Operation type (e.g. 'withdraw')
      • tag [String] Memo/Tag if applicable
      • size [String] Withdrawal amount
      • fee [String] Withdrawal fee
      • status [String] Withdrawal status (e.g. 'success')
      • toAddress [String] Destination address
      • fromAddress [String] Source address
      • confirm [String] Number of confirmations
      • chain [String] Blockchain network
      • cTime [String] Creation timestamp
      • uTime [String] Last update timestamp


1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
# File 'lib/Bitget/V2/Client.rb', line 1746

def spot_wallet_withdrawal_records(coin: nil, client_order_id: nil, start_time:, end_time:, id_less_than: nil, order_id: nil, limit: nil)
  response = get(
    path: '/spot/wallet/withdrawal-records',
    args: {
      coin: coin,
      clientOid: client_order_id,
      startTime: start_time,
      endTime: end_time,
      idLessThan: id_less_than,
      orderId: order_id,
      limit: limit,
    }
  )
  handle_response(response)
end