From e66dbcac257fc7d6a977b0691fd2c1d123802f9f Mon Sep 17 00:00:00 2001 From: Jan Korf Date: Sat, 24 Feb 2024 22:36:29 +0100 Subject: [PATCH] Updated CryptoExchange.Net (#6) Updated CryptoExchange.Net --- CoinGecko.Net/CoinGecko.Net.csproj | 20 +++-- CoinGecko.Net/CoinGecko.Net.xml | 38 ++++++--- .../CryptoClientExtensions.cs | 22 +++++ .../ServiceCollectionExtensions.cs} | 13 +-- README.md | 85 ++++++++++++++++--- 5 files changed, 144 insertions(+), 34 deletions(-) create mode 100644 CoinGecko.Net/ExtensionMethods/CryptoClientExtensions.cs rename CoinGecko.Net/{CoinGeckoHelpers.cs => ExtensionMethods/ServiceCollectionExtensions.cs} (83%) diff --git a/CoinGecko.Net/CoinGecko.Net.csproj b/CoinGecko.Net/CoinGecko.Net.csproj index c624e1c..a4a0e1b 100644 --- a/CoinGecko.Net/CoinGecko.Net.csproj +++ b/CoinGecko.Net/CoinGecko.Net.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;netstandard2.1 enable @@ -7,9 +7,9 @@ CoinGecko.Net JKorf - 2.0.6 - 2.0.6 - 2.0.6 + 2.1.0-beta1 + 2.1.0 + 2.1.0 CoinGecko.Net is a .Net wrapper for the CoinGecko API. It includes all features the API provides using clear and readable objects. false CoinGecko CoinGecko.Net C# .Net CryptoCurrency Exchange API wrapper @@ -21,7 +21,7 @@ README.md en true - 2.0.6 - Updated CryptoExchange.Net + 2.1.0-beta1 - Updated CryptoExchange.Net CoinGecko.Net.xml @@ -44,6 +44,14 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + \ No newline at end of file diff --git a/CoinGecko.Net/CoinGecko.Net.xml b/CoinGecko.Net/CoinGecko.Net.xml index 39731c7..093dfdf 100644 --- a/CoinGecko.Net/CoinGecko.Net.xml +++ b/CoinGecko.Net/CoinGecko.Net.xml @@ -185,19 +185,6 @@ - - - CoinGecko helpers - - - - - Add the ICoinGeckoClient to the sevice collection so they can be injected - - The service collection - Set default options for the rest client - - Client for accessing the CoinGecko Rest API. @@ -2779,5 +2766,30 @@ Api options + + + Extensions for the ICryptoRestClient and ICryptoSocketClient interfaces + + + + + Get the CoinGecko REST Api client + + + + + + + Extensions for DI + + + + + Add the ICoinGeckoClient to the sevice collection so they can be injected + + The service collection + Set default options for the rest client + + diff --git a/CoinGecko.Net/ExtensionMethods/CryptoClientExtensions.cs b/CoinGecko.Net/ExtensionMethods/CryptoClientExtensions.cs new file mode 100644 index 0000000..00596e6 --- /dev/null +++ b/CoinGecko.Net/ExtensionMethods/CryptoClientExtensions.cs @@ -0,0 +1,22 @@ +using CoinGecko.Net.Clients; +using CoinGecko.Net.Interfaces; +using CryptoExchange.Net.Interfaces.CommonClients; +using System; +using System.Collections.Generic; +using System.Text; + +namespace CryptoExchange.Net.Interfaces +{ + /// + /// Extensions for the ICryptoRestClient and ICryptoSocketClient interfaces + /// + public static class CryptoClientExtensions + { + /// + /// Get the CoinGecko REST Api client + /// + /// + /// + public static ICoinGeckoRestClient CoinGecko(this ICryptoRestClient baseClient) => baseClient.TryGet(() => new CoinGeckoRestClient()); + } +} diff --git a/CoinGecko.Net/CoinGeckoHelpers.cs b/CoinGecko.Net/ExtensionMethods/ServiceCollectionExtensions.cs similarity index 83% rename from CoinGecko.Net/CoinGeckoHelpers.cs rename to CoinGecko.Net/ExtensionMethods/ServiceCollectionExtensions.cs index b44e695..eceaa59 100644 --- a/CoinGecko.Net/CoinGeckoHelpers.cs +++ b/CoinGecko.Net/ExtensionMethods/ServiceCollectionExtensions.cs @@ -1,17 +1,19 @@ using CoinGecko.Net.Clients; using CoinGecko.Net.Interfaces; using CoinGecko.Net.Objects.Options; +using CryptoExchange.Net.Clients; +using CryptoExchange.Net.Interfaces; using Microsoft.Extensions.DependencyInjection; using System; using System.Net; using System.Net.Http; -namespace CoinGecko.Net +namespace Microsoft.Extensions.DependencyInjection { /// - /// CoinGecko helpers + /// Extensions for DI /// - public static class CoinGeckoHelpers + public static class ServiceCollectionExtensions { /// /// Add the ICoinGeckoClient to the sevice collection so they can be injected @@ -34,7 +36,8 @@ public static IServiceCollection AddCoinGecko( services.AddHttpClient(options => { options.Timeout = restOptions.RequestTimeout; - }).ConfigurePrimaryHttpMessageHandler(() => { + }).ConfigurePrimaryHttpMessageHandler(() => + { var handler = new HttpClientHandler(); if (restOptions.Proxy != null) { @@ -47,7 +50,7 @@ public static IServiceCollection AddCoinGecko( return handler; }); - services.AddTransient(); + services.AddTransient(); return services; } } diff --git a/README.md b/README.md index 3feb98a..5c6da08 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,79 @@ -# CoinGecko.Net -[![.NET](https://github.com/JKorf/CoinGecko.Net/actions/workflows/dotnet.yml/badge.svg)](https://github.com/JKorf/CoinGecko.Net/actions/workflows/dotnet.yml) [![Nuget version](https://img.shields.io/nuget/v/coingecko.net.svg)](https://www.nuget.org/packages/CoinGecko.Net) [![Nuget downloads](https://img.shields.io/nuget/dt/CoinGecko.Net.svg)](https://www.nuget.org/packages/CoinGecko.Net) +# ![.CoinGecko.Net](https://github.com/JKorf/CoinGecko.Net/blob/main/CoinGecko.Net/Icon/icon.png?raw=true) CoinGecko.Net -CoinGecko.Net is a wrapper around the CoinGecko API as described on [CoinGecko](https://www.coingecko.com/en/api/documentation), including all features the API provides using clear and readable objects. +[![.NET](https://img.shields.io/github/actions/workflow/status/JKorf/CoinGecko.Net/dotnet.yml?style=for-the-badge)](https://github.com/JKorf/CoinGecko.Net/actions/workflows/dotnet.yml) -**If you think something is broken, something is missing or have any questions, please open an [Issue](https://github.com/JKorf/Binance.Net/issues)** +CoinGecko.Net is a wrapper around the CoinGecko API as described on [CoinGecko](https://www.coingecko.com/en/api/documentation), including all features the API provides using clear and readable objects. -[Documentation](https://jkorf.github.io/CoinGecko.Net/) +## Supported Frameworks +The library is targeting both `.NET Standard 2.0` and `.NET Standard 2.1` for optimal compatibility + +|.NET implementation|Version Support| +|--|--| +|.NET Core|`2.0` and higher| +|.NET Framework|`4.6.1` and higher| +|Mono|`5.4` and higher| +|Xamarin.iOS|`10.14` and higher| +|Xamarin.Android|`8.0` and higher| +|UWP|`10.0.16299` and higher| +|Unity|`2018.1` and higher| + +## Get the library +[![Nuget version](https://img.shields.io/nuget/v/coingecko.net.svg?style=for-the-badge)](https://www.nuget.org/packages/CoinGecko.Net) [![Nuget downloads](https://img.shields.io/nuget/dt/CoinGecko.Net.svg?style=for-the-badge)](https://www.nuget.org/packages/CoinGecko.Net) + + dotnet add package CoinGecko.Net + +## How to use +* REST Endpoints + ```csharp + // Get the ETH/USDT ticker via rest request + var restClient = new CoinGeckoRestClient(); + var tickerResult = await restClient.Api.GetMarketsAsync("USD"); + var lastPrice = tickerResult.Data.First().CurrentPrice; + ``` + +For information on the clients, dependency injection, response processing and more see the [documentation](https://jkorf.github.io/CryptoExchange.Net), or have a look at the examples [here](https://github.com/JKorf/CryptoExchange.Net/tree/master/Examples). + +## CryptoExchange.Net +CoinGecko.Net is based on the [CryptoExchange.Net](https://github.com/JKorf/CryptoExchange.Net) base library. Other exchange API implementations based on the CryptoExchange.Net base library are available and follow the same logic. + +CryptoExchange.Net also allows for [easy access to different exchange API's](https://jkorf.github.io/CryptoExchange.Net#idocs_common). + +|Exchange|Repository|Nuget| +|--|--|--| +|Binance|[JKorf/Binance.Net](https://github.com/JKorf/Binance.Net)|[![Nuget version](https://img.shields.io/nuget/v/Binance.net.svg?style=flat-square)](https://www.nuget.org/packages/Binance.Net)| +|Bitfinex|[JKorf/Bitfinex.Net](https://github.com/JKorf/Bitfinex.Net)|[![Nuget version](https://img.shields.io/nuget/v/Bitfinex.net.svg?style=flat-square)](https://www.nuget.org/packages/Bitfinex.Net)| +|Bitget|[JKorf/Bitget.Net](https://github.com/JKorf/Bitget.Net)|[![Nuget version](https://img.shields.io/nuget/v/JK.Bitget.net.svg?style=flat-square)](https://www.nuget.org/packages/JK.Bitget.Net)| +|Bybit|[JKorf/Bybit.Net](https://github.com/JKorf/Bybit.Net)|[![Nuget version](https://img.shields.io/nuget/v/Bybit.net.svg?style=flat-square)](https://www.nuget.org/packages/Bybit.Net)| +|CoinEx|[JKorf/CoinEx.Net](https://github.com/JKorf/CoinEx.Net)|[![Nuget version](https://img.shields.io/nuget/v/CoinEx.net.svg?style=flat-square)](https://www.nuget.org/packages/CoinEx.Net)| +|Huobi/HTX|[JKorf/Huobi.Net](https://github.com/JKorf/Huobi.Net)|[![Nuget version](https://img.shields.io/nuget/v/Huobi.net.svg?style=flat-square)](https://www.nuget.org/packages/Huobi.Net)| +|Kraken|[JKorf/Kraken.Net](https://github.com/JKorf/Kraken.Net)|[![Nuget version](https://img.shields.io/nuget/v/KrakenExchange.net.svg?style=flat-square)](https://www.nuget.org/packages/KrakenExchange.Net)| +|Kucoin|[JKorf/Kucoin.Net](https://github.com/JKorf/Kucoin.Net)|[![Nuget version](https://img.shields.io/nuget/v/Kucoin.net.svg?style=flat-square)](https://www.nuget.org/packages/Kucoin.Net)| +|Mexc|[JKorf/Mexc.Net](https://github.com/JKorf/Mexc.Net)|[![Nuget version](https://img.shields.io/nuget/v/JK.Mexc.net.svg?style=flat-square)](https://www.nuget.org/packages/JK.Mexc.Net)| +|OKX|[JKorf/OKX.Net](https://github.com/JKorf/OKX.Net)|[![Nuget version](https://img.shields.io/nuget/v/JK.OKX.net.svg?style=flat-square)](https://www.nuget.org/packages/JK.OKX.Net)| -## Installation -`dotnet add package CoinGecko.Net` +## Discord +[![Nuget version](https://img.shields.io/discord/847020490588422145?style=for-the-badge)](https://discord.gg/MSpeEtSY8t) +A Discord server is available [here](https://discord.gg/MSpeEtSY8t). Feel free to join for discussion and/or questions around the CryptoExchange.Net and implementation libraries. + +## Supported functionality + +### V3 API +|API|Supported|Location| +|--|--:|--| +|Ping|✓|`restClient.Api`| +|Simple|✓|`restClient.Api`| +|Coins|✓|`restClient.Api`| +|Contract|X|| +|Asset Platforms|✓|`restClient.Api`| +|Categories|✓|`restClient.Api`| +|Exchanges|✓|`restClient.Api`| +|Derivatives|✓|`restClient.Api`| +|Nfts|X|| +|Exchange Rates|✓|`restClient.Api`| +|Search|✓|`restClient.Api`| +|Trending|✓|`restClient.Api`| +|Global|✓|`restClient.Api`| +|Companies|X|| ## Support the project I develop and maintain this package on my own for free in my spare time, any support is greatly appreciated. @@ -22,10 +87,10 @@ Make a one time donation in a crypto currency of your choice. If you prefer to d ### Sponsor Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf). -## Discord -A Discord server is available [here](https://discord.gg/MSpeEtSY8t). For discussion and/or questions around the CryptoExchange.Net and implementation libraries, feel free to join. - ## Release notes +* Version 2.1.0-beta1 - 06 Feb 2024 + * Updated CryptoExchange.Net + * Version 2.0.6 - 03 Dec 2023 * Updated CryptoExchange.Net