Skip to content

Commit

Permalink
Updated CryptoExchange.Net (#6)
Browse files Browse the repository at this point in the history
Updated CryptoExchange.Net
  • Loading branch information
JKorf authored Feb 24, 2024
1 parent 78d214d commit e66dbca
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 34 deletions.
20 changes: 14 additions & 6 deletions CoinGecko.Net/CoinGecko.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<Nullable>enable</Nullable>
Expand All @@ -7,9 +7,9 @@
<PropertyGroup>
<PackageId>CoinGecko.Net</PackageId>
<Authors>JKorf</Authors>
<PackageVersion>2.0.6</PackageVersion>
<AssemblyVersion>2.0.6</AssemblyVersion>
<FileVersion>2.0.6</FileVersion>
<PackageVersion>2.1.0-beta1</PackageVersion>
<AssemblyVersion>2.1.0</AssemblyVersion>
<FileVersion>2.1.0</FileVersion>
<Description>CoinGecko.Net is a .Net wrapper for the CoinGecko API. It includes all features the API provides using clear and readable objects.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>CoinGecko CoinGecko.Net C# .Net CryptoCurrency Exchange API wrapper</PackageTags>
Expand All @@ -21,7 +21,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<NeutralLanguage>en</NeutralLanguage>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageReleaseNotes>2.0.6 - Updated CryptoExchange.Net</PackageReleaseNotes>
<PackageReleaseNotes>2.1.0-beta1 - Updated CryptoExchange.Net</PackageReleaseNotes>
</PropertyGroup>
<PropertyGroup>
<DocumentationFile>CoinGecko.Net.xml</DocumentationFile>
Expand All @@ -44,6 +44,14 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CryptoExchange.Net" Version="6.2.3" />
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
38 changes: 25 additions & 13 deletions CoinGecko.Net/CoinGecko.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions CoinGecko.Net/ExtensionMethods/CryptoClientExtensions.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Extensions for the ICryptoRestClient and ICryptoSocketClient interfaces
/// </summary>
public static class CryptoClientExtensions
{
/// <summary>
/// Get the CoinGecko REST Api client
/// </summary>
/// <param name="baseClient"></param>
/// <returns></returns>
public static ICoinGeckoRestClient CoinGecko(this ICryptoRestClient baseClient) => baseClient.TryGet<ICoinGeckoRestClient>(() => new CoinGeckoRestClient());
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// CoinGecko helpers
/// Extensions for DI
/// </summary>
public static class CoinGeckoHelpers
public static class ServiceCollectionExtensions
{
/// <summary>
/// Add the ICoinGeckoClient to the sevice collection so they can be injected
Expand All @@ -34,7 +36,8 @@ public static IServiceCollection AddCoinGecko(
services.AddHttpClient<ICoinGeckoRestClient, CoinGeckoRestClient>(options =>
{
options.Timeout = restOptions.RequestTimeout;
}).ConfigurePrimaryHttpMessageHandler(() => {
}).ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler();
if (restOptions.Proxy != null)
{
Expand All @@ -47,7 +50,7 @@ public static IServiceCollection AddCoinGecko(
return handler;
});

services.AddTransient<ICoinGeckoRestClient, CoinGeckoRestClient>();
services.AddTransient<ICryptoRestClient, CryptoRestClient>();
return services;
}
}
Expand Down
85 changes: 75 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

Expand Down

0 comments on commit e66dbca

Please sign in to comment.