百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

coinbasepro-csharp

> 开发工具
开源

Coinbase Pro/GDAX API 的非官方 .NET/C# 客户端库

191 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Coinbase Pro/GDAX API 的非官方 .NET/C# 客户端库

coinbasepro-csharp

How to Install

PM> Install-Package GDAX.Api.ClientLibrary

How to Use

Generate your key at https://pro.coinbase.com/profile/api

csharp
//create an authenticator with your apiKey, apiSecret and passphrase
var authenticator = new Authenticator("", "", "");

//create the CoinbasePro client
var coinbaseProClient = new CoinbasePro.CoinbaseProClient(authenticator);

//use one of the services 
var allAccounts = await coinbaseProClient.AccountsService.GetAllAccountsAsync();

What services are provided?

Accounts
  • GetAllAccountsAsync() - get all accounts
  • GetAccountByIdAsync(id) - get account by id
  • GetAccountHistoryAsync(id, limit, numberOfPages) - get account history (paged response)
  • GetAccountHoldsAsync(id, limit, numberOfPages) - get all holds placed on an account (paged response)
CoinbaseAccounts
  • GetAllAccountsAsync() - get all coinbase accounts
Orders
  • PlaceMarketOrderAsync(orderSide, productPair, amount, MarketOrderAmountType, clientOId) - place market order by size or funds
  • PlaceLimitOrderAsync(orderSide, productPair, size, price, timeInForce, postOnly, clientOId) - place limit order with time in force
  • PlaceLimitOrderAsync(orderSide, productPair, size, price, cancelAfter, postOnly, clientOId) - place limit order with cancel after date
  • PlaceStopOrderAsync(orderSide, productPair, size, limitPrice, stopPrice, clientOId) - place stop order with stop and limit price
  • CancelAllOrdersAsync() - cancel all orders
  • CancelOrderByIdAsync(id) - cancel order by id
  • GetAllOrdersAsync(orderStatus, limit, numberOfPages) - get all, active or pending orders (paged response)
  • GetAllOrdersAsync(orderStatus[], limit, numberOfPages) - get orders by multiple statuses (paged response)
  • GetOrderByIdAsync(id) - get order by id
Payments
  • GetAllPaymentMethodsAsync() - get all payment methods
Withdrawals
  • WithdrawFundsAsync(paymentMethodId, amount, currency) - withdraw funds to a payment method
  • WithdrawToCoinbaseAsync(coinbaseAccountId, amount, currency) - withdraw funds to a coinbase account
  • WithdrawToCryptoAsync(cryptoAddress, amount, currency, destinationTag) - withdraw funds to a crypto address
  • GetAllWithdrawals(profileId, before, after, limit) - list of withdrawals from the profile of the API key, in descending order by created time
  • GetWithdrawalById(transferId) - get information on a single withdrawal
  • GetFeeEstimateAsync(currency, cryptoAddress) - gets the network fee estimate when sending to the given address
Deposits
  • GetAllDeposits(profileId, before, after, limit) - list of deposits from the profile of the API key, in descending order by created time
  • GetDepositById(transferId) - get information on a single deposit.
  • DepositFundsAsync(paymentMethodId, amount, currency) - deposits funds from a payment method
  • DepositCoinbaseFundsAsync(coinbaseAccountId, amount, currency) - deposits funds from a coinbase account
  • GenerateCryptoDepositAddressAsync(string coinbaseAccountId) - generate an address for crypto deposits
Products
  • GetAllProductsAsync() - get a list of available currency pairs for trading
  • GetSingleProductAsync(productType) - get market data for a specific currency pair
  • GetProductOrderBookAsync(productType, productLevel) - get a list of open orders for a product (specify level 1, 2, or 3)
  • GetProductTickerAsync(productType) - get information about the last trade (tick), best bid/ask and 24h volume
  • GetTradesAsync(productType, limit, numberOfPages) - get latest trades for a product (paged response)
  • GetProductStatsAsync(productType) - get 24 hour stats for a product
  • GetHistoricRatesAsync(productPair, start, end, granularity) - get historic rates for a product, auto batches requests to pull complete date range
Currencies
  • GetAllCurrenciesAsync() - gets a list of known currencies
  • GetCurrencyByIdAsync(currency) - list the currency for the specified id
Fills
  • GetFillsByOrderIdAsync(orderId, limit, numberOfPages) - gets a list of all recent fills by order id (paged response)
  • GetFillsByProductIdAsync(productType, limit, numberOfPages) - gets a list of all recent fills by product type (paged response)
Limits
  • GetCurrentExchangeLimitsAsync() - returns information on your payment method transfer limits, as well as buy/sell limits per currency
Fundings
  • GetAllFundingsAsync(limit, fundingStatus, numberOfPages) - gets a list of all orders placed with a margin profile that draws funding (paged response)
Reports
  • CreateNewAccountReportAsync(startDate, endDate, accountId, productType, email, fileFormat) - generate new account report
  • CreateNewFillsReportAsync(startDate, endDate, productType, accountId, email, fileFormat) - generate new fills report
  • GetReportStatus(id) - gets report status
User Account
  • GetTrailingVolumeAsync() - get 30-day trailing volume for all products
Fees
  • GetCurrentFeesAsync() - get your current maker & taker fee rates, as well as your 30-day trailing volume
Stablecoin Conversions
  • CreateConversion(currencyFrom, currencyTo, amount) - convert bank-based dollars to blockchain-based digital dollars
Profiles
  • GetAllProfilesAsync() - list your profiles
  • GetProfileByIdAsync(id) - get a single profile by profile id
  • CreateProfileTransferAsync(from, to, currency, amount) - transfer funds from API key’s profile to another user owned profile

Websocket Feed

How to use with authentication

…

How to use without authentication

…

Available functions

These are the starting and stopping methods:

  • Start(productTypes, channelTypes, autoSendPingInterval) - Starts the websocket feed based on product(s) and channel(s). Optionally set an auto send ping interval to prevent websocket from closing if idle more than 1 minute
  • Stop() - Stops the websocket feed
  • ChangeChannels(productTypes) - Change channel subscriptions to the current websocket

The following methods are EventHandlers:

  • OnTickerReceived - EventHandler for data with response type ticker
  • OnSnapShotReceived - EventHandler for data with response type snapshot
  • OnLevel2UpdateReceived - EventHandler for data with response type level2
  • OnHeartbeatReceived - EventHandler for data with response type heartbeat
  • OnReceivedReceived - EventHandler for data with response type received
  • OnOpenReceived - EventHandler for data with response type open
  • OnStatusReceived - EventHandler for data with response type status
  • OnDoneReceived - EventHandler for data with response type done
  • OnMatchReceived - EventHandler for data with response type match
  • OnChangeReceived - EventHandler for data with response type change
  • OnLastMatchReceived - EventHandler for data with response type last match
  • OnErrorReceived - EventHandler for data with response type error
  • OnActivateReceived - Eventhandler for data with response type activate
  • OnWebSocketError - EventHandler for web socket error
  • OnWebSocketClose- EventHandler for web socket closing
  • OnWebSocketOpenAndSubscribed - EventHandler for web socket being opened and subscribed

Sandbox Support

Generate your key at https://public.sandbox.pro.coinbase.com/profile/api

csharp
//create an authenticator with your apiKey, signature and passphrase
var authenticator = new Authenticator("", "", "");

//create the CoinbasePro client and set the sandbox flag to true
var coinbaseProClient = new CoinbasePro.CoinbaseProClient(authenticator, true);

//use one of the services 
var response = await coinbaseProClient.OrdersService.PlaceMarketOrderAsync(OrderSide.Buy, "BTC-USD", 1);

Examples

Place a market order
csharp
//by size
var response = await coinbaseProClient.OrdersService.PlaceMarketOrderAsync(OrderSide.Buy, "BTC-USD", 1);

//by funds
var response = await coinbaseProClient.OrdersService.PlaceMarketOrderAsync(OrderSide.Buy, "BTC-USD", 50, MarketOrderAmountType.Funds);
Place a limit order
csharp
var response = await coinbaseProClient.OrdersService.PlaceLimitOrderAsync(OrderSide.Sell, "ETH-USD", 1, 400.0M);
Cancel all open or un-settled orders
csharp
var response = await coinbaseProClient.OrdersService.CancelAllOrdersAsync();
Getting account history (paged response)
…
Generate and email a report
csharp
var reportDateFrom = new DateTime(2017, 1, 1);
var reportDateTo = new DateTime(2018, 1, 1);
var accountId = "29318029382";

//generate and email accounts report csv
var accountResponse = coinbaseProClient.ReportsService.CreateNewAccountReportAsync(reportDateFrom, reportDateTo, accountId, "BTC-USD", "[email protected]", FileFormat.Csv);

//generate and email fills report pdf
var fillsResponse = coinbaseProClient.ReportsService.CreateNewFillsReportAsync(reportDateFrom, reportDateTo, "BTC-USD", accountId, "[email protected]", FileFormat.Pdf);
Overriding the HttpClient behavior

You can gain greater control of the http requests by implementing CoinbasePro.HttpClient.IHttpClient and passing that into the CoinbasePro constructor.

csharp
var myWay = new MyNamespace.MyHttpClient();

//create an authenticator with your apiKey, signature and passphrase
var authenticator = new Authenticator("", "", "");

//create the CoinbasePro client and set the httpClient to my way of behaving
var coinbaseProClient = new CoinbasePro.CoinbaseProClient(authenticator, myWay);

Logging

Logging is provided by Serilog - https://github.com/serilog/serilog

…

Contributors

Thanks for contributing!

  • @dgelineau
  • @quin810
  • @DontFretBrett
  • @chrisw000
  • @confessore
  • @sotam
  • @BradForsythe
  • @zaccharles
  • @BraveSirAndrew
  • @alexhiggins732
  • @kudobyte
  • @mailgerigk
  • @joshua211
  • @nscheibe

Bugs or questions?

Please open an issue for any bugs or questions

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#apibitcoincoinbasecoinbasepro

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具