Skip to content

Latest commit

 

History

History
 
 

csharp

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

REST API for the Bybit Exchange.

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

  • API version: 1.0.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: 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-testnet.bybit.com

Class Method HTTP request Description
APIkeyApi APIkeyInfo GET /open-api/api-key Get account api-key information.
CommonApi CommonGet GET /v2/public/time Get bybit server time.
ConditionalApi ConditionalCancel POST /open-api/stop-order/cancel Cancel conditional order.
ConditionalApi ConditionalGetOrders GET /open-api/stop-order/list Get my conditional order list.
ConditionalApi ConditionalNew POST /open-api/stop-order/create Place a new conditional order.
ConditionalApi ConditionalReplace POST /open-api/stop-order/replace Replace conditional order. Only incomplete orders can be modified.
ExecutionApi ExecutionGetTrades GET /v2/private/execution/list Get user’s trade records.
FundingApi FundingGetRate 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 FundingPredictedRate GET /open-api/funding/prev-funding-rate Get predicted funding rate and funding fee.
KlineApi KlineGet GET /v2/public/kline/list Query historical kline.
MarketApi MarketOrderbook GET /v2/public/orderBook/L2 Get the orderbook.
MarketApi MarketSymbolInfo GET /v2/public/tickers Get the latest information for symbol.
OrderApi OrderCancel POST /open-api/order/cancel Get my active order list.
OrderApi OrderGetOrders GET /open-api/order/list Get my active order list.
OrderApi OrderNew POST /open-api/order/create Place active order
OrderApi OrderQuery GET /v2/private/order Get my active order list.
OrderApi OrderReplace POST /open-api/order/replace Replace active order. Only incomplete orders can be modified.
PositionsApi PositionsChangeMargin POST /position/change-position-margin Update margin.
PositionsApi PositionsMyPosition GET /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.
PositionsApi PositionsUserLeverage GET /user/leverage Get user leverage setting.
SymbolApi SymbolGet GET /v2/public/symbols Query Symbols.
WalletApi WalletGetRecords GET /open-api/wallet/fund/records Get wallet fund records
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