Bybit
CryptoExchangeAPIs.Bybit.BybitClient
— TypeBybitClient <: AbstractAPIsClient
Client info.
Required fields
base_url::String
: Base URL for the client.
Optional fields
public_key::String
: Public key for authentication.secret_key::String
: Secret key for authentication.interface::String
: Interface for the client.proxy::String
: Proxy information for the client.account_name::String
: Account name associated with the client.description::String
: Description of the client.
CryptoExchangeAPIs.Bybit.BybitAPIError
— TypeBybitAPIError{T} <: AbstractAPIsError
Exception thrown when an API method fails with code T
.
Required fields
retCode::Int64
: Error code.retMsg::String
: Error message.result::Dict{String,Any}
: Error result data.retExtInfo::Dict{String,Any}
: Extended error information.time::NanoDate
: Error timestamp (ms).
CryptoExchangeAPIs.Bybit.List
— TypeList{D} <: AbstractAPIsData
Required fields
list::Vector{D}
: Result values.
Optional fields
nextPageCursor::String
: Pagination cursor.category::String
: Product type
CryptoExchangeAPIs.Bybit.Rows
— TypeRows{D} <: AbstractAPIsData
Required fields
rows::Vector{D}
: Result values.
Optional fields
nextPageCursor::String
: Pagination cursor.
CryptoExchangeAPIs.Bybit.Data
— TypeData{D} <: AbstractAPIsData
Required fields
retCode::Int64
: Return code.retMsg::String
: Return msg.result::D
: Request result data.retExtInfo::Dict{String,Any}
: Request extended information.time::NanoDate
: Current timestamp (ms).
Common
CryptoExchangeAPIs.Bybit.Common.public_client
— Constantpublic_client = BybitClient(; base_url = "https://api.bybit.com")
CryptoExchangeAPIs.Bybit.Common.Instrument.instrument
— Functioninstrument(client::BybitClient, query::InstrumentQuery)
instrument(client::BybitClient = Bybit.Common.public_client; kw...)
Query for the instrument specification of online trading pairs.
GET /v5/market/instruments-info
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
category | ProductType | true | spot linear inverse option |
symbol | String | false | |
status | StatusFilter | false | PreLaunch Trading Delivering Closed |
baseCoin | String | false | |
limit | String | false | |
сгкыщк | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Bybit
result = Bybit.Common.instrument(;
category = Bybit.Common.Instrument.spot
)
to_pretty_json(result.result)
Result:
{
"retCode":0,
"retMsg":"OK",
"result":{
"list":[
{
"symbol":"BTCUSDT",
"baseCoin":"BTC",
"quoteCoin":"USDT",
"innovation":false,
"status":"Trading",
"marginTrading":"utaOnly",
"lotSizeFilter":{
"basePrecision":1.0e-6,
"quotePrecision":1.0e-8,
"minOrderQty":4.8e-5,
"maxOrderQty":71.73956243,
"minOrderAmt":1.0,
"maxOrderAmt":4.0e6
},
"priceFilter":{
"tickSize":0.01
},
"riskParameters":{
"limitParameter":0.03,
"marketParameter":0.03
}
},
...
]
}
Spot
CryptoExchangeAPIs.Bybit.Spot.public_client
— Constantpublic_client = BybitClient(; base_url = "https://api.bybit.com")
CryptoExchangeAPIs.Bybit.Spot.Candle.candle
— Functioncandle(client::BybitClient, query::CandleQuery)
candle(client::BybitClient = Bybit.Spot.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
category | Category | true | SPOT LINEAR INVERSE |
symbol | String | true | |
interval | TimeInterval | true | m1 m3 m5 m15 m30 h1 h2 h4 h6 h12 d1 w1 M1 |
endTime | DateTime | false | |
limit | Int64 | false | |
startTime | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Bybit
result = Bybit.Spot.candle(;
category = Bybit.Spot.Candle.SPOT,
symbol = "ADAUSDT",
interval = Bybit.Spot.Candle.M1,
)
to_pretty_json(result.result)
Result:
{
"retCode":0,
"retMsg":"OK",
"result":{
"list":[
{
"start":"2025-01-01T00:00:00",
"open":0.8451,
"high":1.1519,
"low":0.8382,
"close":0.9103,
"volume":6.6700225827e8,
"turnover":6.724810699166e8
},
...
],
"nextPageCursor":null,
"category":"spot"
},
"retExtInfo":{},
"time":"2025-01-13T11:19:18.851000064"
}
CryptoExchangeAPIs.Bybit.Spot.CoinInfo.coin_info
— Functioncoin_info(client::BybitClient, query::CoinInfoQuery)
coin_info(client::BybitClient; kw...)
Query Coin Information.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
coin | String | false | |
api_key | String | false | |
recv_window | Int64 | false | Default: 5000 |
signature | String | false | |
timestamp | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Bybit
bybit_client = BybitClient(;
base_url = "https://api.bybit.com",
public_key = ENV["BYBIT_PUBLIC_KEY"],
secret_key = ENV["BYBIT_SECRET_KEY"],
)
result = Bybit.Spot.coin_info(bybit_client)
to_pretty_json(result.result)
Result:
{
"retCode":0,
"retMsg":"",
"result":{
"rows":[
{
"chains":[
{
"chain":"ETH",
"chainDeposit":1,
"chainType":"ERC20",
"chainWithdraw":1,
"confirmation":6,
"depositMin":0.0,
"minAccuracy":8,
"withdrawFee":3.0,
"withdrawMin":3.0,
"withdrawPercentageFee":0.0
}
],
"coin":"AGLD",
"name":"AGLD",
"remainAmount":256400
},
...
],
"nextPageCursor":null
},
"retExtInfo":{},
"time":"2024-03-27T14:22:12.088"
}
CryptoExchangeAPIs.Bybit.Spot.Deposit.deposit
— Functiondeposit(client::BybitClient, query::DepositQuery)
deposit(client::BybitClient; kw...)
Query Deposit Records.
GET /v5/asset/deposit/query-record
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
coin | String | false | |
cursor | String | false | |
endTime | DateTime | false | |
limit | Int64 | false | Default: 50, Max: 50 |
startTime | DateTime | false | |
api_key | String | false | |
recv_window | Int64 | false | Default: 5000 |
signature | String | false | |
timestamp | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Bybit
bybit_client = BybitClient(;
base_url = "https://api.bybit.com",
public_key = ENV["BYBIT_PUBLIC_KEY"],
secret_key = ENV["BYBIT_SECRET_KEY"],
)
result = Bybit.Spot.deposit(bybit_client)
to_pretty_json(result.result)
Result:
{
"retCode": 0,
"retMsg": "success",
"result": {
"rows": [
{
"coin": "USDT",
"chain": "ETH",
"amount": "10000",
"txID": "1234567890",
"status": 3,
"toAddress": "xxxxxxxxxxx",
"tag": "",
"depositFee": "",
"successAt": "2024-02-27T14:22:12.000",
"confirmations": "10000",
"txIndex": "",
"batchReleaseLimit":null,
"blockHash": "",
},
{
"coin": "USDT",
"chain": "ETH",
"amount": "10000",
"txID": "01234567890",
"status": 3,
"toAddress": "xxxxxxxxxxx",
"tag": "",
"depositFee": "",
"successAt": "2023-12-15T12:03:40.000",
"confirmations": "10000",
"txIndex": "",
"batchReleaseLimit":null,
"blockHash": "",
}
],
"nextPageCursor": "X78...x89"
},
"retExtInfo": {},
"time": "2024-03-27T14:22:12.088"
}
CryptoExchangeAPIs.Bybit.Spot.OrderBook.order_book
— Functionorder_book(client::BybitClient, query::OrderBookQuery)
order_book(client::BybitClient = Bybit.Spot.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
category | Category | true | SPOT LINEAR INVERSE OPTION |
symbol | String | true | |
limit | Int64 | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Bybit
result = Bybit.Spot.order_book(;
category = Bybit.Spot.OrderBook.SPOT,
symbol = "ADAUSDT",
)
to_pretty_json(result.result)
Result:
{
"retCode":0,
"retMsg":"OK",
"result":{
"s":"ADAUSDT",
"a":[
{
"price":0.9064,
"size":96.0
}
...
],
"b":[
{
"price":0.9062,
"size":1951.28
}
...
],
"ts":"2025-01-13T11:35:23.236999936"
},
"retExtInfo":{},
"time":"2025-01-13T11:35:23.382000128"
}
CryptoExchangeAPIs.Bybit.Spot.SymbolInfo.symbol_info
— Functionsymbol_info(client::BybitClient, query::SymbolInfoQuery)
symbol_info(client::BybitClient = Bybit.Spot.public_client; kw...)
Query for the instrument specification of online trading pairs.
GET /v5/market/instruments-info
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
category | Category | true | SPOT LINEAR INVERSE OPTION |
symbol | String | true | |
status | String | true | |
baseCoin | String | true | |
limit | Int64 | false | |
cursor | String | true |
Code samples:
using Serde
using CryptoExchangeAPIs.Bybit
result = Bybit.Spot.symbol_info(;
category = Bybit.Spot.SymbolInfo.SPOT,
symbol = "BTCUSDT",
)
to_pretty_json(result.result)
Result:
{
"retCode":0,
"retMsg":"OK",
"result":{
"list":[
{
"symbol":"BTCUSDT",
"baseCoin":"BTC",
"quoteCoin":"USDT",
"innovation":0,
"status":"Trading",
"lotSizeFilter":{
"basePrecision":1.0e-6,
"quotePrecision":1.0e-8,
"minOrderQty":4.8e-5,
"maxOrderQty":83.0,
"minOrderAmt":1.0,
"maxOrderAmt":8.0e6
},
"priceFilter":{
"tickSize":0.01
},
"riskParameters":{
"limitParameter":0.02,
"marketParameter":0.02
}
}
],
"nextPageCursor":null,
"category":"spot"
},
"retExtInfo":{},
"time":"2025-01-13T12:00:59.132"
}
CryptoExchangeAPIs.Bybit.Spot.Ticker.ticker
— Functionticker(client::BybitClient, query::TickerQuery)
ticker(client::BybitClient = Bybit.Spot.public_client; kw...)
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
category | Category | true | SPOT LINEAR INVERSE OPTION |
symbol | String | false | |
baseCoin | String | false | |
expDate | String | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Bybit
result = Bybit.Spot.ticker(;
category = Bybit.Spot.Ticker.SPOT,
symbol = "BTCUSDT",
)
to_pretty_json(result.result)
Result:
{
"retCode":0,
"retMsg":"OK",
"result":{
"list":[
{
"symbol":"BTCUSDT",
"bid1Price":90977.73,
"bid1Size":0.033508,
"ask1Price":90977.74,
"ask1Size":0.124391,
"lastPrice":90976.95,
"prevPrice24h":94379.41,
"pice24hPcnt":null,
"highPrice24h":95950.05,
"lowPrice24h":90547.11,
"turnover24h":2.838946290225581e9,
"volume24h":30219.056193,
"usdIndexPrice":90893.782055
}
],
"nextPageCursor":null,
"category":"spot"
},
"retExtInfo":{},
"time":"2025-01-13T12:14:58.473999872"
}
CryptoExchangeAPIs.Bybit.Spot.TradeHistory.trade_history
— Functiontrade_history(client::BybitClient, query::TradeHistoryQuery)
trade_history(client::BybitClient; kw...)
Query users' execution records.
Parameters:
Parameter | Type | Required | Description |
---|---|---|---|
category | String | true | |
symbol | String | false | |
orderId | String | false | |
orderLinkId | String | false | |
baseCoin | String | false | |
endTime | DateTime | false | |
limit | Int64 | false | Default: 50, Max: 100 |
startTime | DateTime | false | |
execType | String | false | |
cursor | String | false | |
api_key | String | false | |
recv_window | Int64 | false | Default: 5000 |
signature | String | false | |
timestamp | DateTime | false |
Code samples:
using Serde
using CryptoExchangeAPIs.Bybit
bybit_client = BybitClient(;
base_url = "https://api.bybit.com",
public_key = ENV["BYBIT_PUBLIC_KEY"],
secret_key = ENV["BYBIT_SECRET_KEY"],
)
result = Bybit.Spot.trade_history(
bybit_client;
category = Bybit.Spot.TradeHistory.LINEAR,
limit = 1,
)
to_pretty_json(result.result)
Result:
{
"retCode":0,
"retMsg":"OK",
"result":{
"list":[
{
"symbol":"ETHPERP",
"orderType":"Market",
"underlyingPrice":nothing,
"orderLinkId":nothing,
"side":"Buy",
"indexPrice":nothing,
"orderId":"8c065341-7b52-4ca9-ac2c-37e31ac55c94",
"stopOrderType":"UNKNOWN",
"leavesQty":0.0,
"execTime":"2022-12-29T02:58:42.428999936",
"feeCurrency":nothing,
"isMaker":false,
"execFee":0.071409,
"feeRate":0.0006,
"execId":"e0cbe81d-0f18-5866-9415-cf319b5dab3b",
"tradeIv":nothing,
"blockTradeId":nothing,
"markPrice":1183.54,
"execPrice":1190.15,
"markIv":nothing,
"orderQty":0.1,
"orderPrice":1236.9,
"execValue":119.015,
"execType":"Trade",
"execQty":0.1,
"closedSize":nothing,
"seq":4688002127
}
],
"nextPageCursor":"132766%3A2%2C132766%3A2",
"category":"linear",
},
"retExtInfo":{},
"time":"2022-12-29T03:15:54.510"
}