繁體中文
NAV
console python

Group And Resources

Bybit API and WebSocket documentation provides guidance to help you access Bybit's endpoints, their expected outputs, and common errors.

For further assistance or feedback, please join the API Telegram chat! API discussion group on Telegram.

API Resources and Support Channels

Changelog

2023-02-14

REST API

2022-11-24

REST API

2022-09-14

REST API

2022-06-15

REST API

2022-05-19

REST API

2021-08-26

REST API

Authentication

All requests made to private endpoints must be authenticated. Requests made to public endpoints do not require additional authentication.

Parameters for Authenticated Endpoints

The following parameters must be used for authentication:

We also provide recv_window (unit in millisecond and default value is 5,000) to specify how long an HTTP request is valid. It is also used to prevent replay attacks.

A smaller recv_window is more secure, but your request may fail if the transmission time is greater than your recv_window.

Please make sure that your timestamp is in sync with our server time. You can use the Server Time endpoint.

Create A Request

An example for adjusting leverage

param_str = "api_key=XXXXXXXXXXX&leverage=100&symbol=BTCUSDH21&timestamp=1542434791747"

# api_key=XXXXXXXXXXX&
# leverage=100&
# symbol=BTCUSDH21&
# timestamp=1542434791747

Note how the parameters are ordered in alphabetical order, with api_key first followed by leverage, then symbol, then timestamp.

1. Concatenate all the public parameters in the query string format. The parameters must be ordered in alphabetical order. This will be used to generate the sign.

2. Use the HMAC_SHA256 algorithm to sign the query string in step 1, and convert it to a hex string to obtain the sign parameter.

Different requests need different message formats. Message format for GET requests:

GET /asset/v1/private/transfer/list?api_key=XXXXXXXXXXX&recvWindow=5000&timestamp=1623208423972&sign=b452640c21a2c9eaec30d24a9bce1a9660d1fb9d07ccc0d623a2a4fca0940095 HTTP/1.1
Host: api-testnet.bybit.com

Message format for POST requests:

POST /asset/v1/private/transfer HTTP/1.1
Host: api-testnet.bybit.com
Content-Type: application/json

{
    "from_account_type": "SPOT",
    "to_account_type": "CONTRACT",
    "amount": "0.01",
    "coin": "USDT",
    "transfer_id": "11ff9b44-2d5d-4293-913d-4597c9ad2170",
    "sign": "{{signature}}",
    "timestamp": "{{timestamp}}",
    "api_key": "{{bybit-api-key}}",
    "recv_window": "50000"
}

Transfer Data Endpoints

The following API data endpoints require authentication.

Create Internal Transfer

Request Example

curl --location --request POST 'https://api-testnet.bybit.com/asset/v1/private/transfer' \
--header 'Content-Type: application/json' \
--data-raw '{
    "from_account_type": "SPOT",
    "to_account_type": "CONTRACT",
    "amount": "0.1",
    "coin": "BTC",
    "transfer_id": "b668ce35-db92-4db4-9f81-0b5da57d4df6",
    "api_key": "XXXXXXXXXXX",
    "sign": "{{sign}}",
    "timestamp": "{{timestamp}}",
    "recv_window": "{{recvWindow}}"
}'
from pybit import account_asset
from uuid import uuid4
session_auth = account_asset.HTTP(
    endpoint="https://api-testnet.bybit.com",
    api_key="your api key",
    api_secret="your api secret")
print(session_auth.create_internal_transfer(
    transfer_id=str(uuid4()),
    coin="BTC",
    amount="0.1",
    from_account_type="SPOT",
    to_account_type="CONTRACT"
))

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "transfer_id": "b668ce35-db92-4db4-9f81-0b5da57d4df6"
    },
    "ext_info": null,
    "time_now": 1629951080227,
    "rate_limit_status": 17,
    "rate_limit_reset_ms": 1629951080227,
    "rate_limit": 3
}

Transfers funds between the different sections of an individual's account (not between subaccounts). For example, between the spot and derivatives accounts.

To send a transfer which is account type & parent/sub agnostic, use the Create Universal Transfer endpoint.

HTTP Request

POST /asset/v1/private/transfer

Request Parameters

Parameter Required Type Comment
transfer_id true string UUID, which is unique across the platform
coin true string Currency type
amount true string Exchange to amount
from_account_type true string Account type
to_account_type true string Account type

Response Parameters

Parameter Type Comment
transfer_id string UUID, which is unique across the platform

Create Subaccount Transfer

Request Example

curl --location --request POST 'https://api-testnet.bybit.com/asset/v1/private/sub-member/transfer' \
--header 'Content-Type: application/json' \
--data-raw '{
    "transfer_id": "5f95de18-b10f-43be-9746-7b95c4a37d97",
    "amount": "0.1",
    "coin": "BTC",
    "sub_user_id": 251711,
    "type": "IN",
    "api_key": "XXXXXXXXXXX",
    "sign": "{{sign}}",
    "timestamp": "{{timestamp}}",
    "recv_window": "{{recvWindow}}"
}'
from pybit import account_asset
from uuid import uuid4
session_auth = account_asset.HTTP(
    endpoint="https://api-testnet.bybit.com",
    api_key="your api key",
    api_secret="your api secret")
print(session_auth.create_subaccount_transfer(
    transfer_id=str(uuid4()),
    coin="BTC",
    amount="0.1",
    sub_user_id=251711,
    type="IN"
))

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "transfer_id": "5f95de18-b10f-43be-9746-7b95c4a37d97"
    },
    "ext_info": null,
    "time_now": 1629966770894,
    "rate_limit_status": 18,
    "rate_limit_reset_ms": 1629966770894,
    "rate_limit": 2
}

Transfers funds between the parent and child (sub) accounts.

To send a transfer which is account type & parent/sub agnostic, use the Create Universal Transfer endpoint.

HTTP Request

POST /asset/v1/private/sub-member/transfer

Request Parameters

Parameter Required Type Comment
transfer_id true string UUID, which is unique across the platform
coin true string Currency type
amount true string Exchange to amount
sub_user_id true string Subaccount
type true string Determines the direction of transfer

Response Parameters

Parameter Type Comment
transfer_id string UUID, which is unique across the platform

Query Internal Transfer List

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/private/transfer/list'
from pybit import account_asset
from uuid import uuid4
session_auth = account_asset.HTTP(
    endpoint="https://api-testnet.bybit.com",
    api_key="your api key",
    api_secret="your api secret")
print(session_auth.query_transfer_list())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "list": [
            {
                "transfer_id": "selfTransfer_c5ae452d-43e8-47e6-aa7c-d2bab57c0958",
                "coin": "BTC",
                "amount": "1",
                "from_account_type": "CONTRACT",
                "to_account_type": "SPOT",
                "timestamp": "1629965054",
                "status": "SUCCESS"
            },
            {
                "transfer_id": "selfTransfer_9a183347-152d-4bdc-990d-8b20284385f9",
                "coin": "BTC",
                "amount": "1",
                "from_account_type": "SPOT",
                "to_account_type": "CONTRACT",
                "timestamp": "1629963043",
                "status": "SUCCESS"
            },
            {
                "transfer_id": "selfTransfer_5f9bfd6e-1718-4a16-814e-1d1bff4b01eb",
                "coin": "BTC",
                "amount": "20",
                "from_account_type": "SPOT",
                "to_account_type": "CONTRACT",
                "timestamp": "1629874294",
                "status": "SUCCESS"
            }
        ],
        "cursor": "eyJtaW5JRCI6Nzg5NTcsIm1heElEIjo3OTM2NH0="
    },
    "ext_info": null,
    "time_now": 1629971474462,
    "rate_limit_status": 59,
    "rate_limit_reset_ms": 1629971474462,
    "rate_limit": 1
}

HTTP Request

GET /asset/v1/private/transfer/list

Request Parameters

Parameter Required Type Comment
transfer_id false string UUID, which is unique across the platform
coin false string Currency type
status false string Transfer status
start_time false integer Start timestamp point for result, in seconds
end_time false integer End timestamp point for result, in seconds
direction false string Turn page
limit false integer Number of records
cursor false string cursor information: used for pagination. Default value: ""

Response Parameters

Parameter Type Comment
transfer_id string UUID, which is unique across the platform
coin string Currency type
amount string Exchange to amount
from_account_type string Account type
to_account_type string Account type
timestamp integer timestamp
status string Transfer status
cursor string cursor information: used for pagination. Default value: ""

Query Subaccount Transfer List

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/private/sub-member/transfer/list'
from pybit import account_asset
from uuid import uuid4
session_auth = account_asset.HTTP(
    endpoint="https://api-testnet.bybit.com",
    api_key="your api key",
    api_secret="your api secret")
print(session_auth.query_subaccount_transfer_list())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "list": [
            {
                "transfer_id": "5f95de18-b10f-43ba-9756-0b95c4a37d07",
                "coin": "BTC",
                "amount": "0.1",
                "user_id": 229988,
                "sub_user_id": 251711,
                "timestamp": "1629968375",
                "status": "SUCCESS",
                "type": "IN"
            },
            {
                "transfer_id": "5f95de18-b10f-43be-9756-0b95c4a37d07",
                "coin": "BTC",
                "amount": "0.1",
                "user_id": 229988,
                "sub_user_id": 251711,
                "timestamp": "1629968351",
                "status": "SUCCESS",
                "type": "IN"
            },
            {
                "transfer_id": "5f95de18-b10f-43be-9746-0b95c4a37d07",
                "coin": "BTC",
                "amount": "0.1",
                "user_id": 229988,
                "sub_user_id": 251711,
                "timestamp": "1629967817",
                "status": "SUCCESS",
                "type": "IN"
            },
            {
                "transfer_id": "5f95de18-b10f-43be-9746-7b95c4a37d97",
                "coin": "BTC",
                "amount": "0.1",
                "user_id": 229988,
                "sub_user_id": 251711,
                "timestamp": "1629966772",
                "status": "SUCCESS",
                "type": "IN"
            }
        ],
        "cursor": "eyJtaW5JRCI6NzkzNzgsIm1heElEIjo3OTQwMH0="
    },
    "ext_info": null,
    "time_now": 1629978073116,
    "rate_limit_status": 59,
    "rate_limit_reset_ms": 1629978073116,
    "rate_limit": 1
}

HTTP Request

GET /asset/v1/private/sub-member/transfer/list

Request Parameters

Parameter Required Type Comment
transfer_id false string UUID, which is unique across the platform
coin false string Currency type
status false string Transfer status
start_time false integer Start timestamp point for result, in seconds
end_time false integer End timestamp point for result, in seconds
direction false string Turn page
limit false integer Number of records
cursor false string cursor information: used for pagination. Default value: ""

Response Parameters

Parameter Type Comment
transfer_id string UUID, which is unique across the platform
coin string Currency type
amount string Exchange to amount
user_id integer Subaccount
sub_user_id integer Subaccount
timestamp integer timestamp
status string Transfer status
type string Determines the direction of transfer
cursor string cursor information: used for pagination. Default value: ""

Query Subaccount List

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/private/sub-member/member-ids'
from pybit import account_asset
from uuid import uuid4
session_auth = account_asset.HTTP(
    endpoint="https://api-testnet.bybit.com",
    api_key="your api key",
    api_secret="your api secret")
print(session_auth.query_subaccount_list())

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "sub_user_id": [
            303936,
            445310,
            445323,
            517292,
            532728,
            545366,
            554286,
            572408
        ],
        "transferable_sub_ids": [
            "303936",
            "445310",
            "445323",
            "517292",
            "532728",
            "545366",
            "554286"
        ]
    },
    "ext_info": null,
    "time_now": 1654676013343,
    "rate_limit_status": 59,
    "rate_limit_reset_ms": 1654676013343,
    "rate_limit": 1
}

HTTP Request

GET /asset/v1/private/sub-member/member-ids

Request Parameters

Parameter Required Type Comment

Response Parameters

Parameter Type Comment
sub_user_id Integer Array List of all subaccounts
transferable_sub_ids string Array List of subaccounts that are universal transfer-enabled

Enable Universal Transfer

Request Example

curl --location --request POST 'https://api-testnet.bybit.com/asset/v1/private/transferable-subs/save' \
--header 'Content-Type: application/json' \
--data-raw '{
    "transferable_sub_ids":"303936,445310,445323,517292,532728,545366,554286",
    "sign": "{{signature}}",
    "timestamp": "{{timestamp}}",
    "api_key": "{{bybit-api-key}}",
    "recv_window": "5000"
}'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {},
    "ext_info": null,
    "time_now": 1654674238364,
    "rate_limit_status": 19,
    "rate_limit_reset_ms": 1654674238364,
    "rate_limit": 1
}

Use this endpoint to enable subaccounts to take part in a universal transfer. It is a one-time switch which, once thrown, enables a subaccount permanently. If not set, your subaccounts cannot use universal tranfers.

HTTP Request

POST /asset/v1/private/transferable-subs/save

Request Parameters

Parameter Required Type Comment
transferable_sub_ids false string A comma-separated list of subaccount UIDs, for example "123,45,14,26,46"

Response Parameters

Parameter Type Comment

Create Universal Transfer

Request Example

curl --location --request POST 'https://api-testnet.bybit.com/asset/v1/private/universal/transfer' \
--header 'Content-Type: application/json' \
--data-raw '{
    "from_account_type": "SPOT",
    "to_account_type": "CONTRACT",
    "amount": "10",
    "coin": "USDT",
    "transfer_id": "21ff1b44-2d5d-4293-913d-4597c5ad2611",
    "from_member_id": "290118",
    "to_member_id": "545366",
    "sign": "{{signature}}",
    "timestamp": "{{timestamp}}",
    "api_key": "{{bybit-api-key}}",
    "recv_window": "5000"
}'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "transfer_id": "21ff1b44-2d5d-4293-913d-4597c5ad2611"
    },
    "ext_info": null,
    "time_now": 1654674912874,
    "rate_limit_status": 18,
    "rate_limit_reset_ms": 1654674912874,
    "rate_limit": 2
}

HTTP Request

POST /asset/v1/private/universal/transfer

Request Parameters

Parameter Required Type Comment
transfer_id true string UUID, which is unique across the platform
coin true string Currency type
amount true string Exchange to amount
from_member_id true string From UID
to_member_id true string To UID
from_account_type true string From account type
to_account_type true string To account type

Response Parameters

Parameter Type Comment
transfer_id string UUID, which is unique across the platform

Query Universal Transfer List

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/private/universal/transfer/list'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "list": [
            {
                "transfer_id": "21ff1b44-2d5d-4293-913d-4597c5ad2611",
                "coin": "USDT",
                "amount": "10",
                "timestamp": "1654674913",
                "status": "SUCCESS",
                "fromAccountType": "SPOT",
                "toAccountType": "CONTRACT",
                "fromMemberId": "290118",
                "toMemberId": "545366"
            },
            {
                "transfer_id": "submember_transfer_7e51ba01-8f44-4c60-a780-5ab7fc578f22",
                "coin": "USDT",
                "amount": "10",
                "timestamp": "1654665691",
                "status": "SUCCESS",
                "fromAccountType": "SPOT",
                "toAccountType": "SPOT",
                "fromMemberId": "290118",
                "toMemberId": "572408"
            }
        ],
        "cursor": "eyJtaW5JRCI6MjgxMzM1LCJtYXhJRCI6NDUzNzMwfQ=="
    },
    "ext_info": null,
    "time_now": 1654676488240,
    "rate_limit_status": 59,
    "rate_limit_reset_ms": 1654676488240,
    "rate_limit": 1
}

HTTP Request

GET /asset/v1/private/universal/transfer/list

Request Parameters

Parameter Required Type Comment
transfer_id false string UUID, which is unique across the platform
coin false string Currency type
status false string Transfer status
start_time false integer Start timestamp point for result, in seconds
end_time false integer End timestamp point for result, in seconds
direction false string Turn page
limit false integer Limit for data size per page, max size is 50. Default as showing 20 pieces of data per page
cursor false string cursor information: used for pagination. Default value: ""

Response Parameters

Parameter Type Comment
transfer_id string UUID, which is unique across the platform
coin string Currency type
amount string Exchange to amount
timestamp integer timestamp
status string Transfer status
from_account_type string Account type
to_account_type string Account type
from_member_id string From UID
to_member_id string To UID
cursor string cursor information: used for pagination. Default value: ""

Withdraw and Deposit Endpoints

The following API data endpoints require authentication.

Supported Deposit List Query Endpoints

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/public/deposit/allowed-deposit-list?coin=ETH&chain=ETH&page_index=1&page_size=10'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "config_list": [
            {
                "coin": "ETH",
                "chain": "ETH",
                "coin_show_name": "ETH",
                "chain_type": "ETH",
                "block_confirm_number": 12,
                "min_deposit_amount": "0"
            }
        ],
        "total": "1"
    },
    "ext_info": null,
    "time_now": 1652841868446
}

It is a public endpoints. Coin and chain must be paired in the input parameter. Otherwise, it is regarded as an unconditional query.

HTTP Request

GET /asset/v1/public/deposit/allowed-deposit-list

Request Parameters

Parameter Required Type Comment
coin false string Deposit Coin. Coin and chain must be paired. Otherwise, it is regarded as an unconditional query
chain false string Deposit Chain Name. Coin and chain must be paired. Otherwise, it is regarded as an unconditional query
page_index false long Page Index: used for pagination. Default value: 1
page_size false long Number of items per page. Default value: 10

Response Parameters

Parameter Type Comment
config_list Array Object
coin string deposit coin
chain string chain name
coin_show_name string Coin show name
chain_type string chain type
block_confirm_number long deposit confirmation number
min_deposit_amount string Minimum Deposit Amount

Query Deposit Records

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/private/deposit/record/query?
api_key=XXXXXXXXXXX&coin=LTC&timestamp=1641534660578&recv_window=50000&sign=XXXXXXXXXXX'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "rows": [
            {
                "coin": "LTC",
                "chain": "LTC",
                "amount": "0.156",
                "tx_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "status": 3,
                "to_address": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "tag": "",
                "deposit_fee": "",
                "success_at": "1631697910",
                "confirmations": "0",
                "tx_index": "",
                "block_hash": ""
            },
            {
                "coin": "LTC",
                "chain": "LTC",
                "amount": "0.158",
                "tx_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "status": 3,
                "to_address": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "tag": "",
                "deposit_fee": "",
                "success_at": "1631688429",
                "confirmations": "0",
                "tx_index": "",
                "block_hash": ""
            }
        ],
        "cursor": "eyJtaW5JRCI6NjkxNjExLCJtYXhJRCI6NjkyOTQ5fQ=="
    },
    "ext_info": null,
    "time_now": 1641535748233,
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1641535748233,
    "rate_limit": 1
}

Rules:

HTTP Request

GET /asset/v1/private/deposit/record/query

Request Parameters

Parameter Required Type Comment
start_time false long start time (In Seconds). Default value: 30 days before the current time
end_time false long end time (In Seconds). Default value: current time
coin false string coin name: for example, BTC. Default value: all
cursor false string cursor infomation: used for pagination. Default value: ""
direction false string prev page: Prev, next page: Next. Default value: Next
limit false long Number of items per page, 0< limit <=50. Default value: 50
timestamp true long timestamp

Response Parameters

Parameter Type Comment
coin string deposit coin
chain string chain name
amount string deposit amount
tx_id string transaction ID. It is "" when deposit failed or deposit cancelled
status int

0=unknown
1=ToBeConfirmed
2=processing
3=success
4=deposit failed

to_address string deposit target address
tag string tag of deposit target address
deposit_fee string deposit fee
success_at int64 last updated time
confirmations string number of confirmation blocks
tx_index string transaction sequence number
block_hash string hash number on the chain
cursor string cursor information: used for pagination. Default value: ""

Query Withdraw Records

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/private/withdraw/record/query?api_key=XXXXXXXXXXX&coin=LTC&limit=1&timestamp=1641789839632&recv_window=50000&sign=XXXXXXXXXXX'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "rows": [
            {
                "coin": "LTC",
                "chain": "LTC",
                "amount": "0.157",
                "tx_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "status": "success",
                "to_address": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "tag": "",
                "withdraw_fee": "0.001",
                "create_time": "1631694166",
                "update_time": "1631694775",
                "withdraw_id":"301121231312"
            },
            {
                "coin": "LTC",
                "chain": "LTC",
                "amount": "0.159",
                "tx_id": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "status": "success",
                "toAddress": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
                "tag": "",
                "withdraw_fee": "0.001",
                "create_time": "1631684557",
                "update_time": "1631685384",
                "withdraw_id":"301121231313"
            }
        ],
        "cursor": "eyJtaW5JRCI6MjAxNTM1MywibWF4SUQiOjIwMTU4OTF9"
    },
    "ext_info": null,
    "time_now": 1640921464384,
    "rate_limit_status": 117,
    "rate_limit_reset_ms": 1640921464384,
    "rate_limit": 3
}

Rule: order by id in reverse order. The maximum difference between the start time and the end time is 30 days.

HTTP Request

GET /asset/v1/private/withdraw/record/query

Request Parameters

Parameter Required Type Comment
withdraw_id false long withdrawal id. (withdraw request ID in Response Parameters of Withdrawal endpoint)
start_time false long start time (In Seconds). Default value: 30 days before the current time
end_time false long end time (In Seconds). Default value: current time
coin false string coin name: for example, BTC. Default value: all
withdraw_type false string 0(default):on chain. 1:off chain. 2:on and off chain
cursor false string cursor infomation: used for pagination. Default value: ""
direction false string prev page: Prev, next page: Next. Default value: Next
limit false long Number of items per page, 0< limit <=50. Default value: 50

Response Parameters

Parameter Type Comment
coin string withdrawal coin
chain string chain name
amount string withdrawal quantity
tx_id string transaction ID. It returns "" when withdrawal failed, withdrawal cancelled or internal transfer
status string withdrawal status
to_address string withdrawal target address. It shows email or mobile number for internal transfer
tag string tag of withdrawal target address
withdraw_fee string withdrawal fee
create_time int64 withdrawal create time
update_time int64 withdrawal status updated time
cursor string cursor information: used for pagination. Default value: ""
withdraw_id string withdrawal id. (withdraw request ID in Response Parameters of Withdrawal endpoint)
withdraw_type int Withdraw type. 0:on chain; 1:internal address transfer

Query Coin Information

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/private/coin-info/query?api_key=XXXXXXXXXXXXXXXXXXXXXXX&timestamp=1641793091931&recv_window=50000&sign=XXXXXXXXXXXXXXXXXXXXXXX'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "rows": [
            {
                "name": "USDT",
                "coin": "USDT",
                "remain_amount": "99999",
                "chains": [
                    {
                        "chain_type": "ETH",
                        "confirmation": "1",
                        "withdraw_fee": "10",
                        "deposit_min": "0.002",
                        "withdraw_min": "20",
                        "chain": "ETH"
                    },
                    {
                        "chain_type": "OMNI",
                        "confirmation": "1",
                        "withdraw_fee": "",
                        "deposit_min": "1",
                        "withdraw_min": "",
                        "chain": "OMNI"
                    }
                ]
            }
        ]
    },
    "ext_info": null,
    "time_now": 1641541870237,
    "rate_limit_status": 119,
    "rate_limit_reset_ms": 1641541870237,
    "rate_limit": 1
}

Rules: order by id in reverse order, no pagination required. The frequency limit is consistent with the current online interface.

HTTP Request

GET /asset/v1/private/coin-info/query

Request Parameters

Parameter Required Type Comment
coin false string Coin

Response Parameters

Parameter Type Comment
name string Name
coin string Coin
remain_amount string Current maximum withdrawal amount
chains List Object
chain_type string chain type
confirmation int deposit confirmation number
withdraw_fee string withdraw fee. if withdraw fee is empty, It means that this coin does not support withdrawal
deposit_min string minimum deposit amount
withdraw_min string minimum withdrawal amount
chain string chain name

Query Asset Information

Request Example

curl --location --request GET 'https://api-testnet.bybit.com/asset/v1/private/asset-info/query?api_key=XXXXXXXXXXXXXXX&coin=BIT&timestamp=1641790155961&recv_window=50000&sign=XXXXXXXXXXXXXXX'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "spot": {
            "status": "ACCOUNT_STATUS_NORMAL",
            "assets": [
                {
                    "coin": "BIT",
                    "frozen": "0",
                    "free": "90.62928",
                    "withdraw": ""
                }
            ]
        }
    },
    "ext_info": null,
    "time_now": 1641544103244,
    "rate_limit_status": 56,
    "rate_limit_reset_ms": 1641544103244,
    "rate_limit": 4
}

HTTP Request

GET /asset/v1/private/asset-info/query

Request Parameters

Parameter Required Type Comment
account_type false string Account type. Default value: ACCOUNT_TYPE_SPOT
coin false string Coin

Response Parameters

Parameter Type Comment
status string

status: ACCOUNT_STATUS_NORMAL -- NORMAL
ACCOUNT_STATUS_UNSPECIFIED -- ABNORMAL

assets List Object
coin string coin
frozen string frozen balance
free string available balance
withdraw string temporarily ""

Withdraw

Request Example

curl --location --request POST 'https://api-testnet.bybit.com/asset/v1/private/withdraw' \
--header 'Content-Type: application/json' \
--data-raw '{
    "address": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
    "amount": "0.153",
    "coin": "LTC",
    "chain": "LTC",
    "sign": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
    "timestamp": "1641789512739",
    "api_key": "XXXXXXXXXXXXXXXXXXXXXXXXXX",
    "recv_window": "50000"
}'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "id": "3912530"
    },
    "ext_info": null,
    "time_now": 1641793038330,
    "rate_limit_status": 2,
    "rate_limit_reset_ms": 1641793038330,
    "rate_limit": 1
}

HTTP Request

POST /asset/v1/private/withdraw

content-type: application/json

Request Parameters

Parameter Required Type Comment
coin true string Coin
chain true string chain name
address true string address. Address verification whether there is a whitelist of withdrawal addresses
tag false string Need to fill in if there is a tag
amount true string withdraw amounts. Rules: Greater than or equal to the minimum withdrawal amount. The minimum withdrawal amount can be obtained from the Coin Info Query API
force_chain false int Force to withdraw on chain or not. 0:If parsed as internal address, then internal transfer (by default);1:Force withdraw on chain
account_type false string Select the wallet to be withdrawn from
  • SPOT:spot wallet (default)
  • FUND:Funding wallet

Response Parameters

Parameter Type Comment
result Object result object
id int64 withdrawal id. (withdraw request ID in Response Parameters of Withdrawal endpoint)

Cancel withdrawal

Request Example

curl --location --request POST 'https://api-testnet.bybit.com/asset/v1/private/withdraw/cancel' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id":234234324234,
    "sign": "XXXXXXXXXXXXXXXXXXXXX",
    "timestamp": "1641790660020",
    "api_key": "XXXXXXXXXXXXXXXXXXXXX",
    "recv_window": "50000"
}'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {},
    "ext_info": null,
    "time_now": 1641798821116,
    "rate_limit_status": 9,
    "rate_limit_reset_ms": 1641798821116,
    "rate_limit": 1
}

HTTP Request

POST /asset/v1/private/withdraw/cancel

content-type:application/json

Request Parameters

Parameter Required Type Comment
id true int64 withdrawal id. (withdraw request ID in Response Parameters of Withdrawal endpoint)

Response Parameters

Parameter Type Comment
result int result(cancel application result: 1 SUCCESS, 0 FAIL)

Query Master Acct Deposit Address Information

Request Example

curl --location --request GET 'https://api.bybit.com/asset/v1/private/deposit/address?api_key=XXXXXXXXX&coin=GMT&timestamp=1663074198991&recv_window=5000&sign=73f79d2d8c0d41dddc30fd118b5da0db3fe92deb2f4ea39cd3dbbb8f3745f8b1&chain_type=SOL'

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "result": {
        "coin": "GMT",
        "chains": [
            {
                "chain_type": "SOL",
                "address_deposit": "H29uWKkPVux8nkB5xKU1DVxbEtt1UyMjC6tHsPHbMRsn",
                "tag_deposit": "",
                "chain": "SOL"
            }
        ]
    },
    "ext_info": null,
    "time_now": 1663074199341
}

HTTP Request

GET /asset/v1/private/deposit/address

Request Parameters

Parameter Required Type Comment
coin true string Coin
chain_type false string chain type

Response Parameters

Parameter Type Comment
result Object result object
coin string Coin
chains List Object
chain_type string chain type
address_deposit string deposit address
tag_deposit string deposit tag
chain string chain name

API Data Endpoints

The following API data endpoints do not require authentication.

Server Time

Request Example

curl https://api-testnet.bybit.com/v2/public/time
from pybit import inverse_perpetual
session_unauth = inverse_perpetual.HTTP(
    endpoint="https://api-testnet.bybit.com"
)
print(session_unauth.server_time())  

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": {},
    "time_now": "1577444332.192859"
}

Get Bybit server time.

HTTP Request

GET /v2/public/time

Request Parameters

Parameter Required Type Comment

Announcement

Request Example

curl https://api-testnet.bybit.com/v2/public/announcement
from pybit import inverse_perpetual
session_unauth = inverse_perpetual.HTTP(
    endpoint="https://api-testnet.bybit.com"
)
print(session_unauth.announcement())  

Response Example

{
    "ret_code": 0,
    "ret_msg": "OK",
    "ext_code": "",
    "ext_info": "",
    "result": [
        {
            "id": 2,
            "title": "2019-12-02 RELEASE",
            "link": "https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/CHANGELOG.md",
            "summary": "<p>New `cancel all` endpoint is here now!</p><p>Additionally, we strongly recommend that you use the new released place and cancel active V2 endpoints, which are more stable and efficient.The old ones are deprecated (although still working for the time be",
            "created_at": "2019-12-02T11:33:42Z"
        }
    ],
    "time_now": "1577444818.227082"
}

Get Bybit OpenAPI announcements in the last 30 days in reverse order.

HTTP Request

GET /v2/public/announcement

Request Parameters

Parameter Required Type Comment

Rate Limits

IP Rate Limit

Bybit has different IP frequency limits depending on the request method. We do not recommend running your application at the very edge of these limits in case abnormal network activity results in an unexpected violation.

All traffic to api.bybit.com or api.bytick.com share this limit regardless of if it accesses Spot, Derivatives or Options.

After violating the limit your IP will be banned for a set period of time (usually 30 minutes). Continually violating the limit will result in a permanent ban. We cannot undo permanent bans or shorten temporary bans.

API Rate Limit

The API rate limit is based on the rolling time window per minute and UID, and each symbol is independent. In other words, it's per minute per UID per symbol. Every request to the API returns the fields shown in the code panel:

Rate Limits For Transfer Endpoints

Limit Path Consume
20/min /asset/v1/private/transfer 1 / request
20/min /asset/v1/private/sub-member/transfer 1 / request
60/min /asset/v1/private/sub-member/member-ids 1 / request
60/min /asset/v1/private/transfer/list 1 / request
60/min /asset/v1/private/sub-member/transfer/list 1 / request

Rate Limits For Withdraw and Deposit Endpoints

Limit Path Consume
3/min /asset/v1/private/withdraw 1 / request
10/min /asset/v1/private/withdraw/cancel 1 / request
30/min /asset/v1/private/deposit/address 1 / request
60/min /asset/v1/private/asset-info/query 1 / request
/asset/v1/private/deposit/record/query 1 / request
120/min /asset/v1/private/withdraw/record/query 1 / request
/asset/v1/private/coin-info/query 1 / request

Enums Definitions

The following lists enumerator names for the request and response parameters of each endpoint.

Account type (from_account_type/to_account_type)

Withdraw status(status)

Currency (currency/coin)

Operator type

Transfer type (type)

Transfer status (status)

Page direction (direction)

Errors

The Bybit API uses the following HTTP codes and error codes:

HTTP Code Meaning
200 Request is valid
403 Access denied
404 Request path not found

0

SUCCESS

10001

Parameter error

10003

Invalid api key

10004

Invalid sign

10005

Permission denied for current apikey. API key was created without the correct permissions (e.g. doesn´t have Order permission, or it's set to read-only)

10006

Too many visits. Refer to the API rate limit. Please use WebSocket for live updates. Current limit is %s requests per minute.

10016

service is not available

38000

Processing

38001

Insufficient available balance

38002

Unable to transfer

90001

The transfer amount is less than 0

90002

The transfer amount accuracy is greater than 8

90003

Transfer error, please contact customer service (upper limit of transfer amount exceeded. please refer to Over the counter (OTC) Lending)

90004

Account not found

90005

Check balance error

90006

Query transfer error

90007

Query sub-account transfer error

90008

Query transfer ID error

90009

Transfer ID already exists

90010

The transfer-in account type cannot be used as the transfer-out account type

90011

Failed to get the list of subaccounts

90012

Query withdrawal record error

90013

Query recharge record error

90014

Not support subaccounts temporarily

90015

This currency cannot be topped up

90016

Recharge chain query error

90029

Users in the gray period are not on the whitelist

90030

The withdrawal address is not in the whitelist

90031

User status is abnormal

90032

User sensitive operation, withdrawal is prohibited within 24 hours

90033

The system is under maintenance

90034

Withdrawal of this currency has been closed

90035

The withdrawal amount is less than the lower limit of a single withdrawal

90036

The withdrawal amount is greater than the upper limit of a single withdrawal

90037

Exceeded the upper limit of the platform's withdrawal limit on the day

90038

Kyc limit exceeded

90039

Spot market makers withdraw excess cash

90040

Withdrawal is being processed

90041

Spot account does not exist

90042

Insufficient available balance in spot account

90043

Insufficient available balance in contract account

90044

Withdrawal failed

90045

The withdrawal record does not exist

90046

The withdrawal initiator is inconsistent

90047

Hot wallet status cannot be cancelled

90048

The withdrawal status does not allow cancellation

90049

Failed to cancel withdrawal and add money

90050

Blocked login status does not allow withdrawals

90051

User withdrawal is blocked

90052

Replay request denied

90100

your balance is not enough, please check transfer safe amount