Skip to content

Latest commit

 

History

History

csharp

IO.Swagger - the C# library for the BitMEX API

REST API for the BitMEX Trading Platform If you are building automated tools, please subscribe to the BitMEX API RSS Feed for changes. The feed will be updated regularly and is the most reliable way to get downtime and update announcements. View Changelog - #### Getting Started Base URI: https://www.bitmex.com/api/v1 ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept count, start, and reverse params. Set reverse=true to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in the main API documentation. All table data is available via the Websocket. We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send ?_format=csv to get CSV data or ?_format=xml to get XML data. ##### Trade Data Queries This is only a small subset of what is available, to get you started. Fill in the parameters and click the Try it out! button to try any of these queries. - Pricing Data - Trade Data - OrderBook Data - Settlement Data - Exchange Statistics Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification ⇩ Download Swagger JSON - ## All API Endpoints Click to expand a section.

This C# SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.2.0
  • SDK version: 1.0.0
  • Build package: io.swagger.codegen.languages.CSharpClientCodegen

Frameworks supported

  • .NET 4.0 or later
  • Windows Phone 7.1 (Mango)

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out IO.Swagger.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Getting Started

using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;

namespace Example
{
    public class Example
    {
        public void main()
        {

            // Configure API key authorization: apiExpires
            Configuration.Default.ApiKey.Add("api-expires", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // Configuration.Default.ApiKeyPrefix.Add("api-expires", "Bearer");
            // Configure API key authorization: apiKey
            Configuration.Default.ApiKey.Add("api-key", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // Configuration.Default.ApiKeyPrefix.Add("api-key", "Bearer");
            // Configure API key authorization: apiSignature
            Configuration.Default.ApiKey.Add("api-signature", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // Configuration.Default.ApiKeyPrefix.Add("api-signature", "Bearer");

            var apiInstance = new APIKeyApi();
            var reverse = true;  // bool? | If true, will sort results newest first. (optional)  (default to false)

            try
            {
                // Get your API Keys.
                List<APIKey> result = apiInstance.APIKeyGet(reverse);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling APIKeyApi.APIKeyGet: " + e.Message );
            }

        }
    }
}

Documentation for API Endpoints

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

Class Method HTTP request Description
APIKeyApi APIKeyGet GET /apiKey Get your API Keys.
AddressApi AddressGet GET /address Get your addresses.
AddressApi AddressNew POST /address Creates a new saved address.
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 ChatGetPinnedMessage GET /chat/pinned Get pinned message for a channel.
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.
FundingApi FundingGet GET /funding Get funding history.
GlobalNotificationApi GlobalNotificationGet GET /globalNotification Get your current GlobalNotifications.
GuildApi GuildArchive POST /guild/archive Archive a guild
GuildApi GuildEdit PUT /guild Edit guild new guild
GuildApi GuildGet GET /guild Get all guilds
GuildApi GuildJoin POST /guild/join Request to Join a private guild or join a public guild
GuildApi GuildKick POST /guild/kick Kick member from guild
GuildApi GuildLeave POST /guild/leave Leave guild or cancel guild join request
GuildApi GuildNew POST /guild Creates a new guild
GuildApi GuildShareTrades POST /guild/shareTrades Toggle share trades for your account, which controls whether your guild members can see your orders and positions in their UI
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.
InstrumentApi InstrumentGetUsdVolume GET /instrument/usdVolume Get a summary of exchange statistics in USD.
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.
OrderApi OrderAmend PUT /order Amend the quantity or price of an open order.
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.
OrderBookApi OrderBookGetL2 GET /orderBook/L2 Get current orderbook in vertical format.
PorlApi PorlGetNonce GET /porl/nonce Get your Proof of Reserves nonce and data.
PorlApi PorlGetSnapshots GET /porl/snapshots Get Proof of Reserves historical snapshots
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 UserCancelPendingWithdrawal DELETE /user/withdrawal Cancel pending withdrawal
UserApi UserCancelWithdrawal POST /user/cancelWithdrawal Cancel a withdrawal.
UserApi UserCheckReferralCode GET /user/checkReferralCode Check if a referral code is valid.
UserApi UserCommunicationToken POST /user/communicationToken Register your communication token for mobile clients
UserApi UserConfirm POST /user/confirmEmail Confirm your email address with a token.
UserApi UserConfirmWithdrawal POST /user/confirmWithdrawal Confirm a withdrawal.
UserApi UserCreateSubAccount POST /user/addSubaccount Creates a new sub-account.
UserApi UserCreateUnstakingRequests POST /user/unstakingRequests Create unstaking request
UserApi UserDeleteUnstakingRequests DELETE /user/unstakingRequests Cancel unstaking request
UserApi UserGet GET /user Get your user model.
UserApi UserGetAffiliateStatus GET /user/affiliateStatus Get your current affiliate/referral status.
UserApi UserGetCSA GET /user/csa Get your account's CSA status.
UserApi UserGetCommission GET /user/commission Get your account's commission status.
UserApi UserGetDepositAddress GET /user/depositAddress Get a deposit address.
UserApi UserGetDepositAddressInformation GET /user/depositAddressInformation Get a deposit address.
UserApi UserGetExecutionHistory GET /user/executionHistory Get the execution history by day.
UserApi UserGetMargin GET /user/margin Get your account's margin status. Send a currency of "all" to receive an array of all supported currencies.
UserApi UserGetQuoteFillRatio GET /user/quoteFillRatio Get 7 days worth of Quote Fill Ratio statistics.
UserApi UserGetQuoteValueRatio GET /user/quoteValueRatio Get Quote Value Ratio statistics over the last 3 days
UserApi UserGetStaking GET /user/staking Get the current user staking amount.
UserApi UserGetStakingInstruments GET /user/staking/instruments List staking instruments
UserApi UserGetStakingTiers GET /user/staking/tiers List staking tiers for a given currency
UserApi UserGetTradingVolume GET /user/tradingVolume Get your 30 days USD average trading volume
UserApi UserGetUnstakingRequests GET /user/unstakingRequests Get the current user unstaking requests
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 UserGetWalletTransferAccounts GET /user/getWalletTransferAccounts Get the list of accounts you can transfer funds between.
UserApi UserLogout POST /user/logout Log out of BitMEX.
UserApi UserRequestWithdrawal POST /user/requestWithdrawal Request a withdrawal to an external wallet.
UserApi UserSavePreferences POST /user/preferences Save user preferences.
UserApi UserUpdateSubAccount POST /user/updateSubaccount Updates the sub-account name.
UserApi UserWalletTransfer POST /user/walletTransfer Execute a transfer to a paired account.
UserAffiliatesApi UserAffiliatesGet GET /userAffiliates Get user's affiliates to a given depth
UserEventApi UserEventGet GET /userEvent Get your user events
WalletApi WalletGetAssetsConfig GET /wallet/assets Get Assets Config
WalletApi WalletGetNetworksConfig GET /wallet/networks Get Networks Config

Documentation for Models

Documentation for Authorization

apiExpires

  • Type: API key
  • API key parameter name: api-expires
  • Location: HTTP header

apiKey

  • Type: API key
  • API key parameter name: api-key
  • Location: HTTP header

apiSignature

  • Type: API key
  • API key parameter name: api-signature
  • Location: HTTP header