0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

swagger-clientでBitMEXトレードしたい

Last updated at Posted at 2018-12-04

Swagger概要

  • REST APIの標準。デファクトスタンダード(だった?)
  • APIの定義を書くとドキュメントとインターフェース部のソースが自動生成される
  • いろいろあって、2018年フォークした
  • OpenAPI Generator - community drivenで成長するコードジェネレータ
  • https://ackintosh.github.io/blog/2018/05/12/openapi-generator/

Node.jsでのチュートリアル(document, api)

クライアント swagger-client

swagger-client、メソッドの一覧

参考:メソッド一覧(一部異なる)
https://github.com/BitMEX/api-connectors/tree/master/auto-generated/javascript

利用方法のサンプル
https://github.com/BitMEX/api-connectors/blob/master/official-http/node-swagger/swaggerClient.js

inspect(client.apis)でメソッド一覧を出力

swaggerClient.js
new SwaggerClient({
  // Switch this to `www.bitmex.com` when you're ready to try it out for real.
  // Don't forget the `www`!
  url: 'https://testnet.bitmex.com/api/explorer/swagger.json',
  usePromise: true
})
.then(function(client) {
  // Comment out if you're not requesting any user data.
  client.clientAuthorizations.add("apiKey", new BitMEXAPIKeyAuthorization('api-key', 'api-secret'));

  // Print client capabilities
  inspect(client.apis); // ← メソッド一覧を出力

出力結果を整形した
引数・戻り値等の詳細はswaggerドキュメント参照
https://www.bitmex.com/api/explorer/

Inspecting BitMEX API...
 [Announcement] :
    Announcement_get, Announcement_getUrgent
 [APIKey] :
    APIKey_remove, APIKey_get, APIKey_new, APIKey_disable, APIKey_enable
 [Chat] :
    Chat_get, Chat_new, Chat_getChannels, Chat_getConnected
 [Execution] :
    Execution_get, Execution_getTradeHistory
 [Funding] :
    Funding_get
 [Instrument] :
    Instrument_get, Instrument_getActive, Instrument_getIndices, Instrument_getActiveAndIndices, 
    Instrument_getActiveIntervals, Instrument_getCompositeIndex
 [Insurance] :
    Insurance_get
 [Leaderboard] :
    Leaderboard_get, Leaderboard_getName
 [Liquidation] :
    Liquidation_get
 [GlobalNotification] :
    GlobalNotification_get
 [Order] :
    Order_cancel, Order_getOrders, Order_new, Order_amend, Order_newBulk, Order_amendBulk, 
    Order_closePosition, Order_cancelAll, Order_cancelAllAfter
 [OrderBook] :
    OrderBook_getL2
 [Position] :
    Position_get, Position_isolateMargin, Position_updateRiskLimit, Position_transferIsolatedMargin, 
    Position_updateLeverage
 [Quote] :
    Quote_get, Quote_getBucketed
 [Schema] :
    Schema_get, Schema_websocketHelp
 [Settlement] :
    Settlement_get
 [Stats] :
    Stats_get, Stats_history, Stats_historyUSD
 [Trade] :
    Trade_get, Trade_getBucketed
 [User] :
    User_getDepositAddress, User_getWallet, User_getWalletHistory, User_getWalletSummary, 
    User_getExecutionHistory, User_minWithdrawalFee, User_requestWithdrawal, User_cancelWithdrawal, 
    User_confirmWithdrawal, User_requestEnableTFA, User_confirmEnableTFA, User_disableTFA, User_confirm, 
    User_getAffiliateStatus, User_checkReferralCode, User_logout, User_logoutAll, User_savePreferences, 
    User_get, User_update, User_getCommission, User_getMargin, User_communicationToken
 [UserEvent] :
    UserEvent_get   
------------------------
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?