Trading desk background

GET. TRADE. PROFIT.

Whale's Secret ScriptApiLib provides unified API to different digital assets platforms.

What is Whale's Secret ScriptApiLib

Whale's Secret ScriptApiLib is a .NET library distributed via NuGet that provides unified API to different digital assets platforms with focus on easy of use and robust error handling.

Spend your time on the development of your trading strategy, script, or a robot, instead of wasting it on implementing integration with poorly documented exchange API. We did the hard work for you and bring you a unified and simple-to-use API, so you can now focus on trading.

You can use ScriptApiLib for free but if you are serious about your trading we highly recommend purchasing the license. What is the difference? In the free mode, you can use all the features that ScriptApiLib provides, but you can only create orders that are limited in size. See the pricing section below for more reasons to buy the license.

What can ScriptApiLib offer to you?

  • Unified API for trading and market data subscriptions.
  • Advanced support for recovering from disconnections.
  • Thoroughly tested.

So would you prefer to invest your time in the implementation of a cryptocurrency exchange API, or would you rather proceed directly to executing your trading concept?

ScriptApiLib in action

KuCoin live demo video

To help you start with ScriptApiLib, we provide wide range of code samples that demonstrate different features of this library. The demonstration above is showing our Interactive Trading Sample.

Implement API or trading strategy?

Implementing a cryptocurrency exchange API is a challenging endeavor. The rapid proliferation of cryptocurrency exchanges has resulted in a lack of standardization in API and even offered features.

Exchanges typically differ in use of authentication protocols, in used data formats, and even in technologies required to access API.

Further complicating the situation, exchanges provide API documentations which are often incomplete, often necessitating a process of trial and error.

Pricing

Our pricing is dead simple. Choose the currency, choose for how long you want the license to be valid, buy.

Currency:

All the paid licenses include:

  • Unlimited order sizes

Without the license, the size of the orders that you can create is limited to a certain multiple of the minimal tradable amount of the symbol pair on the target exchange market. With the license, this limitation no longer applies.

  • VIP status

Each paying customer is a VIP for us and the longer the VIP status is held the higher weight we assign to all suggestions and votes of this customer. This is important, for example, for creating feature requests. For each 1 month of the VIP status, you get 1 extra vote and extra priority on support.

  • Priority support

We support everyone who uses our ScriptApiLib, either on our Telegram Support Chat, or through our Support GitHub Repository. However, paying customers get priority over non-paying users and receive more in-depth help.

Supported APIs

Currently ScriptApiLib supports Binance Spot and KuCoin Spot APIs. Supporting more exchanges is intended in the future. You can submit feature requests, including supporting other exchange platforms on our Developer Support GitHub.

ScriptApiLib API features:

  • Exchange market initialization allows you to obtain basic information about the exchange and its tradable symbol pairs.
  • Order book, candlestick, and ticker subscriptions provide easy way to monitor market data and quickly react to changes.
  • Subscription sets allow subscribing multiple symbol pairs at once, providing efficient access to market data for more complex strategies.
  • Order creation and monitoring for creating market, limit, stop-loss, limit-profit, stop-limit, and take-profit types of orders and monitoring the progress of the orders once placed.
  • Order cancellation including cancelling all orders on the connected exchange.
  • Historical trades and orders data allow you to review your past trading activity on an exchange.
  • Open orders feature lists currently active orders as well as possibility to be informed about any changes.
  • Historical candlesticks data enable access to raw data behind OHLC charts.
  • Exchange account information includes balances in user's wallets on the exchange with possibility to monitor updates.
  • Order Request Builder provides easy way to build multiple orders while respecting restrictions imposed by exchange markets including rounding of amounts and prices.
  • Time synchronization with exchange server times is important for your API requests to be accepted by exchanges.
  • API request count optimization reduces the number of API requests the client sends to an exchange and thus prevents hitting the limits imposed by exchanges.

Add package reference to your project

Use the following command line command:

dotnet add package WhalesSecret.ScriptApiLib
or specify the reference directly in your .csproj project:

<PackageReference Include="WhalesSecret.ScriptApiLib" />

Connect to Binance exchange to work with market data

No credentials are required for this operation.

await using ScriptApi scriptApi = await ScriptApi.CreateAsync();

// Initialization of the market is required before connection can be created.
_ = await scriptApi.InitializeMarketAsync(ExchangeMarket.BinanceSpot);

// Market-data connection type is the only connection type that does not need exchange API credentials.
ConnectionOptions connectionOptions = new(connectionType: ConnectionType.MarketData);
await using ITradeApiClient tradeClient = await scriptApi.ConnectAsync(ExchangeMarket.BinanceSpot, connectionOptions); 
See our market-data connection sample for more details.

Connect to KuCoin exchange to trade

Credentials are required for this operation.

await using ScriptApi scriptApi = await ScriptApi.CreateAsync();

// Initialization of the market is required before connection can be created.
_ = await scriptApi.InitializeMarketAsync(ExchangeMarket.KucoinSpot);

// Credentials must be set before we can create a private connection.
IApiIdentity apiIdentity = KucoinApiIdentity.Create(name: "KucoinCredentials", "YOUR KEY", "YOUR SECRET", "YOUR PASSPHRASE");
scriptApi.SetCredentials(apiIdentity);

await using ITradeApiClient tradeClient = await scriptApi.ConnectAsync(ExchangeMarket.KucoinSpot, ConnectionOptions.DefaultBlock);
See our trading connection sample for more details.

Order book subscription

Create an order book subscription for BTC/USDT and get the current order book snapshot.

await using IOrderBookSubscription subscription = await tradeClient.CreateOrderBookSubscriptionAsync(SymbolPair.BTC_USDT);

// Wait for next order book update for the symbol pair.
OrderBook orderBook = await subscription.GetOrderBookAsync(getMode: OrderBookGetMode.WaitUntilNew);
See our order book subscription sample for more details.

Candlestick subscription

Create a candlestick subscription for BTC/USDT, and wait for a next candlestick update.

await using ICandlestickSubscription subscription = await tradeClient.CreateCandlestickSubscriptionAsync(SymbolPair.BTC_USDT);
CandleUpdate candleUpdate = await subscription.WaitNextCandlestickUpdateAsync(CandleWidth.Minute1);
See our candlestick subscription sample for more details.

Ticker subscription

Create a ticker subscription for BTC/USDT, and wait for a new ticker.

await using ITickerSubscription subscription = await tradeClient.CreateTickerSubscriptionAsync(SymbolPair.BTC_USDT);
Ticker ticker = await subscription.GetNewerTickerAsync();
See our ticker subscription sample for more details.

Create and cancel orders

// Create a market order.
ILiveMarketOrder marketOrder = await tradeClient.CreateMarketOrderAsync(clientOrderId: null, SymbolPair.BTC_USDT, OrderSide.Buy, size: 0.0001m);

// Create a limit order.
ILiveLimitOrder limitOrder = await tradeClient.CreateLimitOrderAsync(clientOrderId: null, SymbolPair.BTC_USDT, OrderSide.Buy, price: 80_000m, size: 0.0001m);

// Cancel the limit order.
await tradeClient.CancelOrderAsync(limitOrder);
See our order sample for more details.

List open orders and listen to order updates

// List open orders.
IReadOnlyList<ILiveOrder> liveOrders = await tradeClient.GetOpenOrdersAsync(OrderFilterOptions.AllOrders);

// Listen to order updates.
await foreach (IOrdersUpdate update in tradeClient.GetOrdersUpdateAsync())
{
    await Console.Out.WriteLineAsync($$"""Order update received: {{update}}""");
}
See our list-open-orders sample for more details.