bybit_api
BybitApi - JavaScript client for bybit_api
https://api.bybit.com]
REST API for the Bybit Exchange. Base URI: [This SDK is automatically generated by the Swagger Codegen project:
- API version: 0.2.10
- Package version: 0.2.10
- Build package: io.swagger.codegen.languages.JavascriptClientCodegen
Installation
Node.js
Fornpm
To publish the library as a npm, please follow the procedure in "Publishing npm packages".
Then install it via:
npm install bybit_api --save
Local development
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing
into the directory containing package.json
(and this README). Let's call this JAVASCRIPT_CLIENT_DIR
. Then run:
npm install
Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR
:
npm link
Finally, switch to the directory you want to use your bybit_api from, and run:
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
You should now be able to require('bybit_api')
in javascript files from the directory you ran the last
command above from.
git
If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:
npm install GIT_USER_ID/GIT_REPO_ID --save
For browser
The library also works in the browser environment via npm and browserify. After following
the above steps with Node.js and installing browserify with npm install -g browserify
,
perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually
use this library):
browserify main.js > bundle.js
Then include bundle.js in the HTML pages.
Webpack Configuration
Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
Getting Started
Please follow the installation instruction and execute the following JS code:
var BybitApi = require('bybit_api');
var defaultClient = BybitApi.ApiClient.instance;
// Configure API key authorization: apiKey
var apiKey = defaultClient.authentications['apiKey'];
apiKey.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix['api_key'] = "Token"
// Configure API key authorization: apiSignature
var apiSignature = defaultClient.authentications['apiSignature'];
apiSignature.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiSignature.apiKeyPrefix['sign'] = "Token"
// Configure API key authorization: timestamp
var timestamp = defaultClient.authentications['timestamp'];
timestamp.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//timestamp.apiKeyPrefix['timestamp'] = "Token"
var api = new BybitApi.APIkeyApi()
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.aPIkeyInfo(callback);
Documentation for API Endpoints
All URIs are relative to https://api.bybit.com
Class | Method | HTTP request | Description |
---|---|---|---|
BybitApi.APIkeyApi | aPIkeyInfo | GET /open-api/api-key | Get account api-key information. |
BybitApi.CommonApi | commonAnnouncements | GET /v2/public/announcement | Get Bybit OpenAPI announcements in the last 30 days in reverse order. |
BybitApi.CommonApi | commonGetLcp | GET /v2/private/account/lcp | Query LCP info. |
BybitApi.CommonApi | commonGetTime | GET /v2/public/time | Get bybit server time. |
BybitApi.ConditionalApi | conditionalCancel | POST /v2/private/stop-order/cancel | Cancel conditional order. |
BybitApi.ConditionalApi | conditionalCancelAll | POST /v2/private/stop-order/cancelAll | Cancel conditional order. |
BybitApi.ConditionalApi | conditionalGetOrders | GET /v2/private/stop-order/list | Get my conditional order list. |
BybitApi.ConditionalApi | conditionalNew | POST /v2/private/stop-order/create | Place a new conditional order. |
BybitApi.ConditionalApi | conditionalQuery | GET /v2/private/stop-order | Query real-time stop order information. |
BybitApi.ConditionalApi | conditionalReplace | POST /v2/private/stop-order/replace | Replace conditional order. Only incomplete orders can be modified. |
BybitApi.ExecutionApi | executionGetTrades | GET /v2/private/execution/list | Get user’s trade records. |
BybitApi.ExecutionApi | positionsClosePnlRecords | GET /v2/private/trade/closed-pnl/list | Get user's closed profit and loss records |
BybitApi.FundingApi | fundingMyLastFee | GET /open-api/funding/prev-funding | Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC. The current interval's fund fee settlement is based on the previous interval's fund rate. For example, at 16:00, the settlement is based on the fund rate generated at 8:00. The fund rate generated at 16:00 will be used at 0:00 on the next day. |
BybitApi.FundingApi | fundingPredicted | GET /open-api/funding/predicted-funding | Get predicted funding rate and funding fee. |
BybitApi.FundingApi | fundingPrevRate | GET /open-api/funding/prev-funding-rate | Get predicted funding rate and funding fee. |
BybitApi.KlineApi | klineGet | GET /v2/public/kline/list | Query historical kline. |
BybitApi.KlineApi | klineMarkPrice | GET /v2/public/mark-price-kline | Query mark price kline. |
BybitApi.LinearConditionalApi | linearConditionalCancel | POST /private/linear/stop-order/cancel | Cancel Active Order |
BybitApi.LinearConditionalApi | linearConditionalCancelAll | POST /private/linear/stop-order/cancel-all | Cancel all stop orders. |
BybitApi.LinearConditionalApi | linearConditionalGetOrders | GET /private/linear/stop-order/list | Get linear Stop Orders |
BybitApi.LinearConditionalApi | linearConditionalNew | POST /private/linear/stop-order/create | Create linear stop Order |
BybitApi.LinearConditionalApi | linearConditionalQuery | GET /private/linear/stop-order/search | Get Stop Orders(real-time) |
BybitApi.LinearConditionalApi | linearConditionalReplace | POST /private/linear/stop-order/replace | Replace conditional order |
BybitApi.LinearExecutionApi | linearExecutionGetTrades | GET /private/linear/trade/execution/list | Get user's trading records. |
BybitApi.LinearFundingApi | linearFundingMyLastFee | GET /private/linear/funding/prev-funding | Get prev funding |
BybitApi.LinearFundingApi | linearFundingPredicted | GET /private/linear/funding/predicted-funding | Get predicted funding rate and funding fee. |
BybitApi.LinearFundingApi | linearFundingPrevRate | GET /public/linear/funding/prev-funding-rate | Get prev funding |
BybitApi.LinearKlineApi | linearKlineGet | GET /public/linear/kline | Get kline |
BybitApi.LinearKlineApi | linearKlineMarkPrice | GET /public/linear/mark-price-kline | Get kline |
BybitApi.LinearMarketApi | linearMarketTrading | GET /public/linear/recent-trading-records | Get recent trades |
BybitApi.LinearOrderApi | linearOrderCancel | POST /private/linear/order/cancel | Cancel Active Order |
BybitApi.LinearOrderApi | linearOrderCancelAll | POST /private/linear/order/cancel-all | Cancel all active orders. |
BybitApi.LinearOrderApi | linearOrderGetOrders | GET /private/linear/order/list | Get linear Active Orders |
BybitApi.LinearOrderApi | linearOrderNew | POST /private/linear/order/create | Create Active Order |
BybitApi.LinearOrderApi | linearOrderQuery | GET /private/linear/order/search | Get Active Orders(real-time) |
BybitApi.LinearOrderApi | linearOrderReplace | POST /private/linear/order/replace | Replace Active Order |
BybitApi.LinearPositionsApi | linearPositionsChangeMargin | POST /private/linear/position/add-margin | Add/Reduce Margin |
BybitApi.LinearPositionsApi | linearPositionsClosePnlRecords | GET /private/linear/trade/closed-pnl/list | Get user's closed profit and loss records. |
BybitApi.LinearPositionsApi | linearPositionsMyPosition | GET /private/linear/position/list | Get my position list. |
BybitApi.LinearPositionsApi | linearPositionsSaveLeverage | POST /private/linear/position/set-leverage | Set leverage |
BybitApi.LinearPositionsApi | linearPositionsSetAutoAddMargin | POST /private/linear/position/set-auto-add-margin | Set auto add margin |
BybitApi.LinearPositionsApi | linearPositionsSwitchIsolated | POST /private/linear/position/switch-isolated | Switch isolated |
BybitApi.LinearPositionsApi | linearPositionsSwitchMode | POST /private/linear/tpsl/switch-mode | Switch Mode |
BybitApi.LinearPositionsApi | linearPositionsTradingStop | POST /private/linear/position/trading-stop | Set tradingStop |
BybitApi.LinearWalletApi | linearWalletGetRiskLimit | GET /public/linear/risk-limit | Get risk limit. |
BybitApi.MarketApi | marketAccountRatio | GET /v2/public/account-ratio | Query Account Long Short Ratio |
BybitApi.MarketApi | marketBigDeal | GET /v2/public/big-deal | Query Big Deal |
BybitApi.MarketApi | marketLiqRecords | GET /v2/public/liq-records | Query liq records. |
BybitApi.MarketApi | marketOpenInterest | GET /v2/public/open-interest | Query Open Interest |
BybitApi.MarketApi | marketOrderbook | GET /v2/public/orderBook/L2 | Get the orderbook. |
BybitApi.MarketApi | marketSymbolInfo | GET /v2/public/tickers | Get the latest information for symbol. |
BybitApi.MarketApi | marketTradingRecords | GET /v2/public/trading-records | Get recent trades |
BybitApi.OrderApi | orderCancel | POST /v2/private/order/cancel | Get my active order list. |
BybitApi.OrderApi | orderCancelAll | POST /v2/private/order/cancelAll | Get my active order list. |
BybitApi.OrderApi | orderGetOrders | GET /v2/private/order/list | Get my active order list. |
BybitApi.OrderApi | orderNew | POST /v2/private/order/create | Place active order |
BybitApi.OrderApi | orderQuery | GET /v2/private/order | Get my active order list. |
BybitApi.OrderApi | orderReplace | POST /v2/private/order/replace | Replace active order. Only incomplete orders can be modified. |
BybitApi.PositionsApi | positionsChangeMargin | POST /position/change-position-margin | Update margin. |
BybitApi.PositionsApi | positionsClosePnlRecords | GET /v2/private/trade/closed-pnl/list | Get user's closed profit and loss records |
BybitApi.PositionsApi | positionsMyPosition | GET /v2/private/position/list | Get my position list. |
BybitApi.PositionsApi | positionsSaveLeverage | POST /user/leverage/save | Change user leverage. |
BybitApi.PositionsApi | positionsTradingStop | POST /open-api/position/trading-stop | Set Trading-Stop Condition. |
BybitApi.SymbolApi | symbolGet | GET /v2/public/symbols | Query Symbols. |
BybitApi.WalletApi | walletExchangeOrder | GET /v2/private/exchange-order/list | Asset Exchange Records |
BybitApi.WalletApi | walletGetBalance | GET /v2/private/wallet/balance | get wallet balance info |
BybitApi.WalletApi | walletGetRecords | GET /open-api/wallet/fund/records | Get wallet fund records |
BybitApi.WalletApi | walletGetRiskLimit | GET /open-api/wallet/risk-limit/list | Get risk limit. |
BybitApi.WalletApi | walletSetRiskLimit | POST /open-api/wallet/risk-limit | Set risk limit |
BybitApi.WalletApi | walletWithdraw | GET /open-api/wallet/withdraw/list | Get wallet fund records |
Documentation for Models
- BybitApi.APIKeyBase
- BybitApi.APIKeyInfo
- BybitApi.AccountRatio
- BybitApi.AccountRatioInfo
- BybitApi.Announcement
- BybitApi.AnnouncementInfo
- BybitApi.BigDeal
- BybitApi.BigDealInfo
- BybitApi.ClosedPnlBase
- BybitApi.ClosedPnlInfo
- BybitApi.ConditionalCancelAllBase
- BybitApi.ConditionalCancelAllRes
- BybitApi.ConditionalOrdersRes
- BybitApi.ConditionalOrdersResBase
- BybitApi.ConditionalRes
- BybitApi.ExchangeOrderList
- BybitApi.ExchangeOrderListBase
- BybitApi.ExtFields
- BybitApi.FundRecordBase
- BybitApi.FundingFeeBase
- BybitApi.FundingFeeRes
- BybitApi.FundingPredicted
- BybitApi.FundingPredictedBase
- BybitApi.FundingRate
- BybitApi.FundingRateBase
- BybitApi.FundingRecords
- BybitApi.GetRiskLimitRes
- BybitApi.KlineBase
- BybitApi.KlineRes
- BybitApi.LCPInfo
- BybitApi.LCPInfoBase
- BybitApi.Leverage
- BybitApi.LeverageInfo
- BybitApi.LeverageResult
- BybitApi.LinearCancelOrderResult
- BybitApi.LinearCancelOrderResultBase
- BybitApi.LinearCancelStopOrderResult
- BybitApi.LinearCancelStopOrderResultBase
- BybitApi.LinearClosePnlRecordsResponse
- BybitApi.LinearClosedPnlRecordResult
- BybitApi.LinearCreateOrderResult
- BybitApi.LinearCreateOrderResultBase
- BybitApi.LinearCreateStopOrderResult
- BybitApi.LinearCreateStopOrderResultBase
- BybitApi.LinearFundingPredicted
- BybitApi.LinearFundingPredictedBase
- BybitApi.LinearKlineResp
- BybitApi.LinearKlineRespBase
- BybitApi.LinearListOrderResult
- BybitApi.LinearListStopOrderResult
- BybitApi.LinearOrderCancelAllBase
- BybitApi.LinearOrderRecordsResponse
- BybitApi.LinearOrderRecordsResponseBase
- BybitApi.LinearOrderReplace
- BybitApi.LinearPositionListResult
- BybitApi.LinearPositionListResultBase
- BybitApi.LinearPrevFundingRateResp
- BybitApi.LinearPrevFundingRateRespBase
- BybitApi.LinearPrevFundingResp
- BybitApi.LinearPrevFundingRespBase
- BybitApi.LinearRecentTradingRecordResp
- BybitApi.LinearRecentTradingRecordRespBase
- BybitApi.LinearRiskLimitResp
- BybitApi.LinearRiskLimitRespBase
- BybitApi.LinearSearchOrderResult
- BybitApi.LinearSearchOrderResultBase
- BybitApi.LinearSearchStopOrderResult
- BybitApi.LinearSearchStopOrderResultBase
- BybitApi.LinearSetLeverageResult
- BybitApi.LinearSetMarginResult
- BybitApi.LinearSetMarginResultBase
- BybitApi.LinearSetTradingStopResult
- BybitApi.LinearStopOrderCancelAllBase
- BybitApi.LinearStopOrderRecordsResponse
- BybitApi.LinearStopOrderRecordsResponseBase
- BybitApi.LinearStopOrderReplace
- BybitApi.LinearSwitchIsolatedResult
- BybitApi.LinearSwitchModeResult
- BybitApi.LinearTradeRecordItem
- BybitApi.LinearTradeRecordsResponse
- BybitApi.LiqRecords
- BybitApi.LiqRecordsInfo
- BybitApi.LotSizeFilter
- BybitApi.MarkPriceKlineBase
- BybitApi.MarkPriceKlineInfo
- BybitApi.OderBookRes
- BybitApi.OpenInterest
- BybitApi.OpenInterestInfo
- BybitApi.OrderBookBase
- BybitApi.OrderCancelAllBase
- BybitApi.OrderCancelAllRes
- BybitApi.OrderCancelBase
- BybitApi.OrderIdRes
- BybitApi.OrderRes
- BybitApi.OrderResBase
- BybitApi.Position
- BybitApi.PositionInfo
- BybitApi.PriceFilter
- BybitApi.QueryOrderBase
- BybitApi.QueryOrderRes
- BybitApi.ReplaceConditionalBase
- BybitApi.ReplaceOrderBase
- BybitApi.RiskIDRes
- BybitApi.RiskLimitBase
- BybitApi.RiskLimitRes
- BybitApi.ServerTime
- BybitApi.SetRiskLimitBase
- BybitApi.StopOrderOrdersResBase
- BybitApi.SymbolInfo
- BybitApi.SymbolInfoBase
- BybitApi.SymbolTickInfo
- BybitApi.Symbols
- BybitApi.TradeRecords
- BybitApi.TradeRecordsBase
- BybitApi.TradeRecordsInfo
- BybitApi.TradingRecords
- BybitApi.TradingRecordsInfo
- BybitApi.TradingStopBase
- BybitApi.TradingStopRes
- BybitApi.V2CancelOrderBase
- BybitApi.V2ConditionalBase
- BybitApi.V2ConditionalListRes
- BybitApi.V2ConditionalRes
- BybitApi.V2OrderListBase
- BybitApi.V2OrderListData
- BybitApi.V2OrderRes
- BybitApi.WalletBalance
- BybitApi.WalletBalanceBase
- BybitApi.WithdrawRecords
- BybitApi.WithdrawResBase
Documentation for Authorization
apiKey
- Type: API key
- API key parameter name: api_key
- Location: URL query string
apiSignature
- Type: API key
- API key parameter name: sign
- Location: URL query string
timestamp
- Type: API key
- API key parameter name: timestamp
- Location: URL query string