Skip to content

Instantly share code, notes, and snippets.

@dsaki
Created May 8, 2017 03:25
Show Gist options
  • Save dsaki/f571aae1270893be3a10d5af35aca0ff to your computer and use it in GitHub Desktop.
Save dsaki/f571aae1270893be3a10d5af35aca0ff to your computer and use it in GitHub Desktop.
ライブラリ作成規則.md

新しい言語のライブラリを作るとき、メソッドの作成規則はここに書かれているとおりにしよう!(提案)

https://docs.bitbank.cc/

命名規則

APIdocの項目 キャメルケース スネークケース
GET /{pair}/ticker getTicker get_ticker
GET /{pair}/depth getDepth get_depth
GET /{pair}/transactions getTransactions get_transactions
GET /{pair}/transactions/{YYYYMMDD} getTransactions get_transactions
GET /{pair}/candlestick/{candle-type}/{YYYY} getCandleStick get_candle_stick
GET /user/assets getAssets get_assets
GET /user/spot/order getOrderInfo get_order_info
POST /user/spot/order sendOrder send_order
POST /user/spot/cancel_order cancelOrder cancel_order
POST /user/spot/cancel_orders cancelOrders cancel_orders
POST /user/spot/orders_info getOrdersInfo get_orders_info
GET /user/spot/active_orders getActiveOrders get_active_orders
GET /user/withdrawal_account getWithdrawalAccount get_withdrawal_account
POST /user/request_withdrawal requestWithdrawal request_withdrawal
  • 情報取得系は全部"get〜"にする
  • POST /user/spot/orders_infoは情報取得系なので"get〜"にする
  • 引数の命名はドキュメントに記載されているパラメータに合わせる(キャメルケースで実装している言語ではキャメルケースに直す)

実装ルール

  • ユーザが以下のようにクラスをインスタンス化することで利用できるように実装する
val bitbankcc = new Bitbankcc("API_KEY", "API_SECRET")
val ticker = bitbankcc.getTicker()
  • nonce値をクラス内のインスタンス変数で管理し、メソッドが呼ばれるたびにインクリメントして管理する
    • nonceの初期値はUNIXTIMEのミリ秒

その他のルール

  • APIドキュメントにあるAPIはすべて実装しよう
  • できればドキュメントに使い方を載せよう
  • スネークケースを使うかキャメルケースを使うかどうかは、言語毎の空気を読んで使い分けるって感じで ✋
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment