{"id":13681480,"url":"https://github.com/dougdellolio/coinbasepro-csharp","last_synced_at":"2025-04-30T03:31:36.220Z","repository":{"id":33210432,"uuid":"111756734","full_name":"dougdellolio/coinbasepro-csharp","owner":"dougdellolio","description":"The unofficial .NET/C# client library for the Coinbase Pro/GDAX API","archived":false,"fork":false,"pushed_at":"2022-12-08T03:43:33.000Z","size":579,"stargazers_count":193,"open_issues_count":11,"forks_count":91,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-08T16:48:19.504Z","etag":null,"topics":["api","bitcoin","coinbase","coinbasepro","coinbasepro-api","csharp-client","ethereum","gdax","gdax-api","library","wrapper","wrapper-api"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dougdellolio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-23T03:03:38.000Z","updated_at":"2025-03-28T22:23:43.000Z","dependencies_parsed_at":"2023-01-14T23:55:36.922Z","dependency_job_id":null,"html_url":"https://github.com/dougdellolio/coinbasepro-csharp","commit_stats":null,"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dougdellolio%2Fcoinbasepro-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dougdellolio%2Fcoinbasepro-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dougdellolio%2Fcoinbasepro-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dougdellolio%2Fcoinbasepro-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dougdellolio","download_url":"https://codeload.github.com/dougdellolio/coinbasepro-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251635303,"owners_count":21619204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bitcoin","coinbase","coinbasepro","coinbasepro-api","csharp-client","ethereum","gdax","gdax-api","library","wrapper","wrapper-api"],"created_at":"2024-08-02T13:01:31.289Z","updated_at":"2025-04-30T03:31:35.821Z","avatar_url":"https://github.com/dougdellolio.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ecoinbasepro-csharp\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\nhttps://docs.pro.coinbase.com/\n\n\n[![Build status](https://ci.appveyor.com/api/projects/status/mdn0y9cu7dqsambv/branch/master?svg=true)](https://ci.appveyor.com/project/dougdellolio/coinbasepro-csharp/branch/master)\n[![NuGet](https://img.shields.io/nuget/v/GDAX.Api.ClientLibrary.svg)](https://www.nuget.org/packages/GDAX.Api.ClientLibrary/)\n[![NuGet](https://img.shields.io/nuget/dt/GDAX.Api.ClientLibrary.svg)](https://www.nuget.org/packages/GDAX.Api.ClientLibrary/)\n\n\u003c/div\u003e\n\u003ch1\u003eHow to Install\u003c/h1\u003e\n\n`PM\u003e Install-Package GDAX.Api.ClientLibrary`\n\n\u003ch1\u003eHow to Use\u003c/h1\u003e\n\n\u003ci\u003eGenerate your key at https://pro.coinbase.com/profile/api\u003c/i\u003e\n\n```csharp\n//create an authenticator with your apiKey, apiSecret and passphrase\nvar authenticator = new Authenticator(\"\u003capiKey\u003e\", \"\u003capiSecret\u003e\", \"\u003cpassphrase\u003e\");\n\n//create the CoinbasePro client\nvar coinbaseProClient = new CoinbasePro.CoinbaseProClient(authenticator);\n\n//use one of the services \nvar allAccounts = await coinbaseProClient.AccountsService.GetAllAccountsAsync();\n```\n\n\u003ch1\u003eWhat services are provided?\u003c/h1\u003e\n\n###### Accounts ######\n- GetAllAccountsAsync() - get all accounts\n- GetAccountByIdAsync(id) - get account by id\n- GetAccountHistoryAsync(id, limit, numberOfPages) - get account history (paged response)\n- GetAccountHoldsAsync(id, limit, numberOfPages) - get all holds placed on an account (paged response)\n\n###### CoinbaseAccounts ######\n- GetAllAccountsAsync() - get all coinbase accounts\n\n###### Orders ######\n- PlaceMarketOrderAsync(orderSide, productPair, amount, MarketOrderAmountType, clientOId) - place market order by size or funds\n- PlaceLimitOrderAsync(orderSide, productPair, size, price, timeInForce, postOnly, clientOId) - place limit order with time in force\n- PlaceLimitOrderAsync(orderSide, productPair, size, price, cancelAfter, postOnly, clientOId) - place limit order with cancel after date\n- PlaceStopOrderAsync(orderSide, productPair, size, limitPrice, stopPrice, clientOId) - place stop order with stop and limit price\n- CancelAllOrdersAsync() - cancel all orders\n- CancelOrderByIdAsync(id) - cancel order by id\n- GetAllOrdersAsync(orderStatus, limit, numberOfPages) - get all, active or pending orders (paged response)\n- GetAllOrdersAsync(orderStatus[], limit, numberOfPages) - get orders by multiple statuses (paged response)\n- GetOrderByIdAsync(id) - get order by id\n\n###### Payments ######\n- GetAllPaymentMethodsAsync() - get all payment methods\n\n###### Withdrawals ######\n- WithdrawFundsAsync(paymentMethodId, amount, currency) - withdraw funds to a payment method\n- WithdrawToCoinbaseAsync(coinbaseAccountId, amount, currency) - withdraw funds to a coinbase account\n- WithdrawToCryptoAsync(cryptoAddress, amount, currency, destinationTag) - withdraw funds to a crypto address\n- GetAllWithdrawals(profileId, before, after, limit) - list of withdrawals from the profile of the API key, in descending order by created time\n- GetWithdrawalById(transferId) - get information on a single withdrawal\n- GetFeeEstimateAsync(currency, cryptoAddress) - gets the network fee estimate when sending to the given address\n\n###### Deposits ######\n- GetAllDeposits(profileId, before, after, limit) - list of deposits from the profile of the API key, in descending order by created time\n- GetDepositById(transferId) - get information on a single deposit.\n- DepositFundsAsync(paymentMethodId, amount, currency) - deposits funds from a payment method\n- DepositCoinbaseFundsAsync(coinbaseAccountId, amount, currency) - deposits funds from a coinbase account\n- GenerateCryptoDepositAddressAsync(string coinbaseAccountId) - generate an address for crypto deposits\n\n###### Products ######\n- GetAllProductsAsync() - get a list of available currency pairs for trading\n- GetSingleProductAsync(productType) - get market data for a specific currency pair\n- GetProductOrderBookAsync(productType, productLevel) - get a list of open orders for a product (specify level 1, 2, or 3)\n- GetProductTickerAsync(productType) - get information about the last trade (tick), best bid/ask and 24h volume\n- GetTradesAsync(productType, limit, numberOfPages) - get latest trades for a product (paged response)\n- GetProductStatsAsync(productType) - get 24 hour stats for a product\n- GetHistoricRatesAsync(productPair, start, end, granularity) - get historic rates for a product, auto batches requests to pull complete date range\n\n###### Currencies ######\n- GetAllCurrenciesAsync() - gets a list of known currencies\n- GetCurrencyByIdAsync(currency) - list the currency for the specified id\n\n###### Fills ######\n- GetFillsByOrderIdAsync(orderId, limit, numberOfPages) - gets a list of all recent fills by order id (paged response)\n- GetFillsByProductIdAsync(productType, limit, numberOfPages) - gets a list of all recent fills by product type (paged response)\n\n###### Limits ######\n- GetCurrentExchangeLimitsAsync() - returns information on your payment method transfer limits, as well as buy/sell limits per currency\n\n###### Fundings ######\n- GetAllFundingsAsync(limit, fundingStatus, numberOfPages) - gets a list of all orders placed with a margin profile that draws funding (paged response)\n\n###### Reports ######\n- CreateNewAccountReportAsync(startDate, endDate, accountId, productType, email, fileFormat) - generate new account report\n- CreateNewFillsReportAsync(startDate, endDate, productType, accountId, email, fileFormat) - generate new fills report\n- GetReportStatus(id) - gets report status\n\n###### User Account ######\n- GetTrailingVolumeAsync() - get 30-day trailing volume for all products\n\n###### Fees ######\n- GetCurrentFeesAsync() - get your current maker \u0026 taker fee rates, as well as your 30-day trailing volume\n\n###### Stablecoin Conversions ######\n- CreateConversion(currencyFrom, currencyTo, amount) - convert bank-based dollars to blockchain-based digital dollars\n\n###### Profiles ######\n- GetAllProfilesAsync() - list your profiles\n- GetProfileByIdAsync(id) - get a single profile by profile id\n- CreateProfileTransferAsync(from, to, currency, amount) - transfer funds from API key’s profile to another user owned profile\n\n\u003ch1\u003eWebsocket Feed\u003c/h1\u003e\n\u003ch2\u003eHow to use with authentication\u003c/h2\u003e\n\n```csharp\n//create an authenticator with your apiKey, apiSecret and passphrase\nvar authenticator = new Authenticator(\"\u003capiKey\u003e\", \"\u003capiSecret\u003e\", \"\u003cpassphrase\u003e\");\n\n//create the CoinbasePro client\nvar coinbaseProClient = new CoinbasePro.CoinbaseProClient(authenticator);\n\n//use the websocket feed\nvar productTypes = new List\u003cstring\u003e() { \"BTC-EUR\", \"BTC-USD\" };\nvar channels = new List\u003cChannelType\u003e() { ChannelType.Full, ChannelType.User } // When not providing any channels, the socket will subscribe to all channels\n\nvar webSocket = coinbaseProClient.WebSocket;\nwebSocket.Start(productTypes, channels);\n\n// EventHandler for the heartbeat response type\nwebSocket.OnHeartbeatReceived += WebSocket_OnHeartbeatReceived;\n\nprivate static void WebSocket_OnHeartbeatReceived(object sender, WebfeedEventArgs\u003cHeartbeat\u003e e)\n{\n  throw new NotImplementedException();\n}\n```\n\n\u003ch2\u003eHow to use without authentication\u003c/h2\u003e\n\n```csharp\n//create the CoinbasePro client without an authenticator\nvar coinbaseProClient = new CoinbasePro.CoinbaseProClient();\n\n//use the websocket feed\nvar productTypes = new List\u003cstring\u003e() { \"BTC-EUR\", \"BTC-USD\" };\nvar channels = new List\u003cChannelType\u003e() { ChannelType.Full, ChannelType.User }; // When not providing any channels, the socket will subscribe to all channels\n\nvar webSocket = coinbaseProClient.WebSocket;\nwebSocket.Start(productTypes, channels);\n\n// EventHandler for the heartbeat response type\nwebSocket.OnHeartbeatReceived += WebSocket_OnHeartbeatReceived;\n\nprivate static void WebSocket_OnHeartbeatReceived(object sender, WebfeedEventArgs\u003cHeartbeat\u003e e)\n{\n  throw new NotImplementedException();\n}\n```\n\n\u003ch2\u003eAvailable functions\u003c/h2\u003e\nThese are the starting and stopping methods:\n\n- 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\n- Stop() - Stops the websocket feed\n- ChangeChannels(productTypes) - Change channel subscriptions to the current websocket\n\nThe following methods are EventHandlers:\n\n- OnTickerReceived - EventHandler for data with response type `ticker`\n- OnSnapShotReceived - EventHandler for data with response type `snapshot`\n- OnLevel2UpdateReceived - EventHandler for data with response type `level2`\n- OnHeartbeatReceived - EventHandler for data with response type `heartbeat`\n- OnReceivedReceived - EventHandler for data with response type `received`\n- OnOpenReceived - EventHandler for data with response type `open`\n- OnStatusReceived - EventHandler for data with response type `status`\n- OnDoneReceived - EventHandler for data with response type `done`\n- OnMatchReceived - EventHandler for data with response type `match`\n- OnChangeReceived - EventHandler for data with response type `change`\n- OnLastMatchReceived - EventHandler for data with response type `last match`\n- OnErrorReceived - EventHandler for data with response type `error`\n- OnActivateReceived - Eventhandler for data with response type `activate`\n- OnWebSocketError - EventHandler for web socket error\n- OnWebSocketClose- EventHandler for web socket closing\n- OnWebSocketOpenAndSubscribed - EventHandler for web socket being opened and subscribed\n\n\u003ch1\u003eSandbox Support\u003c/h1\u003e\n\n\u003ci\u003eGenerate your key at https://public.sandbox.pro.coinbase.com/profile/api\u003c/i\u003e\n\n```csharp\n//create an authenticator with your apiKey, signature and passphrase\nvar authenticator = new Authenticator(\"\u003capiKey\u003e\", \"\u003csignature\u003e\", \"\u003cpassphrase\u003e\");\n\n//create the CoinbasePro client and set the sandbox flag to true\nvar coinbaseProClient = new CoinbasePro.CoinbaseProClient(authenticator, true);\n\n//use one of the services \nvar response = await coinbaseProClient.OrdersService.PlaceMarketOrderAsync(OrderSide.Buy, \"BTC-USD\", 1);\n```\n\n\u003ch1\u003eExamples\u003c/h1\u003e\n\n###### Place a market order ######\n\n```csharp\n//by size\nvar response = await coinbaseProClient.OrdersService.PlaceMarketOrderAsync(OrderSide.Buy, \"BTC-USD\", 1);\n\n//by funds\nvar response = await coinbaseProClient.OrdersService.PlaceMarketOrderAsync(OrderSide.Buy, \"BTC-USD\", 50, MarketOrderAmountType.Funds);\n```\n\n###### Place a limit order ######\n\n```csharp\nvar response = await coinbaseProClient.OrdersService.PlaceLimitOrderAsync(OrderSide.Sell, \"ETH-USD\", 1, 400.0M);\n```\n\n###### Cancel all open or un-settled orders ######\n\n```csharp\nvar response = await coinbaseProClient.OrdersService.CancelAllOrdersAsync();\n```\n\n###### Getting account history (\u003ci\u003epaged response\u003c/i\u003e) ######\n\n```csharp\n//the limit is the amount of items per page - in this case it would be 2 items (default is 100)\n//you can also specify the number of pages to request - in this case it would be the first 5 pages (default is 0 which will request all pages)\n//some routes may require the number of pages to be specified as there are rate limits\nvar accountHistoryResponse = await coinbaseProClient.AccountsService.GetAccountHistoryAsync(\"ef56a389\", 2, 5);\n\n//retrieve by page number - this would return the first page of the response (latest first)\nvar firstPage = accountHistoryResponse.ToList()[0];\n\n//get the first item on the page\nvar firstAccountHistoryOnFirstPage = firstPage.ToList()[0];\n\n//get the second item on the page\nvar secondAccountHistoryOnFirstPage = firstPage.ToList()[1];\n```\n\n###### Generate and email a report ######\n\n```csharp\nvar reportDateFrom = new DateTime(2017, 1, 1);\nvar reportDateTo = new DateTime(2018, 1, 1);\nvar accountId = \"29318029382\";\n\n//generate and email accounts report csv\nvar accountResponse = coinbaseProClient.ReportsService.CreateNewAccountReportAsync(reportDateFrom, reportDateTo, accountId, \"BTC-USD\", \"me@email.com\", FileFormat.Csv);\n\n//generate and email fills report pdf\nvar fillsResponse = coinbaseProClient.ReportsService.CreateNewFillsReportAsync(reportDateFrom, reportDateTo, \"BTC-USD\", accountId, \"me@email.com\", FileFormat.Pdf);\n```\n\n###### Overriding the HttpClient behavior ######\n\nYou can gain greater control of the http requests by implementing CoinbasePro.HttpClient.IHttpClient and passing that into the CoinbasePro constructor.\n\n```csharp\nvar myWay = new MyNamespace.MyHttpClient();\n\n//create an authenticator with your apiKey, signature and passphrase\nvar authenticator = new Authenticator(\"\u003capiKey\u003e\", \"\u003csignature\u003e\", \"\u003cpassphrase\u003e\");\n\n//create the CoinbasePro client and set the httpClient to my way of behaving\nvar coinbaseProClient = new CoinbasePro.CoinbaseProClient(authenticator, myWay);\n```\n\n\u003ch1\u003eLogging\u003c/h1\u003e\n\nLogging is provided by Serilog - https://github.com/serilog/serilog\n\n```csharp\n//configure the application logging to output to console and a file called log.txt\nSerilog.Log.Logger = new LoggerConfiguration()\n\t\t\t\t.MinimumLevel.Debug()\n\t\t\t\t.WriteTo.Console()\n\t\t\t\t.WriteTo.File(\"log.txt\",\n\t\t\t\t\trollingInterval: RollingInterval.Day,\n\t\t\t\t\trollOnFileSizeLimit: true)\n\t\t\t\t.CreateLogger();\n\n//create an authenticator with your apiKey, signature and passphrase\nvar authenticator = new Authenticator(\"\u003capiKey\u003e\", \"\u003csignature\u003e\", \"\u003cpassphrase\u003e\");\n\n//create the CoinbasePro client\nvar coinbaseProClient = new CoinbasePro.CoinbaseProClient(authenticator);\n\n//use one of the services \nvar response = await coinbaseProClient.OrdersService.PlaceMarketOrderAsync(OrderSide.Buy, \"BTC-USD\", 1);\n```\n\n\u003ch1\u003eContributors\u003c/h1\u003e\n\nThanks for contributing!\n\n- @dgelineau\n- @quin810\n- @DontFretBrett\n- @chrisw000\n- @confessore\n- @sotam\n- @BradForsythe\n- @zaccharles\n- @BraveSirAndrew\n- @alexhiggins732\n- @kudobyte\n- @mailgerigk\n- @joshua211\n- @nscheibe\n\n\u003ch1\u003eBugs or questions?\u003c/h1\u003e\n\nPlease open an issue for any bugs or questions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdougdellolio%2Fcoinbasepro-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdougdellolio%2Fcoinbasepro-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdougdellolio%2Fcoinbasepro-csharp/lists"}