Bitmex RESTful APIs for Go
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
api extract auto-generated go api from BitMEX/api-connectors@046f973 Oct 14, 2018
docs fix more float32 types with int Oct 16, 2018
optional
.gitignore Initial commit Oct 14, 2018
LICENSE
README.md update doc with code examples Oct 17, 2018
api_announcement.go add a local optional package with mutable state to replace an externa… Oct 15, 2018
api_api_key.go add a local optional package with mutable state to replace an externa… Oct 15, 2018
api_chat.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_execution.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_funding.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_instrument.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_insurance.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_leaderboard.go add a local optional package with mutable state to replace an externa… Oct 15, 2018
api_liquidation.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_notification.go change package name from swagger to bitmexgo Oct 14, 2018
api_order.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_order_book.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_position.go fix more float32 types with int Oct 16, 2018
api_quote.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_schema.go
api_settlement.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_stats.go change package name from swagger to bitmexgo Oct 14, 2018
api_trade.go replace refs of optional.Float32 with the more appropriate optional.Int Oct 16, 2018
api_user.go fix one last float32 type Oct 16, 2018
client.go simplify auth and configuration Oct 15, 2018
configuration.go simplify auth and configuration Oct 15, 2018
model_access_token.go change package name from swagger to bitmexgo Oct 14, 2018
model_affiliate.go fix more float32 types with int Oct 16, 2018
model_announcement.go fix more float32 types with int Oct 16, 2018
model_api_key.go fix more float32 types with int Oct 16, 2018
model_chat.go fix more float32 types with int Oct 16, 2018
model_chat_channel.go fix more float32 types with int Oct 16, 2018
model_connected_users.go fix more float32 types with int Oct 16, 2018
model_error.go change package name from swagger to bitmexgo Oct 14, 2018
model_error_error.go change package name from swagger to bitmexgo Oct 14, 2018
model_execution.go fix more float32 types with int Oct 16, 2018
model_funding.go change package name from swagger to bitmexgo Oct 14, 2018
model_index_composite.go change package name from swagger to bitmexgo Oct 14, 2018
model_inline_response_200.go change package name from swagger to bitmexgo Oct 14, 2018
model_inline_response_200_1.go change package name from swagger to bitmexgo Oct 14, 2018
model_instrument.go fix more float32 types with int Oct 16, 2018
model_instrument_interval.go change package name from swagger to bitmexgo Oct 14, 2018
model_insurance.go fix more float32 types with int Oct 16, 2018
model_leaderboard.go change package name from swagger to bitmexgo Oct 14, 2018
model_liquidation.go fix more float32 types with int Oct 16, 2018
model_margin.go
model_notification.go fix more float32 types with int Oct 16, 2018
model_order.go fix more float32 types with int Oct 16, 2018
model_order_book_l2.go fix more float32 types with int Oct 16, 2018
model_position.go fix more float32 types with int Oct 16, 2018
model_quote.go fix more float32 types with int Oct 16, 2018
model_settlement.go fix more float32 types with int Oct 16, 2018
model_stats.go fix more float32 types with int Oct 16, 2018
model_stats_history.go fix more float32 types with int Oct 16, 2018
model_stats_usd.go fix more float32 types with int Oct 16, 2018
model_trade.go fix more float32 types with int Oct 16, 2018
model_trade_bin.go fix more float32 types with int Oct 16, 2018
model_transaction.go fix more float32 types with int Oct 16, 2018
model_user.go fix more float32 types with int Oct 16, 2018
model_user_commission.go
model_user_preferences.go change package name from swagger to bitmexgo Oct 14, 2018
model_wallet.go fix more float32 types with int Oct 16, 2018
response.go change package name from swagger to bitmexgo Oct 14, 2018

README.md

Bitmex REST APIs for Go

Overview

This bitmexgo package enables golang clients to call REST APIs for the Bitmex crypto trading platform. It fixes critical bugs in the swagger-generated code and enhances its usability.

Notable changes:

  • Fixed the authentication logic and API endpoint
  • Fixed form data encoding
  • Renamed the package from swagger to bitmexgo
  • Removed all external dependencies (golang.org/x/oauth2 and github.com/antihax/optional)
  • Added a local optional package with mutable states to simplify parameter assignment
  • Fixed many type issues and removed the obsolete XAny type

This package also differs from an alternative library at https://github.com/qct/bitmex-go in the following ways:

  • bitmexgo employs strongly-typed structs for API parameters instead of map[string]interface{}.
  • bitmexgo is forked from a more recent version of the swagger-generated code.
  • bitmexgo depends on no external packages and is compatible with Google App Engine.

Installation

go get github.com/zmxv/bitmexgo

Usage

import "github.com/zmxv/bitmexgo"

// Get your API key/secret pair at https://www.bitmex.com/app/apiKeys
apiKey := "..."
apiSecret := "..."

// Create an authentication context
auth := bitmexgo.NewAPIKeyContext(apiKey, apiSecret)

// Create a shareable API client instance
apiClient := bitmexgo.NewAPIClient(bitmexgo.NewConfiguration())

// Create a testnet API client instance
testnetClient := bitmexgo.NewAPIClient(bitmexgo.NewTestnetConfiguration())

// Call APIs without parameters by passing the auth context.
// e.g. getting exchange-wide turnover and volume statistics:
stats, res, err := apiClient.StatsApi.StatsGet(auth)

// Call APIs with default parameters by passing the auth context and a nil.
// e.g. getting all open positions:
pos, res, err := apiClient.PositionApi.PositionGet(auth, nil)

// Call APIs with additional parameters by constructing a corresponding XXXOpts struct.
// e.g. submitting a limit order to buy 20000 contracts of XBTUSD at $6000.5:
var params bitmexgo.OrderNewOpts
params.OrdType.Set("Limit")
params.Side.Set("Buy")
params.OrderQty.Set(20000)
params.Price.Set(6000.5)
order, res, err := apiClient.OrderApi.OrderNew(auth, "XBTUSD", &params)

Documentation for API Endpoints

All URIs are relative to https://www.bitmex.com/api/v1

Class Method HTTP request Description
APIKeyApi APIKeyDisable Post /apiKey/disable Disable an API Key.
APIKeyApi APIKeyEnable Post /apiKey/enable Enable an API Key.
APIKeyApi APIKeyGet Get /apiKey Get your API Keys.
APIKeyApi APIKeyNew Post /apiKey Create a new API Key.
APIKeyApi APIKeyRemove Delete /apiKey Remove an API Key.
AnnouncementApi AnnouncementGet Get /announcement Get site announcements.
AnnouncementApi AnnouncementGetUrgent Get /announcement/urgent Get urgent (banner) announcements.
ChatApi ChatGet Get /chat Get chat messages.
ChatApi ChatGetChannels Get /chat/channels Get available channels.
ChatApi ChatGetConnected Get /chat/connected Get connected users.
ChatApi ChatNew Post /chat Send a chat message.
ExecutionApi ExecutionGet Get /execution Get all raw executions for your account.
ExecutionApi ExecutionGetTradeHistory Get /execution/tradeHistory Get all balance-affecting executions. This includes each trade, insurance charge, and settlement.
FundingApi FundingGet Get /funding Get funding history.
InstrumentApi InstrumentGet Get /instrument Get instruments.
InstrumentApi InstrumentGetActive Get /instrument/active Get all active instruments and instruments that have expired in <24hrs.
InstrumentApi InstrumentGetActiveAndIndices Get /instrument/activeAndIndices Helper method. Gets all active instruments and all indices. This is a join of the result of /indices and /active.
InstrumentApi InstrumentGetActiveIntervals Get /instrument/activeIntervals Return all active contract series and interval pairs.
InstrumentApi InstrumentGetCompositeIndex Get /instrument/compositeIndex Show constituent parts of an index.
InstrumentApi InstrumentGetIndices Get /instrument/indices Get all price indices.
InsuranceApi InsuranceGet Get /insurance Get insurance fund history.
LeaderboardApi LeaderboardGet Get /leaderboard Get current leaderboard.
LeaderboardApi LeaderboardGetName Get /leaderboard/name Get your alias on the leaderboard.
LiquidationApi LiquidationGet Get /liquidation Get liquidation orders.
NotificationApi NotificationGet Get /notification Get your current notifications.
OrderApi OrderAmend Put /order Amend the quantity or price of an open order.
OrderApi OrderAmendBulk Put /order/bulk Amend multiple orders for the same symbol.
OrderApi OrderCancel Delete /order Cancel order(s). Send multiple order IDs to cancel in bulk.
OrderApi OrderCancelAll Delete /order/all Cancels all of your orders.
OrderApi OrderCancelAllAfter Post /order/cancelAllAfter Automatically cancel all your orders after a specified timeout.
OrderApi OrderClosePosition Post /order/closePosition Close a position. [Deprecated, use POST /order with execInst: 'Close']
OrderApi OrderGetOrders Get /order Get your orders.
OrderApi OrderNew Post /order Create a new order.
OrderApi OrderNewBulk Post /order/bulk Create multiple new orders for the same symbol.
OrderBookApi OrderBookGetL2 Get /orderBook/L2 Get current orderbook in vertical format.
PositionApi PositionGet Get /position Get your positions.
PositionApi PositionIsolateMargin Post /position/isolate Enable isolated margin or cross margin per-position.
PositionApi PositionTransferIsolatedMargin Post /position/transferMargin Transfer equity in or out of a position.
PositionApi PositionUpdateLeverage Post /position/leverage Choose leverage for a position.
PositionApi PositionUpdateRiskLimit Post /position/riskLimit Update your risk limit.
QuoteApi QuoteGet Get /quote Get Quotes.
QuoteApi QuoteGetBucketed Get /quote/bucketed Get previous quotes in time buckets.
SchemaApi SchemaGet Get /schema Get model schemata for data objects returned by this API.
SchemaApi SchemaWebsocketHelp Get /schema/websocketHelp Returns help text & subject list for websocket usage.
SettlementApi SettlementGet Get /settlement Get settlement history.
StatsApi StatsGet Get /stats Get exchange-wide and per-series turnover and volume statistics.
StatsApi StatsHistory Get /stats/history Get historical exchange-wide and per-series turnover and volume statistics.
StatsApi StatsHistoryUSD Get /stats/historyUSD Get a summary of exchange statistics in USD.
TradeApi TradeGet Get /trade Get Trades.
TradeApi TradeGetBucketed Get /trade/bucketed Get previous trades in time buckets.
UserApi UserCancelWithdrawal Post /user/cancelWithdrawal Cancel a withdrawal.
UserApi UserCheckReferralCode Get /user/checkReferralCode Check if a referral code is valid.
UserApi UserConfirm Post /user/confirmEmail Confirm your email address with a token.
UserApi UserConfirmEnableTFA Post /user/confirmEnableTFA Confirm two-factor auth for this account. If using a Yubikey, simply send a token to this endpoint.
UserApi UserConfirmWithdrawal Post /user/confirmWithdrawal Confirm a withdrawal.
UserApi UserDisableTFA Post /user/disableTFA Disable two-factor auth for this account.
UserApi UserGet Get /user Get your user model.
UserApi UserGetAffiliateStatus Get /user/affiliateStatus Get your current affiliate/referral status.
UserApi UserGetCommission Get /user/commission Get your account's commission status.
UserApi UserGetDepositAddress Get /user/depositAddress Get a deposit address.
UserApi UserGetMargin Get /user/margin Get your account's margin status. Send a currency of &quot;all&quot; to receive an array of all supported currencies.
UserApi UserGetWallet Get /user/wallet Get your current wallet information.
UserApi UserGetWalletHistory Get /user/walletHistory Get a history of all of your wallet transactions (deposits, withdrawals, PNL).
UserApi UserGetWalletSummary Get /user/walletSummary Get a summary of all of your wallet transactions (deposits, withdrawals, PNL).
UserApi UserLogout Post /user/logout Log out of BitMEX.
UserApi UserLogoutAll Post /user/logoutAll Log all systems out of BitMEX. This will revoke all of your account's access tokens, logging you out on all devices.
UserApi UserMinWithdrawalFee Get /user/minWithdrawalFee Get the minimum withdrawal fee for a currency.
UserApi UserRequestEnableTFA Post /user/requestEnableTFA Get secret key for setting up two-factor auth.
UserApi UserRequestWithdrawal Post /user/requestWithdrawal Request a withdrawal to an external wallet.
UserApi UserSavePreferences Post /user/preferences Save user preferences.
UserApi UserUpdate Put /user Update your password, name, and other attributes.

Documentation For Models

Bitmex customer support

support@bitmex.com