-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched json (de)serialization from Newtonsoft.Json to System.Text.Json Added support for setting API key Added error parsing implementation Added pro API endpoint to CoinGeckoEnvironment Added GetMarketsAsync endpoint Added GetCompanyHoldingsAsync endpoint Added GetExchangeDerivativesDetailsAsync endpoint Added GetApiUsageAsync endpoint Added precision parameter to GetMarketChartAsync, GetOhlcAsync Updated response models Updated API doc references Removed includeTickers parameter from GetDerivativesAsync endpoint Removed assetPlatformId parameter from GetNftsAsync endpoint
- Loading branch information
Showing
56 changed files
with
2,229 additions
and
1,118 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using CryptoExchange.Net.Objects; | ||
using CryptoExchange.Net.RateLimiting.Filters; | ||
using CryptoExchange.Net.RateLimiting.Guards; | ||
using CryptoExchange.Net.RateLimiting.Interfaces; | ||
using CryptoExchange.Net.RateLimiting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using CryptoExchange.Net.SharedApis; | ||
|
||
namespace CoinGecko.Net | ||
{ | ||
/// <summary> | ||
/// CoinGecko information and configuration | ||
/// </summary> | ||
public static class CoinGeckoApi | ||
{ | ||
/// <summary> | ||
/// Url to the main website | ||
/// </summary> | ||
public static string Url { get; } = "https://www.coingecko.com"; | ||
|
||
/// <summary> | ||
/// Urls to the API documentation | ||
/// </summary> | ||
public static string[] ApiDocsUrl { get; } = new[] { | ||
"https://docs.coingecko.com/" | ||
}; | ||
|
||
/// <summary> | ||
/// Rate limiter configuration for the CoinGecko API | ||
/// </summary> | ||
public static CoinGeckoRateLimiters RateLimiter { get; } = new CoinGeckoRateLimiters(); | ||
} | ||
|
||
/// <summary> | ||
/// Rate limiter configuration for the CoinGecko API | ||
/// </summary> | ||
public class CoinGeckoRateLimiters | ||
{ | ||
/// <summary> | ||
/// Event for when a rate limit is triggered | ||
/// </summary> | ||
public event Action<RateLimitEvent> RateLimitTriggered; | ||
|
||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
internal CoinGeckoRateLimiters() | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
{ | ||
Initialize(); | ||
} | ||
|
||
private void Initialize() | ||
{ | ||
CoinGecko = new RateLimitGate("CoinGecko"); | ||
CoinGecko.RateLimitTriggered += (x) => RateLimitTriggered?.Invoke(x); | ||
} | ||
|
||
internal IRateLimitGate CoinGecko { get; private set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Text; | ||
using CoinGecko.Net.Objects; | ||
using CryptoExchange.Net.Authentication; | ||
using CryptoExchange.Net.Clients; | ||
using CryptoExchange.Net.Objects; | ||
|
||
namespace CoinGecko.Net | ||
{ | ||
internal class CoinGeckoAuthenticationProvider : AuthenticationProvider<CoinGeckoApiCredentials> | ||
{ | ||
/// <summary> | ||
/// Whether or not a demo key is configured | ||
/// </summary> | ||
public bool IsDemo => _credentials.DemoKey; | ||
|
||
public CoinGeckoAuthenticationProvider(CoinGeckoApiCredentials credentials) : base(credentials) | ||
{ | ||
} | ||
|
||
public override void AuthenticateRequest( | ||
RestApiClient apiClient, | ||
Uri uri, | ||
HttpMethod method, | ||
ref IDictionary<string, object>? uriParameters, | ||
ref IDictionary<string, object>? bodyParameters, | ||
ref Dictionary<string, string>? headers, | ||
bool auth, | ||
ArrayParametersSerialization arraySerialization, | ||
HttpMethodParameterPosition parameterPosition, | ||
RequestBodyFormat requestBodyFormat) | ||
{ | ||
uriParameters ??= new ParameterCollection(); | ||
if (_credentials.DemoKey) | ||
uriParameters.Add("x_cg_demo_api_key", _credentials.Key); | ||
else | ||
uriParameters.Add("x_cg_pro_api_key", _credentials.Key); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.