.NET License
dotnet add package HitBTC.Connector
<PackageReference Include="HitBTC.Connector" Version="1.0.0" />
using HitBTC.Connector.Rest;
using HitBTC.Connector.Core.Models;
// Public API (no authentication required)
await using var client = new HitBtcRestClient("", "");
// Get symbols
var symbols = await client.GetSymbolsAsync();
var btcUsdt = symbols["BTCUSDT"];
Console.WriteLine($"BTCUSDT tick size: {btcUsdt.TickSize}");
// Get order book
using var orderBook = await client.GetOrderBookAsync("BTCUSDT", depth: 10);
Console.WriteLine($"Best bid: {orderBook.Bids[0].Price}, Best ask: {orderBook.Asks[0].Price}");
Console.WriteLine($"Spread: {orderBook.Asks[0].Price - orderBook.Bids[0].Price}");
// Get candles
var candles = await client.GetCandlesAsync("BTCUSDT", CandlePeriod.H1, limit: 24);
foreach (var c in candles)
{
Console.WriteLine($"{c.Timestamp:HH:mm} O:{c.Open} H:{c.High} L:{c.Low} C:{c.Close}");
}await using var client = new HitBtcRestClient("YOUR_API_KEY", "YOUR_SECRET_KEY");
// Get active orders
var orders = await client.GetActiveSpotOrdersAsync();
// Place limit order
var order = await client.CreateSpotOrderAsync(new CreateSpotOrderRequest
{
Symbol = "BTCUSDT",
Side = OrderSide.Buy,
Quantity = 0.001m,
Price = 50000m,
Type = OrderType.Limit,
TimeInForce = TimeInForce.GTC,
PostOnly = true
});
Console.WriteLine($"Order placed: {order.ClientOrderId}");
// Replace order
var replaced = await client.ReplaceSpotOrderAsync(order.ClientOrderId, new ReplaceSpotOrderRequest
{
Quantity = 0.002m,
Price = 49000m
});
// Cancel order
var canceled = await client.CancelSpotOrderAsync(replaced.ClientOrderId);
// Cancel all orders
await client.CancelAllSpotOrdersAsync(symbol: "BTCUSDT");await using var client = new HitBtcRestClient("YOUR_API_KEY", "YOUR_SECRET_KEY");
// Get futures balance
var balances = await client.GetFuturesBalanceAsync();
foreach (var b in balances)
{
Console.WriteLine($"{b.Currency}: {b.Available} available");
}
// Create/update margin account
var account = await client.CreateOrUpdateMarginAccountAsync(
MarginMode.Isolated,
"BTCUSDT_PERP",
marginBalance: 100m,
leverage: 25m
);
// Place futures order
var futuresOrder = await client.CreateFuturesOrderAsync(new CreateFuturesOrderRequest
{
Symbol = "BTCUSDT_PERP",
Side = OrderSide.Buy,
Quantity = 0.01m,
Price = 50000m,
Type = OrderType.Limit,
MarginMode = MarginMode.Isolated,
ReduceOnly = false
});
// Close position
await client.CloseFuturesPositionAsync(
MarginMode.Isolated,
"BTCUSDT_PERP",
new ClosePositionRequest { Price = 51000m }
);
// Close margin account (withdraw all funds)
await client.CloseMarginAccountAsync(MarginMode.Isolated, "BTCUSDT_PERP");| Category | Endpoints | Status |
|---|---|---|
| Public | Symbols, OrderBook, Candles, Trades | β |
| Spot Trading | Get/Create/Replace/Cancel Orders | β |
| Futures Trading | Orders, Positions, Margin Accounts | β |
| Futures Balance | Get Balance by Currency | β |
| Margin Management | Create/Update/Close Accounts, Leverage | β |