0.2.10 • Published 2 years ago

@serviceru/bybit_api v0.2.10

Weekly downloads
-
License
Unlicense
Repository
github
Last release
2 years ago

bybit_api

BybitApi - JavaScript client for bybit_api

REST API for the Bybit Exchange. Base URI: https://api.bybit.com

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

For Node.js

npm

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

ClassMethodHTTP requestDescription
BybitApi.APIkeyApiaPIkeyInfoGET /open-api/api-keyGet account api-key information.
BybitApi.CommonApicommonAnnouncementsGET /v2/public/announcementGet Bybit OpenAPI announcements in the last 30 days in reverse order.
BybitApi.CommonApicommonGetLcpGET /v2/private/account/lcpQuery LCP info.
BybitApi.CommonApicommonGetTimeGET /v2/public/timeGet bybit server time.
BybitApi.ConditionalApiconditionalCancelPOST /v2/private/stop-order/cancelCancel conditional order.
BybitApi.ConditionalApiconditionalCancelAllPOST /v2/private/stop-order/cancelAllCancel conditional order.
BybitApi.ConditionalApiconditionalGetOrdersGET /v2/private/stop-order/listGet my conditional order list.
BybitApi.ConditionalApiconditionalNewPOST /v2/private/stop-order/createPlace a new conditional order.
BybitApi.ConditionalApiconditionalQueryGET /v2/private/stop-orderQuery real-time stop order information.
BybitApi.ConditionalApiconditionalReplacePOST /v2/private/stop-order/replaceReplace conditional order. Only incomplete orders can be modified.
BybitApi.ExecutionApiexecutionGetTradesGET /v2/private/execution/listGet user’s trade records.
BybitApi.ExecutionApipositionsClosePnlRecordsGET /v2/private/trade/closed-pnl/listGet user's closed profit and loss records
BybitApi.FundingApifundingMyLastFeeGET /open-api/funding/prev-fundingFunding 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.FundingApifundingPredictedGET /open-api/funding/predicted-fundingGet predicted funding rate and funding fee.
BybitApi.FundingApifundingPrevRateGET /open-api/funding/prev-funding-rateGet predicted funding rate and funding fee.
BybitApi.KlineApiklineGetGET /v2/public/kline/listQuery historical kline.
BybitApi.KlineApiklineMarkPriceGET /v2/public/mark-price-klineQuery mark price kline.
BybitApi.LinearConditionalApilinearConditionalCancelPOST /private/linear/stop-order/cancelCancel Active Order
BybitApi.LinearConditionalApilinearConditionalCancelAllPOST /private/linear/stop-order/cancel-allCancel all stop orders.
BybitApi.LinearConditionalApilinearConditionalGetOrdersGET /private/linear/stop-order/listGet linear Stop Orders
BybitApi.LinearConditionalApilinearConditionalNewPOST /private/linear/stop-order/createCreate linear stop Order
BybitApi.LinearConditionalApilinearConditionalQueryGET /private/linear/stop-order/searchGet Stop Orders(real-time)
BybitApi.LinearConditionalApilinearConditionalReplacePOST /private/linear/stop-order/replaceReplace conditional order
BybitApi.LinearExecutionApilinearExecutionGetTradesGET /private/linear/trade/execution/listGet user's trading records.
BybitApi.LinearFundingApilinearFundingMyLastFeeGET /private/linear/funding/prev-fundingGet prev funding
BybitApi.LinearFundingApilinearFundingPredictedGET /private/linear/funding/predicted-fundingGet predicted funding rate and funding fee.
BybitApi.LinearFundingApilinearFundingPrevRateGET /public/linear/funding/prev-funding-rateGet prev funding
BybitApi.LinearKlineApilinearKlineGetGET /public/linear/klineGet kline
BybitApi.LinearKlineApilinearKlineMarkPriceGET /public/linear/mark-price-klineGet kline
BybitApi.LinearMarketApilinearMarketTradingGET /public/linear/recent-trading-recordsGet recent trades
BybitApi.LinearOrderApilinearOrderCancelPOST /private/linear/order/cancelCancel Active Order
BybitApi.LinearOrderApilinearOrderCancelAllPOST /private/linear/order/cancel-allCancel all active orders.
BybitApi.LinearOrderApilinearOrderGetOrdersGET /private/linear/order/listGet linear Active Orders
BybitApi.LinearOrderApilinearOrderNewPOST /private/linear/order/createCreate Active Order
BybitApi.LinearOrderApilinearOrderQueryGET /private/linear/order/searchGet Active Orders(real-time)
BybitApi.LinearOrderApilinearOrderReplacePOST /private/linear/order/replaceReplace Active Order
BybitApi.LinearPositionsApilinearPositionsChangeMarginPOST /private/linear/position/add-marginAdd/Reduce Margin
BybitApi.LinearPositionsApilinearPositionsClosePnlRecordsGET /private/linear/trade/closed-pnl/listGet user's closed profit and loss records.
BybitApi.LinearPositionsApilinearPositionsMyPositionGET /private/linear/position/listGet my position list.
BybitApi.LinearPositionsApilinearPositionsSaveLeveragePOST /private/linear/position/set-leverageSet leverage
BybitApi.LinearPositionsApilinearPositionsSetAutoAddMarginPOST /private/linear/position/set-auto-add-marginSet auto add margin
BybitApi.LinearPositionsApilinearPositionsSwitchIsolatedPOST /private/linear/position/switch-isolatedSwitch isolated
BybitApi.LinearPositionsApilinearPositionsSwitchModePOST /private/linear/tpsl/switch-modeSwitch Mode
BybitApi.LinearPositionsApilinearPositionsTradingStopPOST /private/linear/position/trading-stopSet tradingStop
BybitApi.LinearWalletApilinearWalletGetRiskLimitGET /public/linear/risk-limitGet risk limit.
BybitApi.MarketApimarketAccountRatioGET /v2/public/account-ratioQuery Account Long Short Ratio
BybitApi.MarketApimarketBigDealGET /v2/public/big-dealQuery Big Deal
BybitApi.MarketApimarketLiqRecordsGET /v2/public/liq-recordsQuery liq records.
BybitApi.MarketApimarketOpenInterestGET /v2/public/open-interestQuery Open Interest
BybitApi.MarketApimarketOrderbookGET /v2/public/orderBook/L2Get the orderbook.
BybitApi.MarketApimarketSymbolInfoGET /v2/public/tickersGet the latest information for symbol.
BybitApi.MarketApimarketTradingRecordsGET /v2/public/trading-recordsGet recent trades
BybitApi.OrderApiorderCancelPOST /v2/private/order/cancelGet my active order list.
BybitApi.OrderApiorderCancelAllPOST /v2/private/order/cancelAllGet my active order list.
BybitApi.OrderApiorderGetOrdersGET /v2/private/order/listGet my active order list.
BybitApi.OrderApiorderNewPOST /v2/private/order/createPlace active order
BybitApi.OrderApiorderQueryGET /v2/private/orderGet my active order list.
BybitApi.OrderApiorderReplacePOST /v2/private/order/replaceReplace active order. Only incomplete orders can be modified.
BybitApi.PositionsApipositionsChangeMarginPOST /position/change-position-marginUpdate margin.
BybitApi.PositionsApipositionsClosePnlRecordsGET /v2/private/trade/closed-pnl/listGet user's closed profit and loss records
BybitApi.PositionsApipositionsMyPositionGET /v2/private/position/listGet my position list.
BybitApi.PositionsApipositionsSaveLeveragePOST /user/leverage/saveChange user leverage.
BybitApi.PositionsApipositionsTradingStopPOST /open-api/position/trading-stopSet Trading-Stop Condition.
BybitApi.SymbolApisymbolGetGET /v2/public/symbolsQuery Symbols.
BybitApi.WalletApiwalletExchangeOrderGET /v2/private/exchange-order/listAsset Exchange Records
BybitApi.WalletApiwalletGetBalanceGET /v2/private/wallet/balanceget wallet balance info
BybitApi.WalletApiwalletGetRecordsGET /open-api/wallet/fund/recordsGet wallet fund records
BybitApi.WalletApiwalletGetRiskLimitGET /open-api/wallet/risk-limit/listGet risk limit.
BybitApi.WalletApiwalletSetRiskLimitPOST /open-api/wallet/risk-limitSet risk limit
BybitApi.WalletApiwalletWithdrawGET /open-api/wallet/withdraw/listGet wallet fund records

Documentation for Models

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