Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Latest commit

 

History

History

csharp

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

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

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

  • API version: 0.2.10
  • 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: 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("sign", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // Configuration.Default.ApiKeyPrefix.Add("sign", "Bearer");
            // Configure API key authorization: timestamp
            Configuration.Default.ApiKey.Add("timestamp", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // Configuration.Default.ApiKeyPrefix.Add("timestamp", "Bearer");

            var apiInstance = new APIkeyApi();

            try
            {
                // Get account api-key information.
                Object result = apiInstance.APIkeyInfo();
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling APIkeyApi.APIkeyInfo: " + e.Message );
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.bybit.com

Class Method HTTP request Description
APIkeyApi APIkeyInfo GET /open-api/api-key Get account api-key information.
CommonApi CommonAnnouncements GET /v2/public/announcement Get Bybit OpenAPI announcements in the last 30 days in reverse order.
CommonApi CommonGetLcp GET /v2/private/account/lcp Query LCP info.
CommonApi CommonGetTime GET /v2/public/time Get bybit server time.
ConditionalApi ConditionalCancel POST /v2/private/stop-order/cancel Cancel conditional order.
ConditionalApi ConditionalCancelAll POST /v2/private/stop-order/cancelAll Cancel conditional order.
ConditionalApi ConditionalGetOrders GET /v2/private/stop-order/list Get my conditional order list.
ConditionalApi ConditionalNew POST /v2/private/stop-order/create Place a new conditional order.
ConditionalApi ConditionalQuery GET /v2/private/stop-order Query real-time stop order information.
ConditionalApi ConditionalReplace POST /v2/private/stop-order/replace Replace conditional order. Only incomplete orders can be modified.
ExecutionApi ExecutionGetTrades GET /v2/private/execution/list Get user’s trade records.
ExecutionApi PositionsClosePnlRecords GET /v2/private/trade/closed-pnl/list Get user's closed profit and loss records
FundingApi FundingMyLastFee GET /open-api/funding/prev-funding Funding 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.
FundingApi FundingPredicted GET /open-api/funding/predicted-funding Get predicted funding rate and funding fee.
FundingApi FundingPrevRate GET /open-api/funding/prev-funding-rate Get predicted funding rate and funding fee.
KlineApi KlineGet GET /v2/public/kline/list Query historical kline.
KlineApi KlineMarkPrice GET /v2/public/mark-price-kline Query mark price kline.
LinearConditionalApi LinearConditionalCancel POST /private/linear/stop-order/cancel Cancel Active Order
LinearConditionalApi LinearConditionalCancelAll POST /private/linear/stop-order/cancel-all Cancel all stop orders.
LinearConditionalApi LinearConditionalGetOrders GET /private/linear/stop-order/list Get linear Stop Orders
LinearConditionalApi LinearConditionalNew POST /private/linear/stop-order/create Create linear stop Order
LinearConditionalApi LinearConditionalQuery GET /private/linear/stop-order/search Get Stop Orders(real-time)
LinearConditionalApi LinearConditionalReplace POST /private/linear/stop-order/replace Replace conditional order
LinearExecutionApi LinearExecutionGetTrades GET /private/linear/trade/execution/list Get user's trading records.
LinearFundingApi LinearFundingMyLastFee GET /private/linear/funding/prev-funding Get prev funding
LinearFundingApi LinearFundingPredicted GET /private/linear/funding/predicted-funding Get predicted funding rate and funding fee.
LinearFundingApi LinearFundingPrevRate GET /public/linear/funding/prev-funding-rate Get prev funding
LinearKlineApi LinearKlineGet GET /public/linear/kline Get kline
LinearKlineApi LinearKlineMarkPrice GET /public/linear/mark-price-kline Get kline
LinearMarketApi LinearMarketTrading GET /public/linear/recent-trading-records Get recent trades
LinearOrderApi LinearOrderCancel POST /private/linear/order/cancel Cancel Active Order
LinearOrderApi LinearOrderCancelAll POST /private/linear/order/cancel-all Cancel all active orders.
LinearOrderApi LinearOrderGetOrders GET /private/linear/order/list Get linear Active Orders
LinearOrderApi LinearOrderNew POST /private/linear/order/create Create Active Order
LinearOrderApi LinearOrderQuery GET /private/linear/order/search Get Active Orders(real-time)
LinearOrderApi LinearOrderReplace POST /private/linear/order/replace Replace Active Order
LinearPositionsApi LinearPositionsChangeMargin POST /private/linear/position/add-margin Add/Reduce Margin
LinearPositionsApi LinearPositionsClosePnlRecords GET /private/linear/trade/closed-pnl/list Get user's closed profit and loss records.
LinearPositionsApi LinearPositionsMyPosition GET /private/linear/position/list Get my position list.
LinearPositionsApi LinearPositionsSaveLeverage POST /private/linear/position/set-leverage Set leverage
LinearPositionsApi LinearPositionsSetAutoAddMargin POST /private/linear/position/set-auto-add-margin Set auto add margin
LinearPositionsApi LinearPositionsSwitchIsolated POST /private/linear/position/switch-isolated Switch isolated
LinearPositionsApi LinearPositionsSwitchMode POST /private/linear/tpsl/switch-mode Switch Mode
LinearPositionsApi LinearPositionsTradingStop POST /private/linear/position/trading-stop Set tradingStop
LinearWalletApi LinearWalletGetRiskLimit GET /public/linear/risk-limit Get risk limit.
MarketApi MarketAccountRatio GET /v2/public/account-ratio Query Account Long Short Ratio
MarketApi MarketBigDeal GET /v2/public/big-deal Query Big Deal
MarketApi MarketLiqRecords GET /v2/public/liq-records Query liq records.
MarketApi MarketOpenInterest GET /v2/public/open-interest Query Open Interest
MarketApi MarketOrderbook GET /v2/public/orderBook/L2 Get the orderbook.
MarketApi MarketSymbolInfo GET /v2/public/tickers Get the latest information for symbol.
MarketApi MarketTradingRecords GET /v2/public/trading-records Get recent trades
OrderApi OrderCancel POST /v2/private/order/cancel Get my active order list.
OrderApi OrderCancelAll POST /v2/private/order/cancelAll Get my active order list.
OrderApi OrderGetOrders GET /v2/private/order/list Get my active order list.
OrderApi OrderNew POST /v2/private/order/create Place active order
OrderApi OrderQuery GET /v2/private/order Get my active order list.
OrderApi OrderReplace POST /v2/private/order/replace Replace active order. Only incomplete orders can be modified.
PositionsApi PositionsChangeMargin POST /position/change-position-margin Update margin.
PositionsApi PositionsClosePnlRecords GET /v2/private/trade/closed-pnl/list Get user's closed profit and loss records
PositionsApi PositionsMyPosition GET /v2/private/position/list Get my position list.
PositionsApi PositionsSaveLeverage POST /user/leverage/save Change user leverage.
PositionsApi PositionsTradingStop POST /open-api/position/trading-stop Set Trading-Stop Condition.
SymbolApi SymbolGet GET /v2/public/symbols Query Symbols.
WalletApi WalletExchangeOrder GET /v2/private/exchange-order/list Asset Exchange Records
WalletApi WalletGetBalance GET /v2/private/wallet/balance get wallet balance info
WalletApi WalletGetRecords GET /open-api/wallet/fund/records Get wallet fund records
WalletApi WalletGetRiskLimit GET /open-api/wallet/risk-limit/list Get risk limit.
WalletApi WalletSetRiskLimit POST /open-api/wallet/risk-limit Set risk limit
WalletApi WalletWithdraw GET /open-api/wallet/withdraw/list Get 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