From c2b70188f05b4dd90f8557ec4199bc8ab38959ac Mon Sep 17 00:00:00 2001 From: Jan Korf Date: Mon, 11 Nov 2024 10:35:08 +0100 Subject: [PATCH] Feature/system text json (#13) 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 --- CoinGecko.Net.UnitTests/JsonTests.cs | 39 - .../Clients/CoinGeckoRestClientApi.cs | 293 +++-- CoinGecko.Net/CoinGecko.Net.xml | 1049 ++++++++++++----- CoinGecko.Net/CoinGeckoApi.cs | 61 + .../CoinGeckoAuthenticationProvider.cs | 42 + CoinGecko.Net/CoinGeckoEnvironment.cs | 24 +- .../ServiceCollectionExtensions.cs | 1 - .../Interfaces/ICoinGeckoRestClientApi.cs | 141 ++- .../Objects/CoinGeckoApiAddresses.cs | 11 +- .../Objects/CoinGeckoApiCredentials.cs | 34 + .../Objects/Models/CoinGeckoApiUsage.cs | 41 + .../Objects/Models/CoinGeckoAsset.cs | 13 +- .../Objects/Models/CoinGeckoAssetDetails.cs | 104 +- ...setMarket.cs => CoinGeckoAssetExchange.cs} | 17 +- .../Objects/Models/CoinGeckoAssetHistory.cs | 42 +- .../Objects/Models/CoinGeckoAssetPlatform.cs | 19 +- .../Objects/Models/CoinGeckoCategory.cs | 5 +- .../Objects/Models/CoinGeckoCodeAddDel.cs | 8 +- .../Objects/Models/CoinGeckoCommunityData.cs | 19 +- .../Objects/Models/CoinGeckoCompanyHolding.cs | 78 ++ .../Objects/Models/CoinGeckoDerivative.cs | 27 +- .../Models/CoinGeckoDerivativeTicker.cs | 99 ++ .../Objects/Models/CoinGeckoDeveloperData.cs | 23 +- .../Objects/Models/CoinGeckoExchange.cs | 22 +- .../Models/CoinGeckoExchangeDerivative.cs | 24 +- .../Models/CoinGeckoExchangeDetails.cs | 46 +- .../Objects/Models/CoinGeckoExchangeRates.cs | 6 + .../Objects/Models/CoinGeckoGlobalData.cs | 29 +- .../Objects/Models/CoinGeckoGlobalDefiData.cs | 17 +- .../Objects/Models/CoinGeckoIcoData.cs | 158 --- .../Objects/Models/CoinGeckoImages.cs | 7 +- .../Objects/Models/CoinGeckoIndex.cs | 32 - .../Objects/Models/CoinGeckoLinks.cs | 30 +- .../Objects/Models/CoinGeckoListItem.cs | 6 +- .../Objects/Models/CoinGeckoMarket.cs | 58 +- .../Objects/Models/CoinGeckoMarketChart.cs | 7 +- .../Objects/Models/CoinGeckoMarketData.cs | 93 +- .../Models/CoinGeckoMarketDataCategory.cs | 26 +- CoinGecko.Net/Objects/Models/CoinGeckoNft.cs | 9 +- .../Objects/Models/CoinGeckoNftDetails.cs | 183 ++- CoinGecko.Net/Objects/Models/CoinGeckoOhlc.cs | 4 +- .../Objects/Models/CoinGeckoPlatform.cs | 9 +- .../Models/CoinGeckoPublicInterestStats.cs | 6 +- .../Objects/Models/CoinGeckoSearchResult.cs | 44 +- .../Objects/Models/CoinGeckoStatusUpdate.cs | 18 +- .../Objects/Models/CoinGeckoTicker.cs | 39 +- .../Objects/Models/CoinGeckoTickers.cs | 5 +- .../Objects/Models/CoinGeckoTrendingSearch.cs | 196 ++- .../Objects/Options/CoinGeckoRestOptions.cs | 2 +- CoinGecko.Net/Usings.cs | 2 +- .../CoinGecko.Examples.Api.csproj | 7 +- Examples/CoinGecko.Examples.Api/Program.cs | 6 +- .../CoinGecko.Examples.Console.csproj | 4 +- Examples/Examples.sln | 10 +- README.md | 14 +- docs/index.html | 38 +- 56 files changed, 2229 insertions(+), 1118 deletions(-) delete mode 100644 CoinGecko.Net.UnitTests/JsonTests.cs create mode 100644 CoinGecko.Net/CoinGeckoApi.cs create mode 100644 CoinGecko.Net/CoinGeckoAuthenticationProvider.cs create mode 100644 CoinGecko.Net/Objects/CoinGeckoApiCredentials.cs create mode 100644 CoinGecko.Net/Objects/Models/CoinGeckoApiUsage.cs rename CoinGecko.Net/Objects/Models/{CoinGeckoAssetMarket.cs => CoinGeckoAssetExchange.cs} (53%) create mode 100644 CoinGecko.Net/Objects/Models/CoinGeckoCompanyHolding.cs create mode 100644 CoinGecko.Net/Objects/Models/CoinGeckoDerivativeTicker.cs delete mode 100644 CoinGecko.Net/Objects/Models/CoinGeckoIcoData.cs delete mode 100644 CoinGecko.Net/Objects/Models/CoinGeckoIndex.cs diff --git a/CoinGecko.Net.UnitTests/JsonTests.cs b/CoinGecko.Net.UnitTests/JsonTests.cs deleted file mode 100644 index 3250331..0000000 --- a/CoinGecko.Net.UnitTests/JsonTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -using NUnit.Framework; -using System.Collections.Generic; -using System.Threading.Tasks; -using CryptoExchange.Net.Interfaces; -using CoinGecko.Net.Clients; -using CoinGecko.Net.Objects; -using Bybit.Net.UnitTests; - -namespace CoinGecko.Net.UnitTests -{ - [TestFixture] - public class JsonTests - { - private JsonToObjectComparer _comparer = new JsonToObjectComparer((json) => TestHelpers.CreateResponseClient(json, x => - { - x.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "123"); - x.ApiOptions.OutputOriginalData = true; - }, - System.Net.HttpStatusCode.OK)); - - [Test] - public async Task ValidateCalls() - { - await _comparer.ProcessSubject("", c => c.Api, - useNestedJsonPropertyForCompare: new Dictionary - { - { "GetGlobalDataAsync", "data" }, - { "GetGlobalDefiDataAsync", "data" }, - }, - ignoreProperties: new Dictionary> - { - { "SearchAsync", new List { "icos" } }, - { "GetTrendingSearchesAsync", new List { "exchanges" } } - } - ); - } - - } -} diff --git a/CoinGecko.Net/Clients/CoinGeckoRestClientApi.cs b/CoinGecko.Net/Clients/CoinGeckoRestClientApi.cs index 96e1096..c4969b5 100644 --- a/CoinGecko.Net/Clients/CoinGeckoRestClientApi.cs +++ b/CoinGecko.Net/Clients/CoinGeckoRestClientApi.cs @@ -1,10 +1,12 @@ using CoinGecko.Net.Interfaces; +using CoinGecko.Net.Objects; using CoinGecko.Net.Objects.Models; using CoinGecko.Net.Objects.Options; using CryptoExchange.Net; using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Clients; -using CryptoExchange.Net.Converters; +using CryptoExchange.Net.Converters.MessageParsing; +using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Objects; using CryptoExchange.Net.SharedApis; using Microsoft.Extensions.Logging; @@ -20,9 +22,13 @@ namespace CoinGecko.Net.Clients /// internal class CoinGeckoRestClientApi : RestApiClient, ICoinGeckoRestClientApi { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly CoinGeckoRestOptions _options; + internal CoinGeckoRestClientApi(ILogger logger, HttpClient? httpClient, CoinGeckoRestOptions options) - : base(logger, httpClient, options.Environment.RestApiAddress, options, options.ApiOptions) + : base(logger, httpClient, options.Environment.RestApiAddressPublic, options, options.ApiOptions) { + _options = options; var version = Assembly.GetAssembly(typeof(RestApiClient)).GetName().Version; StandardRequestHeaders = new Dictionary @@ -31,6 +37,11 @@ internal CoinGeckoRestClientApi(ILogger logger, HttpClient? httpClient, CoinGeck }; } + /// + protected override IStreamMessageAccessor CreateAccessor() => new SystemTextJsonStreamMessageAccessor(); + /// + protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer(); + /// public override string FormatSymbol(string baseAsset, string quoteAsset, TradingMode tradingMode, DateTime? deliverTime = null) => throw new NotImplementedException(); @@ -39,8 +50,10 @@ internal CoinGeckoRestClientApi(ILogger logger, HttpClient? httpClient, CoinGeck /// public async Task> PingAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - var result = await SendRequestAsync>(GetUrl("api/v3/ping"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/ping", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + var result = await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); + if (!result) return result.As(default); @@ -54,10 +67,10 @@ public async Task> PingAsync(CancellationToken ct = defaul /// public async Task>> GetAssetsAsync(bool? includePlatform = null, CancellationToken ct = default) { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("includePlatform", includePlatform); - - return await SendRequestAsync>(GetUrl("api/v3/coins/list"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("include_platform", includePlatform?.ToString().ToLowerInvariant()); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/coins/list", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -74,9 +87,11 @@ public async Task>> GetMarketsAsync( int? pageSize = null, bool? sparkline = null, IEnumerable? priceChangePercentages = null, + string? locale = null, + string? precision = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("vs_currency", quoteAsset); parameters.AddOptionalParameter("ids", assetIds == null ? null : string.Join(",", assetIds)); parameters.AddOptionalParameter("category", category); @@ -85,8 +100,11 @@ public async Task>> GetMarketsAsync( parameters.AddOptionalParameter("page", page); parameters.AddOptionalParameter("sparkline", sparkline); parameters.AddOptionalParameter("price_change_percentage", priceChangePercentages == null ? null : string.Join(", ", priceChangePercentages)); + parameters.AddOptionalParameter("locale", locale); + parameters.AddOptionalParameter("precision", precision); - return await SendRequestAsync>(GetUrl("api/v3/coins/markets"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/coins/markets", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -104,7 +122,7 @@ public async Task> GetAssetDetailsAsync( bool? sparkline = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("localization", localization); parameters.AddOptionalParameter("tickers", tickers); parameters.AddOptionalParameter("market_data", marketData); @@ -112,7 +130,8 @@ public async Task> GetAssetDetailsAsync( parameters.AddOptionalParameter("developer_data", developerData); parameters.AddOptionalParameter("sparkline", sparkline); - return await SendRequestAsync(GetUrl("api/v3/coins/" + assetId), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/coins/" + assetId, CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -121,7 +140,7 @@ public async Task> GetAssetDetailsAsync( /// public async Task> GetTickersAsync( - string coinId, + string assetId, IEnumerable? exchangeIds = null, bool? includeExchangeLogo = null, int? page = null, @@ -129,32 +148,34 @@ public async Task> GetTickersAsync( bool? depth = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("exchange_ids", exchangeIds == null ? null : string.Join(",", exchangeIds)); parameters.AddOptionalParameter("include_exchange_logo", includeExchangeLogo); parameters.AddOptionalParameter("page", page); parameters.AddOptionalParameter("order", order); parameters.AddOptionalParameter("depth", depth); - return await SendRequestAsync(GetUrl("api/v3/coins/" + coinId + "/tickers"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/coins/" + assetId + "/tickers", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion - #region Get Tickers + #region Get Asset History /// public async Task> GetAssetHistoryAsync( - string coinId, + string assetId, DateTime date, bool? localization = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("date", date.ToString("dd-MM-yyyy")); parameters.AddOptionalParameter("localization", localization); - return await SendRequestAsync(GetUrl("api/v3/coins/" + coinId + "/history"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/coins/" + assetId + "/history", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -163,18 +184,21 @@ public async Task> GetAssetHistoryAsync( /// public async Task> GetMarketChartAsync( - string coinId, + string assetId, string quoteAsset, int days, string? interval = null, + string? precision = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("vs_currency", quoteAsset); parameters.AddParameter("days", days); parameters.AddOptionalParameter("interval", interval); + parameters.AddOptionalParameter("precision", precision); - return await SendRequestAsync(GetUrl("api/v3/coins/" + coinId + "/market_chart"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "api/v3/coins/" + assetId + "/market_chart", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -183,18 +207,21 @@ public async Task> GetMarketChartAsync( /// public async Task> GetMarketChartAsync( - string coinId, + string assetId, string quoteAsset, DateTime from, DateTime to, + string? precision = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("vs_currency", quoteAsset); parameters.AddParameter("from", DateTimeConverter.ConvertToSeconds(from)); parameters.AddParameter("to", DateTimeConverter.ConvertToSeconds(to)); + parameters.AddOptionalParameter("precision", precision); - return await SendRequestAsync(GetUrl("api/v3/coins/" + coinId + "/market_chart/range"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "api/v3/coins/" + assetId + "/market_chart/range", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -203,16 +230,19 @@ public async Task> GetMarketChartAsync( /// public async Task>> GetOhlcAsync( - string coinId, + string assetId, string quoteAsset, int days, + string? precision = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("vs_currency", quoteAsset); parameters.AddParameter("days", days); + parameters.AddOptionalParameter("precision", precision); - return await SendRequestAsync>(GetUrl("api/v3/coins/" + coinId + "/ohlc"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "api/v3/coins/" + assetId + "/ohlc", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -230,7 +260,7 @@ public async Task>> GetOhlcAsync( string? precision = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("ids", string.Join(",", ids)); parameters.AddParameter("vs_currencies", string.Join(",", quoteAssets)); parameters.AddOptionalParameter("include_market_cap", includeMarketCap); @@ -238,7 +268,8 @@ public async Task>> GetOhlcAsync( parameters.AddOptionalParameter("include_24hr_change", include24hrChange); parameters.AddOptionalParameter("include_last_updated_at", includeLastUpdatedAt); parameters.AddOptionalParameter("precision", precision); - return await SendRequestAsync>>(GetUrl("api/v3/simple/price"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/simple/price", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -256,7 +287,7 @@ public async Task>> GetOhlcAsync( string? precision = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("contract_addresses", string.Join(",", contractAddresses)); parameters.AddParameter("vs_currencies", string.Join(",", quoteAssets)); parameters.AddOptionalParameter("include_market_cap", includeMarketCap); @@ -264,7 +295,8 @@ public async Task>> GetOhlcAsync( parameters.AddOptionalParameter("include_24hr_change", include24hrChange); parameters.AddOptionalParameter("include_last_updated_at", includeLastUpdatedAt); parameters.AddOptionalParameter("precision", precision); - return await SendRequestAsync>>(GetUrl("api/v3/simple/token_price/" + platformId), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/simple/token_price/" + platformId, CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -274,8 +306,8 @@ public async Task>> GetOhlcAsync( /// public async Task>> GetQuoteAssetsAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync>(GetUrl("api/v3/simple/supported_vs_currencies"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/api/v3/simple/supported_vs_currencies", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion @@ -283,10 +315,10 @@ public async Task>> GetQuoteAssetsAsync(Cancel #region Get Asset Info From Contract /// - public async Task> GetAssetDetailsFromContractAsync(string id, string contractAddress, CancellationToken ct = default) + public async Task> GetAssetDetailsFromContractAsync(string assetId, string contractAddress, CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync(GetUrl($"api/v3/coins/{id}/contract/{contractAddress}"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/coins/{assetId}/contract/{contractAddress}", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion @@ -295,17 +327,18 @@ public async Task> GetAssetDetailsFromContr /// public async Task> GetMarketChartFromContractAsync( - string coinId, + string assetId, string contractAddress, string quoteAsset, int days, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("vs_currency", quoteAsset); parameters.AddParameter("days", days); - return await SendRequestAsync(GetUrl($"api/v3/coins/{coinId}/contract/{contractAddress}/market_chart"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/coins/{assetId}/contract/{contractAddress}/market_chart", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -314,34 +347,36 @@ public async Task> GetMarketChartFromContrac /// public async Task> GetMarketChartFromContractAsync( - string coinId, + string assetId, string contractAddress, string quoteAsset, DateTime from, DateTime to, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("vs_currency", quoteAsset); parameters.AddParameter("from", DateTimeConverter.ConvertToSeconds(from)); parameters.AddParameter("to", DateTimeConverter.ConvertToSeconds(to)); - return await SendRequestAsync(GetUrl($"api/v3/coins/{coinId}/contract/{contractAddress}/market_chart/range"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/coins/{assetId}/contract/{contractAddress}/market_chart/range", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion - #region Get Market Chart From Contract + #region Get Asset Platforms /// public async Task>> GetAssetPlatformsAsync( string? filter = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("filter", filter); - return await SendRequestAsync>(GetUrl($"api/v3/asset_platforms"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/asset_platforms", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -351,8 +386,8 @@ public async Task>> GetAssetPl /// public async Task>> GetAssetCategoriesAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync>(GetUrl($"api/v3/coins/categories/list"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/coins/categories/list", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion @@ -362,9 +397,11 @@ public async Task>> GetAssetCategor /// public async Task>> GetMarketDataCategoriesAsync(string? order = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("order", order); - return await SendRequestAsync>(GetUrl($"api/v3/coins/categories"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/coins/categories", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -374,10 +411,11 @@ public async Task>> GetMa /// public async Task>> GetExchangesAsync(int? page = null, int? pageSize = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("per_page", pageSize); parameters.AddOptionalParameter("page", page); - return await SendRequestAsync>(GetUrl($"api/v3/exchanges"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/exchanges", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -385,10 +423,10 @@ public async Task>> GetExchangesAsy #region Get Exchanges Markets /// - public async Task>> GetExchangeMarketsAsync(CancellationToken ct = default) + public async Task>> GetExchangeListAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync>(GetUrl($"api/v3/exchanges/list"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/exchanges/list", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion @@ -398,8 +436,8 @@ public async Task>> GetExchangeMark /// public async Task> GetExchangeDetailsAsync(string exchangeId, CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync(GetUrl($"api/v3/exchanges/{exchangeId}"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/exchanges/{exchangeId}", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync (GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion @@ -408,13 +446,15 @@ public async Task> GetExchangeDetailsAsy /// public async Task> GetExchangeTickersAsync(string exchangeId, IEnumerable? coinIds = null, bool? includeExchangeLogo = null, int? page = null, bool? depth = null, string? order = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("coin_ids", coinIds == null ? null : string.Join(",", coinIds)); parameters.AddOptionalParameter("include_exchange_logo", includeExchangeLogo); parameters.AddOptionalParameter("page", page); parameters.AddOptionalParameter("depth", depth); parameters.AddOptionalParameter("order", order); - return await SendRequestAsync(GetUrl($"api/v3/exchanges/{exchangeId}/tickers"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/exchanges/{exchangeId}/tickers", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -423,20 +463,33 @@ public async Task> GetExchangeTickersAsync(strin /// public async Task>> GetExchangeVolumeHistoryAsync(string exchangeId, int days, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("days", days); - return await SendRequestAsync>(GetUrl($"api/v3/exchanges/{exchangeId}/volume_chart"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/exchanges/{exchangeId}/volume_chart", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion #region Get Derivatives /// - public async Task>> GetDerivativesAsync(string? includeTickers = null, CancellationToken ct = default) + public async Task>> GetDerivativesAsync(CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/derivatives", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Exchange Derivatives Details + /// + public async Task> GetExchangeDerivativesDetailsAsync(string exchangeId, string? includeTickers = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("include_tickers", includeTickers); - return await SendRequestAsync>(GetUrl($"api/v3/derivatives"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/derivatives/exchanges/{exchangeId}", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -445,31 +498,35 @@ public async Task>> GetDerivative /// public async Task>> GetExchangeDerivativesAsync(int? page = null, int? pageSize = null, string? order = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("page", page); parameters.AddOptionalParameter("pageSize", pageSize); parameters.AddOptionalParameter("order", order); - return await SendRequestAsync>(GetUrl($"api/v3/derivatives/exchanges"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/derivatives/exchanges", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion + #region Get Derivatives Exchanges list /// public async Task>> GetDerivativesExchangesListAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync>(GetUrl($"api/v3/derivatives/exchanges/list"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/derivatives/exchanges/list", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion - #region Get Derivatives Exchanges list + #region Get Exchange Rates /// public async Task> GetBtcExchangeRatesAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync(GetUrl($"api/v3/exchange_rates"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/exchange_rates", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -478,8 +535,9 @@ public async Task> GetBtcExchangeRatesAsyn /// public async Task> GetGlobalDataAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - var data = await SendRequestAsync(GetUrl($"api/v3/global"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/global", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + var data = await SendAsync(GetBaseAddress(), request, null, ct).ConfigureAwait(false); + var parameters = new ParameterCollection(); if (!data) return data.As(null); @@ -488,12 +546,13 @@ public async Task> GetGlobalDataAsync(Cancell #endregion - #region Get Global Data + #region Get Global Defi Data /// public async Task> GetGlobalDefiDataAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - var data = await SendRequestAsync(GetUrl($"api/v3/global/decentralized_finance_defi"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/global/decentralized_finance_defi", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + var data = await SendAsync(GetBaseAddress(), request, null, ct).ConfigureAwait(false); + var parameters = new ParameterCollection(); if (!data) return data.As(null); @@ -504,14 +563,15 @@ public async Task> GetGlobalDefiDataAsync #region Get Nfts /// - public async Task>> GetNftsAsync(string? order = null, string? assetPlatformId = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + public async Task>> GetNftsAsync(string? order = null, int? page = null, int? pageSize = null, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddOptionalParameter("order", order); - parameters.AddOptionalParameter("asset_platform_id", assetPlatformId); parameters.AddOptionalParameter("page", page); parameters.AddOptionalParameter("per_page", pageSize); - return await SendRequestAsync>(GetUrl($"api/v3/nfts/list"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/nfts/list", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync>(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -520,8 +580,8 @@ public async Task>> GetNftsAsync(string? /// public async Task> GetNftAsync(string id, CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync(GetUrl($"api/v3/nfts/{id}"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/nfts/{id}", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion @@ -530,8 +590,8 @@ public async Task> GetNftAsync(string id, Can /// public async Task> GetNftByContractAddressAsync(string platformId, string contractAddress, CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync(GetUrl($"api/v3/nfts/{platformId}/contract/{contractAddress}"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/nfts/{platformId}/contract/{contractAddress}", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion @@ -540,9 +600,10 @@ public async Task> GetNftByContractAddressAsy /// public async Task> SearchAsync(string query, CancellationToken ct = default) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.AddParameter("query", query); - return await SendRequestAsync(GetUrl($"api/v3/search"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/search", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, parameters, ct).ConfigureAwait(false); } #endregion @@ -551,42 +612,62 @@ public async Task> SearchAsync(string query /// public async Task> GetTrendingSearchesAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync(GetUrl($"api/v3/search/trending"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/search/trending", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + return await SendAsync(GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion - #region Get Indexes + #region Get Company Holdings + /// - public async Task>> GetIndexesAsync(int? page = null, int? pageSize = null, CancellationToken ct = default) + public async Task> GetCompanyHoldingsAsync(string asset, CancellationToken ct = default) { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("page", page); - parameters.AddOptionalParameter("per_page", pageSize); - return await SendRequestAsync>(GetUrl($"api/v3/indexes"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"/api/v3/companies/public_treasury/{asset}", CoinGeckoApi.RateLimiter.CoinGecko, 1, false); + var result = await SendAsync(GetBaseAddress(), request, null, ct).ConfigureAwait(false); + return result; } #endregion - #region Get Indexes list + #region Get Api Usage /// - public async Task>> GetIndexesListAsync(CancellationToken ct = default) + public async Task> GetApiUsageAsync(CancellationToken ct = default) { - var parameters = new Dictionary(); - return await SendRequestAsync>(GetUrl($"api/v3/indexes/list"), HttpMethod.Get, ct, parameters, requestWeight: 0).ConfigureAwait(false); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v3/key", CoinGeckoApi.RateLimiter.CoinGecko, 1, true); + return await SendAsync(GetBaseAddress(), request, null, ct).ConfigureAwait(false); } #endregion - /// - /// Get url for an endpoint - /// - /// - /// - internal Uri GetUrl(string endpoint) + protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable>> responseHeaders, IMessageAccessor accessor) { - return new Uri(BaseAddress.AppendPath(endpoint)); + if (!accessor.IsJson) + return new ServerError(accessor.GetOriginalString()); + + var code = accessor.GetValue(MessagePath.Get().Property("error_code")); + var msg = accessor.GetValue(MessagePath.Get().Property("status").Property("error_message")); + + if (code != null && msg != null) + return new ServerError(code.Value, msg); + + code = accessor.GetValue(MessagePath.Get().Property("status").Property("error_code")); + if (code != null && msg != null) + return new ServerError(code.Value, msg); + + return new ServerError(httpStatusCode, accessor.GetOriginalString()); + } + + private string GetBaseAddress() + { + if (AuthenticationProvider != null) + { + if (((CoinGeckoAuthenticationProvider)AuthenticationProvider).IsDemo) + return _options.Environment.RestApiAddressPublic; + + return _options.Environment.RestApiAddressPro; + } + return _options.Environment.RestApiAddressPublic; } /// @@ -594,6 +675,6 @@ internal Uri GetUrl(string endpoint) /// public override TimeSyncInfo? GetTimeSyncInfo() => null; /// - protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) => null!; + protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) => new CoinGeckoAuthenticationProvider((CoinGeckoApiCredentials)credentials); } } diff --git a/CoinGecko.Net/CoinGecko.Net.xml b/CoinGecko.Net/CoinGecko.Net.xml index 9483efe..af23cde 100644 --- a/CoinGecko.Net/CoinGecko.Net.xml +++ b/CoinGecko.Net/CoinGecko.Net.xml @@ -33,6 +33,12 @@ + + + + + + @@ -42,7 +48,7 @@ - + @@ -54,13 +60,13 @@ - + - + - + @@ -93,7 +99,7 @@ - + @@ -105,7 +111,10 @@ - + + + + @@ -123,7 +132,7 @@ - + @@ -138,19 +147,12 @@ - + - + - - - Get url for an endpoint - - - - @@ -160,14 +162,54 @@ + + + CoinGecko information and configuration + + + + + Url to the main website + + + + + Urls to the API documentation + + + + + Rate limiter configuration for the CoinGecko API + + + + + Rate limiter configuration for the CoinGecko API + + + + + Event for when a rate limit is triggered + + + + + Whether or not a demo key is configured + + CoinGecko Environments - + + + Rest client address public API + + + - Rest client address + Rest client address pro API @@ -175,12 +217,10 @@ Live environment - + Create a custom environment - - @@ -201,7 +241,7 @@ Get asset categories - + Cancellation token @@ -209,7 +249,7 @@ Get asset details - + The asset id Include localization @@ -224,9 +264,9 @@ Get asset details by contract address - + - Id of the platform + Id of the asset Contract address Cancellation token @@ -234,7 +274,7 @@ Get asset platforms list - + Filter Cancellation token @@ -243,7 +283,7 @@ Get list of all assets - + Include platform contract address Cancellation token @@ -252,24 +292,23 @@ Get BTC-to-Currency exchange rates - + Cancellation token - + Get list of derivative tickers - + - Include tickers for `all` or only `unexpired` Cancellation token List all derivatives exchanges name and identifier - + Cancellation token @@ -277,7 +316,7 @@ Get all derivatives exchanges - + Page Page size @@ -285,19 +324,29 @@ Cancellation token + + + Get exchange derivative details + + + Exchange id + Include tickers, 'all' or 'unexpired' + Cancellation token + + Get exchange details - + Id of the exchange Cancellation token - + - Get all exchange markets - + Get all exchanges + Cancellation token @@ -305,7 +354,7 @@ Get all exchanges - + Page Page size @@ -315,7 +364,7 @@ Get exchange tickers - + Exchange id Asset ids filter @@ -328,8 +377,8 @@ - Get volume chart data for an exchange - + Get volume chart data for an exchange, interval is determined automatically: 1 day -> 10 minutes, 7-14 days -> 1 hour, 30+ days -> 1 day + Exchange id Days history @@ -339,7 +388,7 @@ Get asset history info - + Asset id Date snapshot time @@ -347,34 +396,36 @@ Cancellation token - + Get historical market data - + Asset id Quote asset From date To date + Decimal place for currency price value Cancellation token - + Get historical market data - + Asset id Quote asset Days back Data interval + Decimal place for currency price value Cancellation token Get historical market data by contract - + Asset id Contract address @@ -387,7 +438,7 @@ Get historical market data by contract - + Asset id Contract address @@ -399,16 +450,16 @@ Get market data categories - + Sorting Cancellation token - + Get coins market data - + Quote asset Asset ids @@ -418,24 +469,27 @@ PageSize Include sparkline Include price change percentages + Language, defaults to `en` + Decimal place for currency price value Cancellation token - + - Get Open/High/Low/Close data - + Get Open/High/Low/Close data, interval is determined automatically: 1-2 days -> 30 minutes, 3-30 days -> 4 hours, 31+ days -> 4 days + Asset id Quote asset Days back + Decimal place for currency price value Cancellation token Get prices for specific assets - + Asset ids to get data for Quote assets @@ -450,7 +504,7 @@ Get list of quote assets - + Cancellation token @@ -458,7 +512,7 @@ Get tickers for an asset - + Asset id Exchange ids @@ -472,7 +526,7 @@ Get prices by token contract addresses - + Platform id Contract addresses @@ -488,7 +542,7 @@ Ping the server - + Cancellation token @@ -496,7 +550,7 @@ Get global crypto data - + Cancellation token @@ -504,18 +558,17 @@ Get global defi crypto data - + Cancellation token - + Get list of nfts - + Sort - Platform id Page Page size Cancellation token @@ -524,7 +577,7 @@ Get details on an NFT - + Id Cancellation token @@ -533,7 +586,7 @@ Get nft info by contract address - + Platform id Contract address @@ -543,7 +596,7 @@ Search for assets, exchanges, categories or nfts - + Search query Cancellation token @@ -552,23 +605,23 @@ Get trending searches - + Cancellation token - + - Get indexes + Get public company holdings for an asset + - Page - Page size + Asset name Cancellation token - - + - Get indexes list + Get current API usage stats + Cancellation token @@ -578,9 +631,14 @@ Api addresses usable for the CoinGecko client - + + + The address used by the CoinGeckoRestClient for the public API + + + - The address used by the BybitClient for the Spot rest API + The address used by the CoinGeckoRestClient for the pro API @@ -588,6 +646,59 @@ The default addresses to connect to the Bybit.com API + + + CoinGecko API credentials + + + + + Wheter using a demo key + + + + + ctor + + The API key + Whether or not this is a demo key + + + + Copy + + + + + + API usage info + + + + + Plan + + + + + Rate limit request per minute + + + + + Monthly call credit + + + + + Current total monthly calls + + + + + Current remaining monthly calls + + Asset info @@ -608,6 +719,11 @@ Name of the asset + + + Asset platform and contract address + + Asset details @@ -628,6 +744,11 @@ Name of the asset + + + Asset web slug + + Main platform @@ -658,6 +779,11 @@ Categories + + + Preview listing + + Public notice @@ -698,11 +824,6 @@ Genesis block date - - - Contract address - - Sentiment up votes percentage @@ -713,79 +834,64 @@ Sentiment down votes percentage - - - Ico data - - Market cap rank - - - Coin gecko rank - - - - - Coin gecko score - - - + - Developer score + Market data - + - Community score + Status updates - + - Liquidity score + Community data - + - Public interest score + Developer data - + - Market data + Last updated - + - Public interest statistics + Tickers - + - Status updates + Asset exchange info - + - Community data + Exchange name - + - Developer data + Identifier - + - Last updated + Has trading incentive - + - Tickers + Logo @@ -838,24 +944,24 @@ Public interest stats - + - Asset market info + Basic market data - + - Name + Current price - + - Identifier + Market caps - + - Has trading incentive + Total volumes @@ -883,6 +989,16 @@ Short name + + + Chain native coin id + + + + + Platform image + + Category @@ -953,6 +1069,71 @@ Telegram channel user count + + + Company holdings + + + + + Total holdings + + + + + Total value in USD + + + + + Market cap dominance + + + + + Companies + + + + + Company holding + + + + + Name + + + + + Symbol + + + + + Country + + + + + Total holdings + + + + + Total entry value USD + + + + + Total current value USD + + + + + Percentage of total supply + + Derivative info @@ -1028,6 +1209,96 @@ Expired at + + + Derivatives ticker + + + + + Symbol + + + + + Base asset + + + + + Target asset + + + + + Trade url + + + + + Contract type + + + + + Last price + + + + + 24 hour percentage change + + + + + Index price + + + + + Index basis percentage + + + + + Bid ask spread + + + + + Funding rate + + + + + Open interest usd + + + + + 24 hour volume + + + + + Converted volume + + + + + Converted last + + + + + Last trade time + + + + + Expired time + + Developer data @@ -1208,6 +1479,11 @@ Url + + + Tickers + + Exchange details @@ -1323,11 +1599,6 @@ Tickers - - - Status updates - - Exchange rates @@ -1388,9 +1659,9 @@ Ended icos - + - Markets + Exchanges @@ -1458,164 +1729,19 @@ Top defi asset dominance - + - Ico information + Image links - + - Ico start date + Thumbnail - + - Ico end date - - - - - Short description - - - - - Description - - - - - Soft cap currency - - - - - Hard cap currency - - - - - Total raised currency - - - - - Softcap - - - - - Hardcap amount - - - - - Total raised - - - - - Quote pre-sale currency - - - - - Base pre sale amount - - - - - Quote pre sale amount - - - - - Quote public sale currency - - - - - Base public sale amount - - - - - Quote public sale amount - - - - - Accepting currencies - - - - - Country origin - - - - - Pre sale start date - - - - - Pre sale end date - - - - - Whitelist url - - - - - Whitelist start date - - - - - Whitelist end date - - - - - Bounty detail url - - - - - Amount for sale - - - - - KYC required - - - - - Whitelist available - - - - - Pre sale ended - - - - - Image links - - - - - Thumbnail - - - - - Small image + Small image @@ -1623,36 +1749,6 @@ Large image - - - Index info - - - - - Id - - - - - Name - - - - - Market - - - - - Last - - - - - Is multi asset composite index - - Links @@ -1663,6 +1759,11 @@ Homepage + + + White paper link + + Blockchain explorer links @@ -1865,7 +1966,7 @@ - Market raturn on investment info + Market return on investment info @@ -1993,6 +2094,11 @@ Fully diluted valuation + + + Market cap to fully diluted valuation ratio + + Total volumes @@ -2233,11 +2339,21 @@ Name + + + Symbol + + Images + + + Banner image + + Description @@ -2248,6 +2364,11 @@ Native currency + + + Native currency symbol + + Floor price 24h change percentage in USD @@ -2263,6 +2384,11 @@ Number of unique address 24h change percentage + + + Volume 24h change percentage in USD + + Total supply @@ -2283,6 +2409,96 @@ Floor price + + + Floor price 24h percentage change + + + + + Market cap 24h percentage change + + + + + Volume 24h percentage change + + + + + One day sales + + + + + One day sales percentage change + + + + + One day average sales price + + + + + One day sales percentage change + + + + + Floor price 7 day percentage change + + + + + Floor price 14 day percentage change + + + + + Floor price 30 day percentage change + + + + + Floor price 60 day percentage change + + + + + Floor price 1 year percentage change + + + + + Nft collection user favorites count + + + + + All time high price + + + + + All time high price change percentage + + + + + All time high price date + + + + + Explorer links + + + + + Explorer links + + Nft value info @@ -2298,6 +2514,36 @@ In usd + + + Nft value info + + + + + In native currency + + + + + In usd + + + + + Nft value info + + + + + Link name + + + + + Link + + Open High Low Close data @@ -2383,6 +2629,11 @@ Nfts found + + + Icos + + Asset result @@ -2573,9 +2824,9 @@ Quote asset - + - Market info + Exchange info @@ -2660,7 +2911,7 @@ - Coin name + Asset name @@ -2678,6 +2929,16 @@ Trending assets + + + Trending NFTs + + + + + Trending Categories + + Trending asset @@ -2738,6 +2999,156 @@ Score + + + Nft + + + + + Id + + + + + Name + + + + + Symbol + + + + + Thumb image + + + + + Nft contract id + + + + + Native asset symbol + + + + + Floor price in native asset + + + + + Floor price 24h percentage change + + + + + Data + + + + + Nft data + + + + + Floor price + + + + + Floor price in usd 24h percentage change + + + + + Volume 24h + + + + + Average sale price 24h + + + + + Sparkline + + + + + Trending category + + + + + Id + + + + + Name + + + + + Market cap 1 hour change + + + + + Slug + + + + + Coins count + + + + + Data + + + + + Category date + + + + + Market cap + + + + + Market cap btc + + + + + Total volume + + + + + Total volume btc + + + + + Market cap change percentage24h + + + + + Sparkline + + Item diff --git a/CoinGecko.Net/CoinGeckoApi.cs b/CoinGecko.Net/CoinGeckoApi.cs new file mode 100644 index 0000000..5ac30ca --- /dev/null +++ b/CoinGecko.Net/CoinGeckoApi.cs @@ -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 +{ + /// + /// CoinGecko information and configuration + /// + public static class CoinGeckoApi + { + /// + /// Url to the main website + /// + public static string Url { get; } = "https://www.coingecko.com"; + + /// + /// Urls to the API documentation + /// + public static string[] ApiDocsUrl { get; } = new[] { + "https://docs.coingecko.com/" + }; + + /// + /// Rate limiter configuration for the CoinGecko API + /// + public static CoinGeckoRateLimiters RateLimiter { get; } = new CoinGeckoRateLimiters(); + } + + /// + /// Rate limiter configuration for the CoinGecko API + /// + public class CoinGeckoRateLimiters + { + /// + /// Event for when a rate limit is triggered + /// + public event Action 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; } + } +} diff --git a/CoinGecko.Net/CoinGeckoAuthenticationProvider.cs b/CoinGecko.Net/CoinGeckoAuthenticationProvider.cs new file mode 100644 index 0000000..9c33226 --- /dev/null +++ b/CoinGecko.Net/CoinGeckoAuthenticationProvider.cs @@ -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 + { + /// + /// Whether or not a demo key is configured + /// + public bool IsDemo => _credentials.DemoKey; + + public CoinGeckoAuthenticationProvider(CoinGeckoApiCredentials credentials) : base(credentials) + { + } + + public override void AuthenticateRequest( + RestApiClient apiClient, + Uri uri, + HttpMethod method, + ref IDictionary? uriParameters, + ref IDictionary? bodyParameters, + ref Dictionary? 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); + } + } +} diff --git a/CoinGecko.Net/CoinGeckoEnvironment.cs b/CoinGecko.Net/CoinGeckoEnvironment.cs index 61d86f0..e2e3517 100644 --- a/CoinGecko.Net/CoinGeckoEnvironment.cs +++ b/CoinGecko.Net/CoinGeckoEnvironment.cs @@ -9,14 +9,20 @@ namespace CoinGecko.Net public class CoinGeckoEnvironment : TradeEnvironment { /// - /// Rest client address + /// Rest client address public API /// - public string RestApiAddress { get; } + public string RestApiAddressPublic { get; } + /// + /// Rest client address pro API + /// + public string RestApiAddressPro { get; } internal CoinGeckoEnvironment(string name, - string restBaseAddress) : base(name) + string restBaseAddressPublic, + string restBaseAddressPro) : base(name) { - RestApiAddress = restBaseAddress; + RestApiAddressPublic = restBaseAddressPublic; + RestApiAddressPro = restBaseAddressPro; } /// @@ -24,17 +30,17 @@ internal CoinGeckoEnvironment(string name, /// public static CoinGeckoEnvironment Live { get; } = new CoinGeckoEnvironment(TradeEnvironmentNames.Live, - CoinGeckoApiAddresses.Default.RestClientAddress); + CoinGeckoApiAddresses.Default.RestClientAddressPublic, + CoinGeckoApiAddresses.Default.RestClientAddressPro); /// /// Create a custom environment /// - /// - /// /// public static CoinGeckoEnvironment CreateCustom( string name, - string restAddress) - => new CoinGeckoEnvironment(name, restAddress); + string restAddressPublic, + string restAddressPro) + => new CoinGeckoEnvironment(name, restAddressPublic, restAddressPro); } } diff --git a/CoinGecko.Net/ExtensionMethods/ServiceCollectionExtensions.cs b/CoinGecko.Net/ExtensionMethods/ServiceCollectionExtensions.cs index eceaa59..2bfffe8 100644 --- a/CoinGecko.Net/ExtensionMethods/ServiceCollectionExtensions.cs +++ b/CoinGecko.Net/ExtensionMethods/ServiceCollectionExtensions.cs @@ -3,7 +3,6 @@ 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; diff --git a/CoinGecko.Net/Interfaces/ICoinGeckoRestClientApi.cs b/CoinGecko.Net/Interfaces/ICoinGeckoRestClientApi.cs index ede2ae8..3b0a124 100644 --- a/CoinGecko.Net/Interfaces/ICoinGeckoRestClientApi.cs +++ b/CoinGecko.Net/Interfaces/ICoinGeckoRestClientApi.cs @@ -15,14 +15,14 @@ public interface ICoinGeckoRestClientApi: IRestApiClient { /// /// Get asset categories - /// + /// /// /// Cancellation token /// Task>> GetAssetCategoriesAsync(CancellationToken ct = default); /// /// Get asset details - /// + /// /// /// The asset id /// Include localization @@ -36,16 +36,16 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task> GetAssetDetailsAsync(string assetId, bool? localization = null, bool? tickers = null, bool? marketData = null, bool? communityData = null, bool? developerData = null, bool? sparkline = null, CancellationToken ct = default); /// /// Get asset details by contract address - /// + /// /// - /// Id of the platform + /// Id of the asset /// Contract address /// Cancellation token /// - Task> GetAssetDetailsFromContractAsync(string platformId, string contractAddress, CancellationToken ct = default); + Task> GetAssetDetailsFromContractAsync(string assetId, string contractAddress, CancellationToken ct = default); /// /// Get asset platforms list - /// + /// /// /// Filter /// Cancellation token @@ -53,7 +53,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task>> GetAssetPlatformsAsync(string? filter = null, CancellationToken ct = default); /// /// Get list of all assets - /// + /// /// /// Include platform contract address /// Cancellation token @@ -61,29 +61,28 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task>> GetAssetsAsync(bool? includePlatform = null, CancellationToken ct = default); /// /// Get BTC-to-Currency exchange rates - /// + /// /// /// Cancellation token /// Task> GetBtcExchangeRatesAsync(CancellationToken ct = default); /// /// Get list of derivative tickers - /// + /// /// - /// Include tickers for `all` or only `unexpired` /// Cancellation token /// - Task>> GetDerivativesAsync(string? includeTickers = null, CancellationToken ct = default); + Task>> GetDerivativesAsync(CancellationToken ct = default); /// /// List all derivatives exchanges name and identifier - /// + /// /// /// Cancellation token /// Task>> GetDerivativesExchangesListAsync(CancellationToken ct = default); /// /// Get all derivatives exchanges - /// + /// /// /// Page /// Page size @@ -91,24 +90,35 @@ public interface ICoinGeckoRestClientApi: IRestApiClient /// Cancellation token /// Task>> GetExchangeDerivativesAsync(int? page = null, int? pageSize = null, string? order = null, CancellationToken ct = default); + + /// + /// Get exchange derivative details + /// + /// + /// Exchange id + /// Include tickers, 'all' or 'unexpired' + /// Cancellation token + /// + Task> GetExchangeDerivativesDetailsAsync(string exchangeId, string? includeTickers = null, CancellationToken ct = default); + /// /// Get exchange details - /// + /// /// /// Id of the exchange /// Cancellation token /// Task> GetExchangeDetailsAsync(string exchangeId, CancellationToken ct = default); /// - /// Get all exchange markets - /// + /// Get all exchanges + /// /// /// Cancellation token /// - Task>> GetExchangeMarketsAsync(CancellationToken ct = default); + Task>> GetExchangeListAsync(CancellationToken ct = default); /// /// Get all exchanges - /// + /// /// /// Page /// Page size @@ -117,7 +127,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task>> GetExchangesAsync(int? page = null, int? pageSize = null, CancellationToken ct = default); /// /// Get exchange tickers - /// + /// /// /// Exchange id /// Asset ids filter @@ -129,8 +139,8 @@ public interface ICoinGeckoRestClientApi: IRestApiClient /// Task> GetExchangeTickersAsync(string exchangeId, IEnumerable? assetIds = null, bool? includeExchangeLogo = null, int? page = null, bool? depth = null, string? order = null, CancellationToken ct = default); /// - /// Get volume chart data for an exchange - /// + /// Get volume chart data for an exchange, interval is determined automatically: 1 day -> 10 minutes, 7-14 days -> 1 hour, 30+ days -> 1 day + /// /// /// Exchange id /// Days history @@ -139,7 +149,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task>> GetExchangeVolumeHistoryAsync(string exchangeId, int days, CancellationToken ct = default); /// /// Get asset history info - /// + /// /// /// Asset id /// Date snapshot time @@ -149,29 +159,31 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task> GetAssetHistoryAsync(string assetId, DateTime date, bool? localization = null, CancellationToken ct = default); /// /// Get historical market data - /// + /// /// /// Asset id /// Quote asset /// From date /// To date + /// Decimal place for currency price value /// Cancellation token /// - Task> GetMarketChartAsync(string assetId, string quoteAsset, DateTime from, DateTime to, CancellationToken ct = default); + Task> GetMarketChartAsync(string assetId, string quoteAsset, DateTime from, DateTime to, string? precision = null, CancellationToken ct = default); /// /// Get historical market data - /// + /// /// /// Asset id /// Quote asset /// Days back /// Data interval + /// Decimal place for currency price value /// Cancellation token /// - Task> GetMarketChartAsync(string assetId, string quoteAsset, int days, string? interval = null, CancellationToken ct = default); + Task> GetMarketChartAsync(string assetId, string quoteAsset, int days, string? interval = null, string? precision = null, CancellationToken ct = default); /// /// Get historical market data by contract - /// + /// /// /// Asset id /// Contract address @@ -183,7 +195,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task> GetMarketChartFromContractAsync(string assetId, string contractAddress, string quoteAsset, DateTime from, DateTime to, CancellationToken ct = default); /// /// Get historical market data by contract - /// + /// /// /// Asset id /// Contract address @@ -194,7 +206,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task> GetMarketChartFromContractAsync(string assetId, string contractAddress, string quoteAsset, int days, CancellationToken ct = default); /// /// Get market data categories - /// + /// /// /// Sorting /// Cancellation token @@ -202,7 +214,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task>> GetMarketDataCategoriesAsync(string? order = null, CancellationToken ct = default); /// /// Get coins market data - /// + /// /// /// Quote asset /// Asset ids @@ -212,22 +224,38 @@ public interface ICoinGeckoRestClientApi: IRestApiClient /// PageSize /// Include sparkline /// Include price change percentages - /// Cancellation token - /// - Task>> GetMarketsAsync(string quoteAsset, IEnumerable? assetIds = null, string? category = null, string? order = null, int? page = null, int? pageSize = null, bool? sparkline = null, IEnumerable? priceChangePercentages = null, CancellationToken ct = default); + /// Language, defaults to `en` + /// Decimal place for currency price value + /// Cancellation token + /// + Task>> GetMarketsAsync( + string quoteAsset, + IEnumerable? assetIds = null, + string? category = null, + string? order = null, + int? page = null, + int? pageSize = null, + bool? sparkline = null, + IEnumerable? priceChangePercentages = null, + string? locale = null, + string? precision = null, + CancellationToken ct = default); + /// - /// Get Open/High/Low/Close data - /// + /// Get Open/High/Low/Close data, interval is determined automatically: 1-2 days -> 30 minutes, 3-30 days -> 4 hours, 31+ days -> 4 days + /// /// /// Asset id /// Quote asset /// Days back + /// Decimal place for currency price value /// Cancellation token /// - Task>> GetOhlcAsync(string assetId, string quoteAsset, int days, CancellationToken ct = default); + Task>> GetOhlcAsync(string assetId, string quoteAsset, int days, string? precision = null, CancellationToken ct = default); + /// /// Get prices for specific assets - /// + /// /// /// Asset ids to get data for /// Quote assets @@ -241,14 +269,14 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task>>> GetPricesAsync(IEnumerable ids, IEnumerable quoteAssets, bool? includeMarketCap = false, bool? include24hrVolume = false, bool? include24hrChange = false, bool? includeLastUpdatedAt = false, string? precision = null, CancellationToken ct = default); /// /// Get list of quote assets - /// + /// /// /// Cancellation token /// Task>> GetQuoteAssetsAsync(CancellationToken ct = default); /// /// Get tickers for an asset - /// + /// /// /// Asset id /// Exchange ids @@ -261,7 +289,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task> GetTickersAsync(string assetId, IEnumerable? exchangeIds = null, bool? includeExchangeLogo = null, int? page = null, string? order = null, bool? depth = null, CancellationToken ct = default); /// /// Get prices by token contract addresses - /// + /// /// /// Platform id /// Contract addresses @@ -276,21 +304,21 @@ public interface ICoinGeckoRestClientApi: IRestApiClient Task>>> GetTokenPricesAsync(string platformId, IEnumerable contractAddresses, IEnumerable quoteAssets, bool? includeMarketCap = false, bool? include24hrVolume = false, bool? include24hrChange = false, bool? includeLastUpdatedAt = false, string? precision = null, CancellationToken ct = default); /// /// Ping the server - /// + /// /// /// Cancellation token /// Task> PingAsync(CancellationToken ct = default); /// /// Get global crypto data - /// + /// /// /// Cancellation token /// Task> GetGlobalDataAsync(CancellationToken ct = default); /// /// Get global defi crypto data - /// + /// /// /// Cancellation token /// @@ -298,19 +326,18 @@ public interface ICoinGeckoRestClientApi: IRestApiClient /// /// Get list of nfts - /// + /// /// /// Sort - /// Platform id /// Page /// Page size /// Cancellation token /// - Task>> GetNftsAsync(string? order = null, string? assetPlatformId = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + Task>> GetNftsAsync(string? order = null, int? page = null, int? pageSize = null, CancellationToken ct = default); /// /// Get details on an NFT - /// + /// /// /// Id /// Cancellation token @@ -319,7 +346,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient /// /// Get nft info by contract address - /// + /// /// /// Platform id /// Contract address @@ -329,7 +356,7 @@ public interface ICoinGeckoRestClientApi: IRestApiClient /// /// Search for assets, exchanges, categories or nfts - /// + /// /// /// Search query /// Cancellation token @@ -338,26 +365,26 @@ public interface ICoinGeckoRestClientApi: IRestApiClient /// /// Get trending searches - /// + /// /// /// Cancellation token /// Task> GetTrendingSearchesAsync(CancellationToken ct = default); /// - /// Get indexes + /// Get public company holdings for an asset + /// /// - /// Page - /// Page size + /// Asset name /// Cancellation token - /// - Task>> GetIndexesAsync(int? page = null, int? pageSize = null, CancellationToken ct = default); + Task> GetCompanyHoldingsAsync(string asset, CancellationToken ct = default); /// - /// Get indexes list + /// Get current API usage stats + /// /// /// Cancellation token /// - Task>> GetIndexesListAsync(CancellationToken ct = default); + Task> GetApiUsageAsync(CancellationToken ct = default); } } diff --git a/CoinGecko.Net/Objects/CoinGeckoApiAddresses.cs b/CoinGecko.Net/Objects/CoinGeckoApiAddresses.cs index 7f549b8..9671873 100644 --- a/CoinGecko.Net/Objects/CoinGeckoApiAddresses.cs +++ b/CoinGecko.Net/Objects/CoinGeckoApiAddresses.cs @@ -6,9 +6,13 @@ public class CoinGeckoApiAddresses { /// - /// The address used by the BybitClient for the Spot rest API + /// The address used by the CoinGeckoRestClient for the public API /// - public string RestClientAddress { get; set; } = ""; + public string RestClientAddressPublic { get; set; } = ""; + /// + /// The address used by the CoinGeckoRestClient for the pro API + /// + public string RestClientAddressPro { get; set; } = ""; /// @@ -16,7 +20,8 @@ public class CoinGeckoApiAddresses /// public static CoinGeckoApiAddresses Default = new CoinGeckoApiAddresses { - RestClientAddress = "https://api.coingecko.com/" + RestClientAddressPublic = "https://api.coingecko.com/", + RestClientAddressPro = "https://pro-api.coingecko.com/" }; } } diff --git a/CoinGecko.Net/Objects/CoinGeckoApiCredentials.cs b/CoinGecko.Net/Objects/CoinGeckoApiCredentials.cs new file mode 100644 index 0000000..44f929d --- /dev/null +++ b/CoinGecko.Net/Objects/CoinGeckoApiCredentials.cs @@ -0,0 +1,34 @@ +using CryptoExchange.Net.Authentication; + +namespace CoinGecko.Net.Objects +{ + /// + /// CoinGecko API credentials + /// + public class CoinGeckoApiCredentials : ApiCredentials + { + /// + /// Wheter using a demo key + /// + public bool DemoKey { get; } + + /// + /// ctor + /// + /// The API key + /// Whether or not this is a demo key + public CoinGeckoApiCredentials(string apiKey, bool demoKey = false) : base(apiKey, "-") + { + DemoKey = demoKey; + } + + /// + /// Copy + /// + /// + public override ApiCredentials Copy() + { + return new CoinGeckoApiCredentials(Key, DemoKey); + } + } +} diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoApiUsage.cs b/CoinGecko.Net/Objects/Models/CoinGeckoApiUsage.cs new file mode 100644 index 0000000..a3f55af --- /dev/null +++ b/CoinGecko.Net/Objects/Models/CoinGeckoApiUsage.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace CoinGecko.Net.Objects.Models +{ + /// + /// API usage info + /// + public record CoinGeckoApiUsage + { + /// + /// Plan + /// + [JsonPropertyName("plan")] + public string Plan { get; set; } = string.Empty; + /// + /// Rate limit request per minute + /// + [JsonPropertyName("rate_limit_request_per_minute")] + public long RateLimitRequestPerMinute { get; set; } + /// + /// Monthly call credit + /// + [JsonPropertyName("monthly_call_credit")] + public long MonthlyCallCredit { get; set; } + /// + /// Current total monthly calls + /// + [JsonPropertyName("current_total_monthly_calls")] + public long CurrentTotalMonthlyCalls { get; set; } + /// + /// Current remaining monthly calls + /// + [JsonPropertyName("current_remaining_monthly_calls")] + public long CurrentRemainingMonthlyCalls { get; set; } + } + + +} diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoAsset.cs b/CoinGecko.Net/Objects/Models/CoinGeckoAsset.cs index 31ad52a..7fbb278 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoAsset.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoAsset.cs @@ -1,4 +1,7 @@ -namespace CoinGecko.Net.Objects.Models +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace CoinGecko.Net.Objects.Models { /// /// Asset info @@ -8,14 +11,22 @@ public record CoinGeckoAsset /// /// Id of the asset /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Symbol of the asset /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Name of the asset /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; + /// + /// Asset platform and contract address + /// + [JsonPropertyName("platforms")] + public Dictionary? Platforms { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoAssetDetails.cs b/CoinGecko.Net/Objects/Models/CoinGeckoAssetDetails.cs index 807e768..6e95c2d 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoAssetDetails.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoAssetDetails.cs @@ -1,7 +1,6 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -13,168 +12,143 @@ public record CoinGeckoAssetDetails /// /// Id of the asset /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Symbol of the asset /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Name of the asset /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// + /// Asset web slug + /// + [JsonPropertyName("web_slug")] + public string WebSlug { get; set; } = string.Empty; + /// /// Main platform /// - [JsonProperty("asset_platform_id")] + [JsonPropertyName("asset_platform_id")] public string AssetPlatformId { get; set; } = string.Empty; /// /// Smart contract addresses on different platforms /// + [JsonPropertyName("platforms")] public Dictionary Platforms { get; set; } = new Dictionary(); /// /// Platform details /// - [JsonProperty("detail_platforms")] + [JsonPropertyName("detail_platforms")] public Dictionary PlatformDetails { get; set; } = new Dictionary(); /// /// Block generation time /// - [JsonProperty("block_time_in_minutes")] - public int BlockTimeInMinutes { get; set; } + [JsonPropertyName("block_time_in_minutes")] + public int? BlockTimeInMinutes { get; set; } /// /// Hasing algorithm /// - [JsonProperty("hashing_algorithm")] + [JsonPropertyName("hashing_algorithm")] public string HashingAlgorithm { get; set; } = string.Empty; /// /// Categories /// + [JsonPropertyName("categories")] public IEnumerable Categories { get; set; } = Array.Empty(); /// + /// Preview listing + /// + [JsonPropertyName("preview_listing")] + public bool PreviewListing { get; set; } + /// /// Public notice /// - [JsonProperty("public_notice")] + [JsonPropertyName("public_notice")] public string PublicNotice { get; set; } = string.Empty; /// /// Additional notices /// - [JsonProperty("additional_notices")] + [JsonPropertyName("additional_notices")] public IEnumerable AdditionalNotice { get; set; } = Array.Empty(); /// /// Name in different languages /// + [JsonPropertyName("localization")] public Dictionary Localization { get; set; } = new Dictionary(); /// /// Description in different languages /// + [JsonPropertyName("description")] public Dictionary Description { get; set; } = new Dictionary(); /// /// Links /// + [JsonPropertyName("links")] public CoinGeckoLinks Links { get; set; } = null!; /// /// Images /// + [JsonPropertyName("image")] public CoinGeckoImages Image { get; set; } = null!; /// /// Country of origin /// - [JsonProperty("country_origin")] + [JsonPropertyName("country_origin")] public string CountryOrigin { get; set; } = string.Empty; /// /// Genesis block date /// - [JsonProperty("genesis_date")] + [JsonPropertyName("genesis_date")] [JsonConverter(typeof(DateTimeConverter))] public DateTime? GenesisDate { get; set; } /// - /// Contract address - /// - [JsonProperty("contract_address")] - public string? ContractAddress { get; set; } = string.Empty; - /// /// Sentiment up votes percentage /// - [JsonProperty("sentiment_votes_up_percentage")] + [JsonPropertyName("sentiment_votes_up_percentage")] public decimal? SentimentVotesUpPercentage { get; set; } /// /// Sentiment down votes percentage /// - [JsonProperty("sentiment_votes_down_percentage")] + [JsonPropertyName("sentiment_votes_down_percentage")] public decimal? SentimentVotesDownPercentage { get; set; } /// - /// Ico data - /// - [JsonProperty("ico_data")] - public CoinGeckoIcoData? IcoData { get; set; } - /// /// Market cap rank /// - [JsonProperty("market_cap_rank")] + [JsonPropertyName("market_cap_rank")] public int? MarketCapRank { get; set; } /// - /// Coin gecko rank - /// - [JsonProperty("coingecko_rank")] - public int? CoinGeckoRank { get; set; } - /// - /// Coin gecko score - /// - [JsonProperty("coingecko_score")] - public decimal CoinGeckoScore { get; set; } - /// - /// Developer score - /// - [JsonProperty("developer_score")] - public decimal DeveloperScore { get; set; } - /// - /// Community score - /// - [JsonProperty("community_score")] - public decimal CommunityScore { get; set; } - /// - /// Liquidity score - /// - [JsonProperty("liquidity_score")] - public decimal LiquidityScore { get; set; } - /// - /// Public interest score - /// - [JsonProperty("public_interest_score")] - public decimal PublicInterestScore { get; set; } - /// /// Market data /// - [JsonProperty("market_data")] + [JsonPropertyName("market_data")] public CoinGeckoMarketData? MarketData { get; set; } /// - /// Public interest statistics - /// - [JsonProperty("public_interest_stats")] - public CoinGeckoPublicInterestStats? PublicInterestStats { get; set; } - /// /// Status updates /// - [JsonProperty("status_updates")] + [JsonPropertyName("status_updates")] public IEnumerable StatusUpdates { get; set; } = Array.Empty(); /// /// Community data /// - [JsonProperty("community_data")] + [JsonPropertyName("community_data")] public CoinGeckoCommunityData? CommunityData { get; set; } /// /// Developer data /// - [JsonProperty("developer_data")] + [JsonPropertyName("developer_data")] public CoinGeckoDeveloperData? DeveloperData { get; set; } /// /// Last updated /// - [JsonProperty("last_updated")] + [JsonPropertyName("last_updated")] public DateTime? LastUpdated { get; set; } /// /// Tickers /// + [JsonPropertyName("tickers")] public IEnumerable Tickers { get; set; } = Array.Empty(); } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoAssetMarket.cs b/CoinGecko.Net/Objects/Models/CoinGeckoAssetExchange.cs similarity index 53% rename from CoinGecko.Net/Objects/Models/CoinGeckoAssetMarket.cs rename to CoinGecko.Net/Objects/Models/CoinGeckoAssetExchange.cs index e95066d..21cbf3c 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoAssetMarket.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoAssetExchange.cs @@ -1,24 +1,31 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { /// - /// Asset market info + /// Asset exchange info /// - public record CoinGeckoAssetMarket + public record CoinGeckoAssetExchange { /// - /// Name + /// Exchange name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Identifier /// + [JsonPropertyName("identifier")] public string Identifier { get; set; } = string.Empty; /// /// Has trading incentive /// - [JsonProperty("has_trading_incentive")] + [JsonPropertyName("has_trading_incentive")] public bool HasTradingIncentive { get; set; } + /// + /// Logo + /// + [JsonPropertyName("logo")] + public string? Logo { get; set; } } } \ No newline at end of file diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoAssetHistory.cs b/CoinGecko.Net/Objects/Models/CoinGeckoAssetHistory.cs index ce47445..203332b 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoAssetHistory.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoAssetHistory.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using System.Collections.Generic; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -11,43 +11,69 @@ public record CoinGeckoAssetHistory /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Localization /// + [JsonPropertyName("localization")] public Dictionary Localization { get; set; } = new Dictionary(); /// /// Images /// - [JsonProperty("image")] + [JsonPropertyName("image")] public CoinGeckoImages? Images { get; set; } /// /// Market data /// - [JsonProperty("market_data")] - public CoinGeckoMarketData? MarketData { get; set; } + [JsonPropertyName("market_data")] + public CoinGeckoMarketDataBasic? MarketData { get; set; } /// /// Community data /// - [JsonProperty("community_data")] + [JsonPropertyName("community_data")] public CoinGeckoCommunityData? CommunityData { get; set; } /// /// Developer data /// - [JsonProperty("developer_data")] + [JsonPropertyName("developer_data")] public CoinGeckoDeveloperData? DeveloperData { get; set; } /// /// Public interest stats /// - [JsonProperty("public_interest_stats")] + [JsonPropertyName("public_interest_stats")] public CoinGeckoPublicInterestStats? PublicInterestStats { get; set; } } + + /// + /// Basic market data + /// + public record CoinGeckoMarketDataBasic + { + /// + /// Current price + /// + [JsonPropertyName("current_price")] + public Dictionary CurrentPrice { get; set; } = new Dictionary(); + /// + /// Market caps + /// + [JsonPropertyName("market_cap")] + public Dictionary MarketCaps { get; set; } = new Dictionary(); + /// + /// Total volumes + /// + [JsonPropertyName("total_volume")] + public Dictionary TotalVolumes { get; set; } = new Dictionary(); + } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoAssetPlatform.cs b/CoinGecko.Net/Objects/Models/CoinGeckoAssetPlatform.cs index 4c218f1..90efde0 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoAssetPlatform.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoAssetPlatform.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,19 +10,32 @@ public record CoinGeckoAssetPlatform /// /// Platform id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Chain identifier /// - [JsonProperty("chain_identifier")] - public string? ChainIdentifier { get; set; } + [JsonPropertyName("chain_identifier")] + public int? ChainIdentifier { get; set; } /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Short name /// + [JsonPropertyName("shortname")] public string? ShortName { get; set; } + /// + /// Chain native coin id + /// + [JsonPropertyName("native_coin_id")] + public string? NativeCoinId { get; set; } + /// + /// Platform image + /// + [JsonPropertyName("image")] + public CoinGeckoImages? Image { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoCategory.cs b/CoinGecko.Net/Objects/Models/CoinGeckoCategory.cs index bed4465..0e2782d 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoCategory.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoCategory.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,11 +10,12 @@ public record CoinGeckoCategory /// /// Category id /// - [JsonProperty("category_id")] + [JsonPropertyName("category_id")] public string CategoryId { get; set; } = string.Empty; /// /// Category name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoCodeAddDel.cs b/CoinGecko.Net/Objects/Models/CoinGeckoCodeAddDel.cs index f3d42b0..baa788d 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoCodeAddDel.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoCodeAddDel.cs @@ -1,6 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; + + +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -12,10 +12,12 @@ public record CoinGeckoCodeAddDel /// /// Lines added /// + [JsonPropertyName("additions")] public int? Additions { get; set; } /// /// Lines deleted /// + [JsonPropertyName("deletions")] public int? Deletions { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoCommunityData.cs b/CoinGecko.Net/Objects/Models/CoinGeckoCommunityData.cs index aff9b5b..121c605 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoCommunityData.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoCommunityData.cs @@ -1,7 +1,4 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -13,37 +10,37 @@ public record CoinGeckoCommunityData /// /// Facebook likes /// - [JsonProperty("facebook_likes")] + [JsonPropertyName("facebook_likes")] public int? FacebookLikes { get; set; } /// /// Twitter followers /// - [JsonProperty("twitter_followers")] + [JsonPropertyName("twitter_followers")] public int? TwitterFollowers { get; set; } /// /// Average amount of reddit posts per 48 hours /// - [JsonProperty("reddit_average_posts_48h")] + [JsonPropertyName("reddit_average_posts_48h")] public decimal? RedditAveragePostsPer48h { get; set; } /// /// Average amount of reddit comments per 48 hours /// - [JsonProperty("reddit_average_comments_48h")] + [JsonPropertyName("reddit_average_comments_48h")] public decimal? RedditAverageCommentsPer48h { get; set; } /// /// Reddit subscribers /// - [JsonProperty("reddit_subscribers")] + [JsonPropertyName("reddit_subscribers")] public int? RedditSubscribers { get; set; } /// /// Active reddit subscribers last 48 hours /// - [JsonProperty("reddit_accounts_active_48h")] + [JsonPropertyName("reddit_accounts_active_48h")] public decimal? RedditActiveAccounts48h { get; set; } /// /// Telegram channel user count /// - [JsonProperty("telegram_channel_user_count")] + [JsonPropertyName("telegram_channel_user_count")] public int? TelegramChannelUserCount { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoCompanyHolding.cs b/CoinGecko.Net/Objects/Models/CoinGeckoCompanyHolding.cs new file mode 100644 index 0000000..8c7dc8d --- /dev/null +++ b/CoinGecko.Net/Objects/Models/CoinGeckoCompanyHolding.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace CoinGecko.Net.Objects.Models +{ + /// + /// Company holdings + /// + public record CoinGeckoCompanyHolding + { + /// + /// Total holdings + /// + [JsonPropertyName("total_holdings")] + public decimal TotalHoldings { get; set; } + /// + /// Total value in USD + /// + [JsonPropertyName("total_value_usd")] + public decimal TotalValueUsd { get; set; } + /// + /// Market cap dominance + /// + [JsonPropertyName("market_cap_dominance")] + public decimal MarketCapDominance { get; set; } + /// + /// Companies + /// + [JsonPropertyName("companies")] + public IEnumerable Companies { get; set; } = Array.Empty(); + } + + /// + /// Company holding + /// + public record CoinGeckoCompanyAsset + { + /// + /// Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Country + /// + [JsonPropertyName("country")] + public string Country { get; set; } = string.Empty; + /// + /// Total holdings + /// + [JsonPropertyName("total_holdings")] + public decimal TotalHoldings { get; set; } + /// + /// Total entry value USD + /// + [JsonPropertyName("total_entry_value_usd")] + public decimal TotalEntryValueUsd { get; set; } + /// + /// Total current value USD + /// + [JsonPropertyName("total_current_value_usd")] + public decimal TotalCurrentValueUsd { get; set; } + /// + /// Percentage of total supply + /// + [JsonPropertyName("percentage_of_total_supply")] + public decimal PercentageOfTotalSupply { get; set; } + } + + +} diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoDerivative.cs b/CoinGecko.Net/Objects/Models/CoinGeckoDerivative.cs index 3533d83..a542d2e 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoDerivative.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoDerivative.cs @@ -1,6 +1,5 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; +using System; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -12,67 +11,73 @@ public record CoinGeckoDerivative /// /// Market /// + [JsonPropertyName("market")] public string Market { get; set; } = string.Empty; /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Index id /// - [JsonProperty("index_id")] + [JsonPropertyName("index_id")] public string IndexId { get; set; } = string.Empty; /// /// Price /// + [JsonPropertyName("price")] public decimal? Price { get; set; } /// /// Price change percentage last 24h /// - [JsonProperty("price_percentage_change_24h")] + [JsonPropertyName("price_percentage_change_24h")] public decimal? PricePercentageChange24h { get; set; } /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] public string ContractType { get; set; } = string.Empty; /// /// Index /// + [JsonPropertyName("index")] public decimal? Index { get; set; } /// /// Basis /// + [JsonPropertyName("basis")] public decimal? Basis { get; set; } /// /// Spread /// + [JsonPropertyName("spread")] public decimal? Spread { get; set; } /// /// Funding rate /// - [JsonProperty("funding_rate")] + [JsonPropertyName("funding_rate")] public decimal? FundingRate { get; set; } /// /// Open interest /// - [JsonProperty("open_interest")] + [JsonPropertyName("open_interest")] public decimal? OpenInterest { get; set; } /// /// Volume last 24h /// - [JsonProperty("volume_24h")] + [JsonPropertyName("volume_24h")] public decimal? Volume24h { get; set; } /// /// Last traded at /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("last_traded_at")] + [JsonPropertyName("last_traded_at")] public DateTime? LastTradedAt { get; set; } /// /// Expired at /// - [JsonProperty("expired_at")] + [JsonPropertyName("expired_at")] [JsonConverter(typeof(DateTimeConverter))] public DateTime? ExpiredAt { get; set; } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoDerivativeTicker.cs b/CoinGecko.Net/Objects/Models/CoinGeckoDerivativeTicker.cs new file mode 100644 index 0000000..2e081b3 --- /dev/null +++ b/CoinGecko.Net/Objects/Models/CoinGeckoDerivativeTicker.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace CoinGecko.Net.Objects.Models +{ + /// + /// Derivatives ticker + /// + public record CoinGeckoDerivativeTicker + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Base asset + /// + [JsonPropertyName("base")] + public string Base { get; set; } = string.Empty; + /// + /// Target asset + /// + [JsonPropertyName("target")] + public string Target { get; set; } = string.Empty; + /// + /// Trade url + /// + [JsonPropertyName("trade_url")] + public string TradeUrl { get; set; } = string.Empty; + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public string ContractType { get; set; } = string.Empty; + /// + /// Last price + /// + [JsonPropertyName("last")] + public decimal LastPrice { get; set; } + /// + /// 24 hour percentage change + /// + [JsonPropertyName("h24_percentage_change")] + public decimal H24PercentageChange { get; set; } + /// + /// Index price + /// + [JsonPropertyName("index")] + public decimal IndexPrice { get; set; } + /// + /// Index basis percentage + /// + [JsonPropertyName("index_basis_percentage")] + public decimal IndexBasisPercentage { get; set; } + /// + /// Bid ask spread + /// + [JsonPropertyName("bid_ask_spread")] + public decimal BidAskSpread { get; set; } + /// + /// Funding rate + /// + [JsonPropertyName("funding_rate")] + public decimal FundingRate { get; set; } + /// + /// Open interest usd + /// + [JsonPropertyName("open_interest_usd")] + public decimal OpenInterestUsd { get; set; } + /// + /// 24 hour volume + /// + [JsonPropertyName("h24_volume")] + public decimal H24Volume { get; set; } + /// + /// Converted volume + /// + [JsonPropertyName("converted_volume")] + public Dictionary ConvertedVolume { get; set; } = null!; + /// + /// Converted last + /// + [JsonPropertyName("converted_last")] + public Dictionary ConvertedLast { get; set; } = null!; + /// + /// Last trade time + /// + [JsonPropertyName("last_traded")] + public DateTime LastTradeTime { get; set; } + /// + /// Expired time + /// + [JsonPropertyName("expired_at")] + public DateTime? ExpireTime { get; set; } + } +} diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoDeveloperData.cs b/CoinGecko.Net/Objects/Models/CoinGeckoDeveloperData.cs index 05e9005..a73990c 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoDeveloperData.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoDeveloperData.cs @@ -1,7 +1,5 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -13,49 +11,52 @@ public record CoinGeckoDeveloperData /// /// Forks /// + [JsonPropertyName("forks")] public int? Forks { get; set; } /// /// Stars /// + [JsonPropertyName("stars")] public int? Stars { get; set; } /// /// Subscribers /// + [JsonPropertyName("subscribers")] public int? Subscribers { get; set; } /// /// Total issues /// - [JsonProperty("total_issues")] + [JsonPropertyName("total_issues")] public int? TotalIssues { get; set; } /// /// Closed issues /// - [JsonProperty("closed_issues")] + [JsonPropertyName("closed_issues")] public int? ClosedIssues { get; set; } /// /// Pull requests merged /// - [JsonProperty("pull_requests_merged")] + [JsonPropertyName("pull_requests_merged")] public int? PullRequestsMerged { get; set; } /// /// Pull request contributors /// - [JsonProperty("pull_request_contributors")] + [JsonPropertyName("pull_request_contributors")] public int? PullRequestContributors { get; set; } /// /// Code changes last 4 weeks /// - [JsonProperty("code_additions_deletions_4_weeks")] + [JsonPropertyName("code_additions_deletions_4_weeks")] public CoinGeckoCodeAddDel? CodeAdditionsDeletions4Weeks { get; set; } /// /// Amount of commits last 4 weeks /// - [JsonProperty("commit_count_4_weeks")] + [JsonPropertyName("commit_count_4_weeks")] public int? CommitCount4Weeks { get; set; } /// /// Commits series last 4 weeks /// - [JsonProperty("last_4_weeks_commit_activity_series")] + [JsonPropertyName("last_4_weeks_commit_activity_series")] public IEnumerable Last4WeeksCommitActivitySeries { get; set; } = new List(); } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoExchange.cs b/CoinGecko.Net/Objects/Models/CoinGeckoExchange.cs index d913c1a..3084d6a 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoExchange.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoExchange.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,56 +10,62 @@ public record CoinGeckoExchange /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Year established /// - [JsonProperty("year_established")] + [JsonPropertyName("year_established")] public int? YearEstablished { get; set; } /// /// Country /// + [JsonPropertyName("country")] public string Country { get; set; } = string.Empty; /// /// Description /// + [JsonPropertyName("description")] public string Description { get; set; } = string.Empty; /// /// Url /// + [JsonPropertyName("url")] public string Url { get; set; } = string.Empty; /// /// Image /// + [JsonPropertyName("image")] public string Image { get; set; } = string.Empty; /// /// Has a trading incentive /// - [JsonProperty("has_trading_incentive")] + [JsonPropertyName("has_trading_incentive")] public bool? HasTradingIncentive { get; set; } /// /// Trust score /// - [JsonProperty("trust_score")] - public string? TrustScore { get; set; } + [JsonPropertyName("trust_score")] + public int? TrustScore { get; set; } /// /// Trust score rank /// - [JsonProperty("trust_score_rank")] + [JsonPropertyName("trust_score_rank")] public int? TrustScoreRank { get; set; } /// /// Trading volume in btc last 24h /// - [JsonProperty("trade_volume_24h_btc")] + [JsonPropertyName("trade_volume_24h_btc")] public decimal? TradeVolume24hBtc { get; set; } /// /// Normalized trading volume in btc last 24h /// - [JsonProperty("trade_volume_24h_btc_normalized")] + [JsonPropertyName("trade_volume_24h_btc_normalized")] public decimal? TradeVolume24hBtcNormalized { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoExchangeDerivative.cs b/CoinGecko.Net/Objects/Models/CoinGeckoExchangeDerivative.cs index e27029f..59ad6d3 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoExchangeDerivative.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoExchangeDerivative.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,51 +11,62 @@ public record CoinGeckoExchangeDerivative /// /// Mame /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Open interest in btc /// - [JsonProperty("open_interest_btc")] + [JsonPropertyName("open_interest_btc")] public decimal? OpenInterestBtc { get; set; } /// /// Trade volume in btc /// - [JsonProperty("trade_volume_24h_btc")] + [JsonPropertyName("trade_volume_24h_btc")] public decimal? TradeVolume24hBtc { get; set; } /// /// Number of perpetual pairs /// - [JsonProperty("number_of_perpetual_pairs")] + [JsonPropertyName("number_of_perpetual_pairs")] public int NumberOfPerpetualPairs { get; set; } /// /// Number of futures pairs /// - [JsonProperty("number_of_futures_pairs")] + [JsonPropertyName("number_of_futures_pairs")] public int NumberOfFuturesPairs { get; set; } /// /// Image /// + [JsonPropertyName("image")] public string Image { get; set; } = string.Empty; /// /// Year established /// - [JsonProperty("year_established")] + [JsonPropertyName("year_established")] public int? YearEstablished { get; set; } /// /// Country /// + [JsonPropertyName("country")] public string? Country { get; set; } /// /// Description /// + [JsonPropertyName("decription")] public string Description { get; set; } = string.Empty; /// /// Url /// + [JsonPropertyName("url")] public string Url { get; set; } = string.Empty; + /// + /// Tickers + /// + [JsonPropertyName("tickers")] + public IEnumerable? Tickers { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoExchangeDetails.cs b/CoinGecko.Net/Objects/Models/CoinGeckoExchangeDetails.cs index 2cfd987..83cc741 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoExchangeDetails.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoExchangeDetails.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; using System; using System.Collections.Generic; @@ -12,110 +12,112 @@ public record CoinGeckoExchangeDetails /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Year established /// - [JsonProperty("year_established")] + [JsonPropertyName("year_established")] public int? YearEstablished { get; set; } /// /// Country /// + [JsonPropertyName("country")] public string Country { get; set; } = string.Empty; /// /// Description /// + [JsonPropertyName("description")] public string Description { get; set; } = string.Empty; /// /// Url /// + [JsonPropertyName("url")] public string Url { get; set; } = string.Empty; /// /// Image /// + [JsonPropertyName("image")] public string Image { get; set; } = string.Empty; /// /// Facebook url /// - [JsonProperty("facebook_url")] + [JsonPropertyName("facebook_url")] public string FacebookUrl { get; set; } = string.Empty; /// /// Reddit url /// - [JsonProperty("reddit_url")] + [JsonPropertyName("reddit_url")] public string RedditUrl { get; set; } = string.Empty; /// /// Telegram url /// - [JsonProperty("telegram_url")] + [JsonPropertyName("telegram_url")] public string TelegramUrl { get; set; } = string.Empty; /// /// Slack url /// - [JsonProperty("slack_url")] + [JsonPropertyName("slack_url")] public string SlackUrl { get; set; } = string.Empty; /// /// Other url 1 /// - [JsonProperty("other_url_1")] + [JsonPropertyName("other_url_1")] public string OtherUrl1 { get; set; } = string.Empty; /// /// Other url 2 /// - [JsonProperty("other_url_2")] + [JsonPropertyName("other_url_2")] public string OtherUrl2 { get; set; } = string.Empty; /// /// Twitter handle /// - [JsonProperty("twitter_handle")] + [JsonPropertyName("twitter_handle")] public string TwitterHandle { get; set; } = string.Empty; /// /// Has trading incentive /// - [JsonProperty("has_trading_incentive")] + [JsonPropertyName("has_trading_incentive")] public bool HasTradingIncentive { get; set; } /// /// Centralized /// + [JsonPropertyName("centralized")] public bool Centralized { get; set; } /// /// Public notice /// - [JsonProperty("public_notice")] + [JsonPropertyName("public_notice")] public string PublicNotice { get; set; } = string.Empty; /// /// Alert notice /// - [JsonProperty("alert_notice")] + [JsonPropertyName("alert_notice")] public string AlertNotice { get; set; } = string.Empty; /// /// Trust score /// - [JsonProperty("trust_score")] - public string? TrustScore { get; set; } + [JsonPropertyName("trust_score")] + public int? TrustScore { get; set; } /// /// Trust score rank /// - [JsonProperty("trust_score_rank")] + [JsonPropertyName("trust_score_rank")] public int? TrustScoreRank { get; set; } /// /// Trade volume in btc last 24h /// - [JsonProperty("trade_volume_24h_btc")] + [JsonPropertyName("trade_volume_24h_btc")] public decimal? TradeVolume24hBtc { get; set; } /// /// Normalized trade volume in btc last 24h /// - [JsonProperty("trade_volume_24h_btc_normalized")] + [JsonPropertyName("trade_volume_24h_btc_normalized")] public decimal? TradeVolume24hBtcNormalized { get; set; } /// /// Tickers /// + [JsonPropertyName("tickers")] public IEnumerable Tickers { get; set; } = Array.Empty(); - /// - /// Status updates - /// - [JsonProperty("status_updates")] - public IEnumerable StatusUpdates { get; set; } = Array.Empty(); } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoExchangeRates.cs b/CoinGecko.Net/Objects/Models/CoinGeckoExchangeRates.cs index 71e6d28..5c901a5 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoExchangeRates.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoExchangeRates.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,6 +11,7 @@ public record CoinGeckoExchangeRates /// /// Rates dictionary /// + [JsonPropertyName("rates")] public Dictionary Rates { get; set; } = new Dictionary(); } @@ -21,18 +23,22 @@ public record CoinGeckoExchangeRate /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Unit /// + [JsonPropertyName("unit")] public string Unit { get; set; } = string.Empty; /// /// Value /// + [JsonPropertyName("value")] public decimal? Value { get; set; } /// /// Type /// + [JsonPropertyName("type")] public string Type { get; set; } = string.Empty; } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoGlobalData.cs b/CoinGecko.Net/Objects/Models/CoinGeckoGlobalData.cs index fe885f7..23195b9 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoGlobalData.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoGlobalData.cs @@ -1,12 +1,12 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { internal record CoinGeckoGlobalDataWrapper { + [JsonPropertyName("data")] public CoinGeckoGlobalData? Data { get; set; } } @@ -18,52 +18,53 @@ public record CoinGeckoGlobalData /// /// Active crypto currencies /// - [JsonProperty("active_cryptocurrencies")] + [JsonPropertyName("active_cryptocurrencies")] public int ActiveCryptoCurrencies { get; set; } /// /// Upcoming icos /// - [JsonProperty("upcoming_icos")] + [JsonPropertyName("upcoming_icos")] public int UpcomingIcos { get; set; } /// /// Ongoing icos /// - [JsonProperty("ongoing_icos")] + [JsonPropertyName("ongoing_icos")] public int OngoingIcos { get; set; } /// /// Ended icos /// - [JsonProperty("ended_icos")] + [JsonPropertyName("ended_icos")] public int EndedIcos { get; set; } /// - /// Markets + /// Exchanges /// - public int Markets { get; set; } + [JsonPropertyName("markets")] + public int Exchanges { get; set; } /// /// Total crypto market cap /// - [JsonProperty("total_market_cap")] + [JsonPropertyName("total_market_cap")] public Dictionary TotalMarketCap { get; set; } = new Dictionary(); /// /// Total trade volume /// - [JsonProperty("total_volume")] + [JsonPropertyName("total_volume")] public Dictionary TotalVolume { get; set; } = new Dictionary(); /// /// Market cap percentages /// - [JsonProperty("market_cap_percentage")] + [JsonPropertyName("market_cap_percentage")] public Dictionary MarketCapPercentage { get; set; } = new Dictionary(); /// /// Market cap percentage change over last 24 hours /// - [JsonProperty("market_cap_change_percentage_24h_usd")] + [JsonPropertyName("market_cap_change_percentage_24h_usd")] public decimal? MarketCapChangePercentage24hUsd { get; set; } /// /// Updated at /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("updated_at")] + [JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoGlobalDefiData.cs b/CoinGecko.Net/Objects/Models/CoinGeckoGlobalDefiData.cs index a15154b..55804ff 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoGlobalDefiData.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoGlobalDefiData.cs @@ -1,9 +1,10 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { internal record CoinGeckoGlobalDefiDataWrapper { + [JsonPropertyName("data")] public CoinGeckoGlobalDefiData? Data { get; set; } } @@ -15,37 +16,37 @@ public record CoinGeckoGlobalDefiData /// /// Defi market cap /// - [JsonProperty("defi_market_cap")] + [JsonPropertyName("defi_market_cap")] public decimal? DefiMarketCap { get; set; } /// /// Eth market cap /// - [JsonProperty("eth_market_cap")] + [JsonPropertyName("eth_market_cap")] public decimal? EthMarketCap { get; set; } /// /// Defi to eth ratio /// - [JsonProperty("defi_to_eth_ratio")] + [JsonPropertyName("defi_to_eth_ratio")] public decimal? DefiToEthRatio { get; set; } /// /// Trading volume 24h /// - [JsonProperty("trading_volume_24h")] + [JsonPropertyName("trading_volume_24h")] public decimal? TradingVolume24h { get; set; } /// /// Defi dominance /// - [JsonProperty("defi_dominance")] + [JsonPropertyName("defi_dominance")] public decimal? DefiDominance { get; set; } /// /// Top asset name /// - [JsonProperty("top_coin_name")] + [JsonPropertyName("top_coin_name")] public string TopAssetName { get; set; } = string.Empty; /// /// Top defi asset dominance /// - [JsonProperty("top_coin_defi_dominance")] + [JsonPropertyName("top_coin_defi_dominance")] public decimal? TopAssetDefiDominance { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoIcoData.cs b/CoinGecko.Net/Objects/Models/CoinGeckoIcoData.cs deleted file mode 100644 index 6ead702..0000000 --- a/CoinGecko.Net/Objects/Models/CoinGeckoIcoData.cs +++ /dev/null @@ -1,158 +0,0 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; - -namespace CoinGecko.Net.Objects.Models -{ - /// - /// Ico information - /// - public record CoinGeckoIcoData - { - /// - /// Ico start date - /// - [JsonProperty("ico_start_date")] - [JsonConverter(typeof(DateTimeConverter))] - public DateTime? IcoStartDate { get; set; } - /// - /// Ico end date - /// - [JsonProperty("ico_end_date")] - [JsonConverter(typeof(DateTimeConverter))] - public DateTime? IcoEndDate { get; set; } - /// - /// Short description - /// - [JsonProperty("short_desc")] - public string ShortDescription { get; set; } = string.Empty; - /// - /// Description - /// - public string? Description { get; set; } - /// - /// Soft cap currency - /// - [JsonProperty("softcap_currency")] - public string? SoftcapCurrency { get; set; } - /// - /// Hard cap currency - /// - [JsonProperty("hardcap_currency")] - public string? HardcapCurrency { get; set; } - /// - /// Total raised currency - /// - [JsonProperty("total_raised_currency")] - public string? TotalRaisedCurrency { get; set; } - /// - /// Softcap - /// - [JsonProperty("softcap_amount")] - public decimal? SoftcapAmount { get; set; } - /// - /// Hardcap amount - /// - [JsonProperty("hardcap_amount")] - public decimal? HardcapAmount { get; set; } - /// - /// Total raised - /// - [JsonProperty("total_raised")] - public decimal? TotalRaised { get; set; } - /// - /// Quote pre-sale currency - /// - [JsonProperty("quote_pre_sale_currency")] - public string QuotePreSaleCurrency { get; set; } = string.Empty; - /// - /// Base pre sale amount - /// - [JsonProperty("base_pre_sale_amount")] - public string BasePreSaleAmount { get; set; } = string.Empty; - /// - /// Quote pre sale amount - /// - [JsonProperty("quote_pre_sale_amount")] - public decimal? QuotePreSaleAmount { get; set; } - /// - /// Quote public sale currency - /// - [JsonProperty("quote_public_sale_currency")] - public string QuotePublicSaleCurrency { get; set; } = string.Empty; - /// - /// Base public sale amount - /// - [JsonProperty("base_public_sale_amount")] - public decimal? BasePublicSaleAmount { get; set; } - /// - /// Quote public sale amount - /// - [JsonProperty("quote_public_sale_amount")] - public decimal? QuotePublicSaleAmount { get; set; } - /// - /// Accepting currencies - /// - [JsonProperty("accepting_currencies")] - public string AcceptingCurrencies { get; set; } = string.Empty; - /// - /// Country origin - /// - [JsonProperty("country_origin")] - public string CountryOrigin { get; set; } = string.Empty; - /// - /// Pre sale start date - /// - [JsonProperty("pre_sale_start_date")] - [JsonConverter(typeof(DateTimeConverter))] - public DateTime? PreSaleStartDate { get; set; } - /// - /// Pre sale end date - /// - [JsonProperty("pre_sale_end_date")] - [JsonConverter(typeof(DateTimeConverter))] - public DateTime? PreSaleEndDate { get; set; } - /// - /// Whitelist url - /// - [JsonProperty("whitelist_url")] - public string WhitelistUrl { get; set; } = string.Empty; - /// - /// Whitelist start date - /// - [JsonProperty("whitelist_start_date")] - [JsonConverter(typeof(DateTimeConverter))] - public DateTime? WhitelistStartDate { get; set; } - /// - /// Whitelist end date - /// - [JsonProperty("whitelist_end_date")] - [JsonConverter(typeof(DateTimeConverter))] - public DateTime? WhitelistEndDate { get; set; } - /// - /// Bounty detail url - /// - [JsonProperty("bounty_detail_url")] - public string BountyDetailUrl { get; set; } = string.Empty; - /// - /// Amount for sale - /// - [JsonProperty("amount_for_sale")] - public decimal? AmountForSale { get; set; } - /// - /// KYC required - /// - [JsonProperty("kyc_required")] - public bool KycRequired { get; set; } - /// - /// Whitelist available - /// - [JsonProperty("whitelist_available")] - public bool? WhitelistAvailable { get; set; } - /// - /// Pre sale ended - /// - [JsonProperty("pre_sale_ended")] - public bool PreSaleEnded { get; set; } - } -} diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoImages.cs b/CoinGecko.Net/Objects/Models/CoinGeckoImages.cs index 48d6933..8dacafe 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoImages.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoImages.cs @@ -1,4 +1,6 @@ -namespace CoinGecko.Net.Objects.Models +using System.Text.Json.Serialization; + +namespace CoinGecko.Net.Objects.Models { /// /// Image links @@ -8,14 +10,17 @@ public record CoinGeckoImages /// /// Thumbnail /// + [JsonPropertyName("thumb")] public string? Thumb { get; set; } /// /// Small image /// + [JsonPropertyName("small")] public string? Small { get; set; } /// /// Large image /// + [JsonPropertyName("large")] public string? Large { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoIndex.cs b/CoinGecko.Net/Objects/Models/CoinGeckoIndex.cs deleted file mode 100644 index 98a0875..0000000 --- a/CoinGecko.Net/Objects/Models/CoinGeckoIndex.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Newtonsoft.Json; - -namespace CoinGecko.Net.Objects.Models -{ - /// - /// Index info - /// - public record CoinGeckoIndex - { - /// - /// Id - /// - public string Id { get; set; } = string.Empty; - /// - /// Name - /// - public string Name { get; set; } = string.Empty; - /// - /// Market - /// - public string Market { get; set; } = string.Empty; - /// - /// Last - /// - public decimal? Last { get; set; } - /// - /// Is multi asset composite index - /// - [JsonProperty("is_multi_asset_composite")] - public bool? IsMultiAssetComposite { get; set; } - } -} diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoLinks.cs b/CoinGecko.Net/Objects/Models/CoinGeckoLinks.cs index 0405855..f14f008 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoLinks.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoLinks.cs @@ -1,7 +1,7 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Text; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -13,56 +13,62 @@ public record CoinGeckoLinks /// /// Homepage /// + [JsonPropertyName("homepage")] public IEnumerable Homepage { get; set; } = Array.Empty(); /// + /// White paper link + /// + [JsonPropertyName("whitepaper")] + public string? WhitePaper { get; set; } + /// /// Blockchain explorer links /// - [JsonProperty("blockchain_site")] + [JsonPropertyName("blockchain_site")] public IEnumerable BlockchainSites { get; set; } = Array.Empty(); /// /// Official forum urls /// - [JsonProperty("official_forum_url")] + [JsonPropertyName("official_forum_url")] public IEnumerable OfficialForumUrls { get; set; } = Array.Empty(); /// /// Chat urls /// - [JsonProperty("chat_url")] + [JsonPropertyName("chat_url")] public IEnumerable ChatUrls { get; set; } = Array.Empty(); /// /// Announcement urls /// - [JsonProperty("announcement_url")] + [JsonPropertyName("announcement_url")] public IEnumerable AnnouncementUrls { get; set; } = Array.Empty(); /// /// Twitter name /// - [JsonProperty("twitter_screen_name")] + [JsonPropertyName("twitter_screen_name")] public string TwitterScreenName { get; set; } = string.Empty; /// /// Facebook name /// - [JsonProperty("facebook_username")] + [JsonPropertyName("facebook_username")] public string FacebookName { get; set; } = string.Empty; /// /// BitcoinTalk thread identifier /// - [JsonProperty("bitcointalk_thread_identifier")] + [JsonPropertyName("bitcointalk_thread_identifier")] public string? BitcoinTalkThreadIdentifier { get; set; } = string.Empty; /// /// Telegram channel identifier /// - [JsonProperty("telegram_channel_identifier")] + [JsonPropertyName("telegram_channel_identifier")] public string? TelegramChannelIdentifier { get; set; } = string.Empty; /// /// Subreddit url /// - [JsonProperty("subreddit_url")] + [JsonPropertyName("subreddit_url")] public string? SubredditUrl { get; set; } = string.Empty; /// /// Git repository urls /// - [JsonProperty("repos_url")] + [JsonPropertyName("repos_url")] public Dictionary> RepoUrls { get; set; } = new Dictionary>(); } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoListItem.cs b/CoinGecko.Net/Objects/Models/CoinGeckoListItem.cs index c3369f0..a5ef095 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoListItem.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoListItem.cs @@ -1,4 +1,6 @@ -namespace CoinGecko.Net.Objects.Models +using System.Text.Json.Serialization; + +namespace CoinGecko.Net.Objects.Models { /// /// List item @@ -8,10 +10,12 @@ public record CoinGeckoListItem /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoMarket.cs b/CoinGecko.Net/Objects/Models/CoinGeckoMarket.cs index acb937f..3772702 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoMarket.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoMarket.cs @@ -1,6 +1,5 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; +using System; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -12,150 +11,157 @@ public record CoinGeckoMarket /// /// Market id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Market symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Image /// + [JsonPropertyName("image")] public string Image { get; set; } = string.Empty; /// /// Current price /// - [JsonProperty("current_price")] + [JsonPropertyName("current_price")] public decimal CurrentPrice { get; set; } /// /// Market cap /// - [JsonProperty("market_cap")] + [JsonPropertyName("market_cap")] public decimal MarketCap { get; set; } /// /// Market cap rank /// - [JsonProperty("market_cap_rank")] + [JsonPropertyName("market_cap_rank")] public decimal? MarketCapRank { get; set; } /// /// Fully diluted valuation /// - [JsonProperty("fully_diluted_valuation")] + [JsonPropertyName("fully_diluted_valuation")] public decimal? FullyDilutedValuation { get; set; } /// /// Total trade volume /// - [JsonProperty("total_volume")] + [JsonPropertyName("total_volume")] public decimal TotalVolume { get; set; } /// /// 24 hour high price /// - [JsonProperty("high_24h")] + [JsonPropertyName("high_24h")] public decimal? High24h { get; set; } /// /// 24 hour low price /// - [JsonProperty("low_24h")] + [JsonPropertyName("low_24h")] public decimal? Low24h { get; set; } /// /// 24 hour price change /// - [JsonProperty("price_change_24h")] + [JsonPropertyName("price_change_24h")] public decimal? PriceChange24h { get; set; } /// /// 24 hour price change percentage /// - [JsonProperty("price_change_percentage_24h")] + [JsonPropertyName("price_change_percentage_24h")] public double? PriceChangePercentage24h { get; set; } /// /// 24 hour market cap change /// - [JsonProperty("market_cap_change_24h")] + [JsonPropertyName("market_cap_change_24h")] public decimal? MarketCapChange24h { get; set; } /// /// 24 hour market cap change percentage /// - [JsonProperty("market_cap_change_percentage_24h")] + [JsonPropertyName("market_cap_change_percentage_24h")] public double? MarketCapChangePercentage24h { get; set; } /// /// Circulating supply /// - [JsonProperty("circulating_supply")] + [JsonPropertyName("circulating_supply")] public decimal CiculationSupply { get; set; } /// /// Total supply /// - [JsonProperty("total_supply")] + [JsonPropertyName("total_supply")] public decimal? TotalSupply { get; set; } /// /// Max supply /// - [JsonProperty("max_supply")] + [JsonPropertyName("max_supply")] public decimal? MaxSupply { get; set; } /// /// All time high price /// - [JsonProperty("ath")] + [JsonPropertyName("ath")] public decimal AllTimeHigh { get; set; } /// /// All time high change percentage /// - [JsonProperty("ath_change_percentage")] + [JsonPropertyName("ath_change_percentage")] public double AllTimeHighChangePercentage { get; set; } /// /// All time high time /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("ath_date")] + [JsonPropertyName("ath_date")] public DateTime AllTimeHighTimestamp { get; set; } /// /// All time low price /// - [JsonProperty("atl")] + [JsonPropertyName("atl")] public decimal AllTimeLow { get; set; } /// /// All time low change percentage /// - [JsonProperty("atl_change_percentage")] + [JsonPropertyName("atl_change_percentage")] public double AllTimeLowChangePercentage { get; set; } /// /// All time low time /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("atl_date")] + [JsonPropertyName("atl_date")] public DateTime AllTimeLowTimestamp { get; set; } /// /// Return on investment /// + [JsonPropertyName("roi")] public CoinGeckoMarketRoi? Roi { get; set; } /// /// Last updated timestamp /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("last_updated")] + [JsonPropertyName("last_updated")] public DateTime LastUpdated { get; set; } } /// - /// Market raturn on investment info + /// Market return on investment info /// public record CoinGeckoMarketRoi { /// /// Times /// + [JsonPropertyName("times")] public decimal Times { get; set; } /// /// Investment asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Profit percentage /// + [JsonPropertyName("percentage")] public decimal Percentage { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoMarketChart.cs b/CoinGecko.Net/Objects/Models/CoinGeckoMarketChart.cs index 9359724..03c9a6b 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoMarketChart.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoMarketChart.cs @@ -1,8 +1,8 @@ using CryptoExchange.Net.Converters; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -14,16 +14,17 @@ public record CoinGeckoMarketChart /// /// Price history /// + [JsonPropertyName("prices")] public IEnumerable Prices { get; set; } = Array.Empty(); /// /// Market cap history /// - [JsonProperty("market_caps")] + [JsonPropertyName("market_caps")] public IEnumerable MarketCaps { get; set; } = Array.Empty(); /// /// Volume history /// - [JsonProperty("total_volumes")] + [JsonPropertyName("total_volumes")] public IEnumerable TotalVolumes { get; set; } = Array.Empty(); } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoMarketData.cs b/CoinGecko.Net/Objects/Models/CoinGeckoMarketData.cs index 9c52e37..4f256b2 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoMarketData.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoMarketData.cs @@ -1,8 +1,7 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Text; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -14,211 +13,217 @@ public record CoinGeckoMarketData /// /// Current price /// - [JsonProperty("current_price")] + [JsonPropertyName("current_price")] public Dictionary CurrentPrice { get; set; } = new Dictionary(); /// /// Total value locked /// - [JsonProperty("total_value_locked")] + [JsonPropertyName("total_value_locked")] public Dictionary? TotalValueLocked { get; set; } /// /// Market cap to total value locked ratio /// - [JsonProperty("mcap_to_tvl_ratio")] + [JsonPropertyName("mcap_to_tvl_ratio")] public decimal? MarketCapToTotalValueLockedRatio { get; set; } /// /// Fully diluted valuation to total value locked ratio /// - [JsonProperty("fdv_to_tvl_ratio")] + [JsonPropertyName("fdv_to_tvl_ratio")] public decimal? FullyDilutedValuationToTotalValueLockedRatio { get; set; } /// /// Return on investment /// + [JsonPropertyName("roi")] public CoinGeckoMarketRoi? Roi { get; set; } /// /// All time high prices /// - [JsonProperty("ath")] + [JsonPropertyName("ath")] public Dictionary AllTimeHighs { get; set; } = new Dictionary(); /// /// Current price change vs all time high /// - [JsonProperty("ath_change_percentage")] + [JsonPropertyName("ath_change_percentage")] public Dictionary AllTimeHighChangePercentages { get; set; } = new Dictionary(); /// /// All time high dates /// - [JsonProperty("ath_date")] + [JsonPropertyName("ath_date")] public Dictionary AllTimeHighDates { get; set; } = new Dictionary(); /// /// All time low prices /// - [JsonProperty("atl")] + [JsonPropertyName("atl")] public Dictionary AllTimeLows { get; set; } = new Dictionary(); /// /// Current price change vs all time low /// - [JsonProperty("atl_change_percentage")] + [JsonPropertyName("atl_change_percentage")] public Dictionary AllTimeLowChangePercentages { get; set; } = new Dictionary(); /// /// All time low dates /// - [JsonProperty("atl_date")] + [JsonPropertyName("atl_date")] public Dictionary AllTimeLowDates { get; set; } = new Dictionary(); /// /// Market caps /// - [JsonProperty("market_cap")] + [JsonPropertyName("market_cap")] public Dictionary MarketCaps { get; set; } = new Dictionary(); /// /// Market cap rank /// - [JsonProperty("market_cap_rank")] + [JsonPropertyName("market_cap_rank")] public int? MarketCapRank { get; set; } /// /// Fully diluted valuation /// - [JsonProperty("fully_diluted_valuation")] + [JsonPropertyName("fully_diluted_valuation")] public Dictionary FullyDilutedValuations { get; set; } = new Dictionary(); /// + /// Market cap to fully diluted valuation ratio + /// + [JsonPropertyName("market_cap_fdv_ratio")] + public decimal? MarketCapToFullyDilutedValuationRatio { get; set; } + /// /// Total volumes /// - [JsonProperty("total_volume")] + [JsonPropertyName("total_volume")] public Dictionary TotalVolumes { get; set; } = new Dictionary(); /// /// 24h high prices /// - [JsonProperty("high_24h")] + [JsonPropertyName("high_24h")] public Dictionary High24h { get; set; } = new Dictionary(); /// /// 24h low prices /// - [JsonProperty("low_24h")] + [JsonPropertyName("low_24h")] public Dictionary Low24h { get; set; } = new Dictionary(); /// /// 24h price change /// - [JsonProperty("price_change_24h")] + [JsonPropertyName("price_change_24h")] public decimal? PriceChange24h { get; set; } /// /// 24h price change percentage /// - [JsonProperty("price_change_percentage_24h")] + [JsonPropertyName("price_change_percentage_24h")] public decimal? PriceChangePercentage24h { get; set; } /// /// 7 day price change percentage /// - [JsonProperty("price_change_percentage_7d")] + [JsonPropertyName("price_change_percentage_7d")] public decimal PriceChangePercentage7d { get; set; } /// /// 14 day price change percentage /// - [JsonProperty("price_change_percentage_14d")] + [JsonPropertyName("price_change_percentage_14d")] public decimal PriceChangePercentage14d { get; set; } /// /// 30 day price change percentage /// - [JsonProperty("price_change_percentage_30d")] + [JsonPropertyName("price_change_percentage_30d")] public decimal PriceChangePercentage30d { get; set; } /// /// 60 day price change percentage /// - [JsonProperty("price_change_percentage_60d")] + [JsonPropertyName("price_change_percentage_60d")] public decimal PriceChangePercentage60d { get; set; } /// /// 200 day price change percentage /// - [JsonProperty("price_change_percentage_200d")] + [JsonPropertyName("price_change_percentage_200d")] public decimal PriceChangePercentage200d { get; set; } /// /// 1 year price change percentage /// - [JsonProperty("price_change_percentage_1y")] + [JsonPropertyName("price_change_percentage_1y")] public decimal PriceChangePercentage1y { get; set; } /// /// 24 hour market cap change /// - [JsonProperty("market_cap_change_24h")] + [JsonPropertyName("market_cap_change_24h")] public decimal? MarketCapChange24h { get; set; } /// /// 24 hour market cap change /// - [JsonProperty("market_cap_change_percentage_24h")] + [JsonPropertyName("market_cap_change_percentage_24h")] public decimal? MarketCapChangePercentage24h { get; set; } /// /// 24h price changes /// - [JsonProperty("price_change_24h_in_currency")] + [JsonPropertyName("price_change_24h_in_currency")] public Dictionary PriceChanges24h { get; set; } = new Dictionary(); /// /// 1h price changes percentages /// - [JsonProperty("price_change_percentage_1h_in_currency")] + [JsonPropertyName("price_change_percentage_1h_in_currency")] public Dictionary PriceChangePerecentages1h { get; set; } = new Dictionary(); /// /// 24h price changes percentages /// - [JsonProperty("price_change_percentage_24h_in_currency")] + [JsonPropertyName("price_change_percentage_24h_in_currency")] public Dictionary PriceChangePerecentages24h { get; set; } = new Dictionary(); /// /// 7d price change percentages /// - [JsonProperty("price_change_percentage_7d_in_currency")] + [JsonPropertyName("price_change_percentage_7d_in_currency")] public Dictionary PriceChangePerecentages7d { get; set; } = new Dictionary(); /// /// 14d price change percentages /// - [JsonProperty("price_change_percentage_14d_in_currency")] + [JsonPropertyName("price_change_percentage_14d_in_currency")] public Dictionary PriceChangePerecentages14d { get; set; } = new Dictionary(); /// /// 30d price change percentages /// - [JsonProperty("price_change_percentage_30d_in_currency")] + [JsonPropertyName("price_change_percentage_30d_in_currency")] public Dictionary PriceChangePerecentages30d { get; set; } = new Dictionary(); /// /// 60d price change percentages /// - [JsonProperty("price_change_percentage_60d_in_currency")] + [JsonPropertyName("price_change_percentage_60d_in_currency")] public Dictionary PriceChangePerecentages60d { get; set; } = new Dictionary(); /// /// 200d price change percentages /// - [JsonProperty("price_change_percentage_200d_in_currency")] + [JsonPropertyName("price_change_percentage_200d_in_currency")] public Dictionary PriceChangePerecentages200d { get; set; } = new Dictionary(); /// /// 1y price change percentages /// - [JsonProperty("price_change_percentage_1y_in_currency")] + [JsonPropertyName("price_change_percentage_1y_in_currency")] public Dictionary PriceChangePerecentages1y { get; set; } = new Dictionary(); /// /// 24h market cap changes /// - [JsonProperty("market_cap_change_24h_in_currency")] + [JsonPropertyName("market_cap_change_24h_in_currency")] public Dictionary MarketCapChanges24h { get; set; } = new Dictionary(); /// /// 24h market cap change percentages /// - [JsonProperty("market_cap_change_percentage_24h_in_currency")] + [JsonPropertyName("market_cap_change_percentage_24h_in_currency")] public Dictionary MarketCapChangePercentages24h { get; set; } = new Dictionary(); /// /// Total supply /// - [JsonProperty("total_supply")] + [JsonPropertyName("total_supply")] public decimal? TotalSupply { get; set; } /// /// Max supply /// - [JsonProperty("max_supply")] + [JsonPropertyName("max_supply")] public decimal? MaxSupply { get; set; } /// /// Circulating supply /// - [JsonProperty("circulating_supply")] + [JsonPropertyName("circulating_supply")] public decimal? CirculatingSupply { get; set; } /// /// Last updated timestamp /// - [JsonProperty("last_updated")] + [JsonPropertyName("last_updated")] [JsonConverter(typeof(DateTimeConverter))] public DateTime? LastUpdated { get; set; } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoMarketDataCategory.cs b/CoinGecko.Net/Objects/Models/CoinGeckoMarketDataCategory.cs index 2e851c4..5aa5b73 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoMarketDataCategory.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoMarketDataCategory.cs @@ -1,7 +1,6 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -13,40 +12,43 @@ public record CoinGeckoMarketDataCategory /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Total market cap /// - [JsonProperty("market_cap")] - public decimal MarketCap { get; set; } + [JsonPropertyName("market_cap")] + public decimal? MarketCap { get; set; } /// /// Market cap change last 24h /// - [JsonProperty("market_cap_change_24h")] - public decimal MarketCapChange24h { get; set; } + [JsonPropertyName("market_cap_change_24h")] + public decimal? MarketCapChange24h { get; set; } /// /// Content /// + [JsonPropertyName("content")] public string Content { get; set; } = string.Empty; /// /// Top 3 coins /// - [JsonProperty("top_3_coins")] + [JsonPropertyName("top_3_coins")] public IEnumerable Top3Coins { get; set; } = Array.Empty(); /// /// Volume last 24h /// - [JsonProperty("volume_24h")] - public decimal Volume24h { get; set; } + [JsonPropertyName("volume_24h")] + public decimal? Volume24h { get; set; } /// /// Last updated /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("updated_at")] - public DateTime LastUpdated { get; set; } + [JsonPropertyName("updated_at")] + public DateTime? LastUpdated { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoNft.cs b/CoinGecko.Net/Objects/Models/CoinGeckoNft.cs index d879d52..4461644 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoNft.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoNft.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,24 +10,27 @@ public record CoinGeckoNft /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Contract address /// - [JsonProperty("contract_address")] + [JsonPropertyName("contract_address")] public string ContractAddress { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Asset platform id /// - [JsonProperty("asset_platform_id")] + [JsonPropertyName("asset_platform_id")] public string AssetPlatformId { get; set; } = string.Empty; /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoNftDetails.cs b/CoinGecko.Net/Objects/Models/CoinGeckoNftDetails.cs index 10e5c1e..40a42c1 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoNftDetails.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoNftDetails.cs @@ -1,4 +1,7 @@ -using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,70 +13,183 @@ public record CoinGeckoNftDetails /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Contract address /// - [JsonProperty("contract_address")] + [JsonPropertyName("contract_address")] public string ContractAddress { get; set; } = string.Empty; /// /// Platform id /// - [JsonProperty("asset_platform_id")] + [JsonPropertyName("asset_platform_id")] public string AssetPlatformId { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// /// Images /// - [JsonProperty("image")] + [JsonPropertyName("image")] public CoinGeckoImages? Images { get; set; } /// + /// Banner image + /// + [JsonPropertyName("banner_image")] + public string? BannerImage { get; set; } + /// /// Description /// + [JsonPropertyName("description")] public string Description { get; set; } = string.Empty; /// /// Native currency /// - [JsonProperty("native_currency")] + [JsonPropertyName("native_currency")] public string NativeCurrency { get; set; } = string.Empty; /// + /// Native currency symbol + /// + [JsonPropertyName("native_currency_symbol")] + public string NativeCurrencySymbol { get; set; } = string.Empty; + /// /// Floor price 24h change percentage in USD /// - [JsonProperty("floor_price_in_usd_24h_percentage_change")] + [JsonPropertyName("floor_price_in_usd_24h_percentage_change")] public decimal? FloorPriceInUsd24hPercentageChange { get; set; } /// /// Number of unique addresses /// - [JsonProperty("number_of_unique_addresses")] - public int? NumberOfUniqueAddresses { get; set; } + [JsonPropertyName("number_of_unique_addresses")] + public decimal? NumberOfUniqueAddresses { get; set; } /// /// Number of unique address 24h change percentage /// - [JsonProperty("number_of_unique_addresses_24h_percentage_change")] - public int? NumberOfUniqueAddresses24hChangePercentage { get; set; } + [JsonPropertyName("number_of_unique_addresses_24h_percentage_change")] + public decimal? NumberOfUniqueAddresses24hChangePercentage { get; set; } + /// + /// Volume 24h change percentage in USD + /// + [JsonPropertyName("volume_in_usd_24h_percentage_change")] + public decimal? VolumeInUsd24hPercentageChange { get; set; } /// /// Total supply /// - [JsonProperty("total_supply")] - public int TotalSupply { get; set; } + [JsonPropertyName("total_supply")] + public decimal TotalSupply { get; set; } /// /// Floor price /// - [JsonProperty("floor_price")] + [JsonPropertyName("floor_price")] public CoinGeckoNftValue? FloorPrice { get; set; } /// /// Floor price /// - [JsonProperty("market_cap")] + [JsonPropertyName("market_cap")] public CoinGeckoNftValue? MarketCap { get; set; } /// /// Floor price /// - [JsonProperty("volume_24h")] + [JsonPropertyName("volume_24h")] public CoinGeckoNftValue? Volume24h { get; set; } + /// + /// Floor price 24h percentage change + /// + [JsonPropertyName("floor_price_24h_percentage_change")] + public CoinGeckoNftValue? FloorPrice24hPercentageChange { get; set; } + /// + /// Market cap 24h percentage change + /// + [JsonPropertyName("market_cap_24h_percentage_change")] + public CoinGeckoNftValue? MarketCap24hPercentageChange { get; set; } + /// + /// Volume 24h percentage change + /// + [JsonPropertyName("volume_24h_percentage_change")] + public CoinGeckoNftValue? Volume24hPercentageChange { get; set; } + /// + /// One day sales + /// + [JsonPropertyName("one_day_sales")] + public decimal OneDaySales { get; set; } + /// + /// One day sales percentage change + /// + [JsonPropertyName("one_day_sales_24h_percentage_change")] + public decimal OneDaySales24hPercentageChange { get; set; } + /// + /// One day average sales price + /// + [JsonPropertyName("one_day_average_sale_price")] + public decimal OneDayAverageSalesPrice { get; set; } + /// + /// One day sales percentage change + /// + [JsonPropertyName("one_day_average_sale_price_24h_percentage_change")] + public decimal OneDayAverageSalesPrice24hPercentageChange { get; set; } + /// + /// Floor price 7 day percentage change + /// + [JsonPropertyName("floor_price_7d_percentage_change")] + public CoinGeckoNftValue? FloorPrice7dPercentageChange { get; set; } + /// + /// Floor price 14 day percentage change + /// + [JsonPropertyName("floor_price_14d_percentage_change")] + public CoinGeckoNftValue? FloorPrice14dPercentageChange { get; set; } + /// + /// Floor price 30 day percentage change + /// + [JsonPropertyName("floor_price_30d_percentage_change")] + public CoinGeckoNftValue? FloorPrice30dPercentageChange { get; set; } + /// + /// Floor price 60 day percentage change + /// + [JsonPropertyName("floor_price_60d_percentage_change")] + public CoinGeckoNftValue? FloorPrice60dPercentageChange { get; set; } + /// + /// Floor price 1 year percentage change + /// + [JsonPropertyName("floor_price_1y_percentage_change")] + public CoinGeckoNftValue? FloorPrice1yPercentageChange { get; set; } + /// + /// Nft collection user favorites count + /// + [JsonPropertyName("user_favorites_count")] + public int UserFavoritesCount { get; set; } + /// + /// All time high price + /// + [JsonPropertyName("ath")] + public CoinGeckoNftValue? AllTimeHigh { get; set; } + /// + /// All time high price change percentage + /// + [JsonPropertyName("ath_change_percentage")] + public CoinGeckoNftValue? AllTimeHighChangePercentage { get; set; } + /// + /// All time high price date + /// + [JsonPropertyName("ath_date")] + public CoinGeckoNftDate? AllTimeHighDate { get; set; } + /// + /// Explorer links + /// + [JsonPropertyName("links")] + public Dictionary Links { get; set; } = new Dictionary(); + /// + /// Explorer links + /// + [JsonPropertyName("explorers")] + public IEnumerable Exlorers { get; set; } = Array.Empty(); } /// @@ -84,11 +200,46 @@ public record CoinGeckoNftValue /// /// In native currency /// - [JsonProperty("native_currency")] + [JsonPropertyName("native_currency")] public decimal? NativeCurrency { get; set; } /// /// In usd /// + [JsonPropertyName("usd")] public decimal? Usd { get; set; } } + + /// + /// Nft value info + /// + public record CoinGeckoNftDate + { + /// + /// In native currency + /// + [JsonPropertyName("native_currency")] + public DateTime? NativeCurrency { get; set; } + /// + /// In usd + /// + [JsonPropertyName("usd")] + public DateTime? Usd { get; set; } + } + + /// + /// Nft value info + /// + public record CoinGeckoNftLink + { + /// + /// Link name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// Link + /// + [JsonPropertyName("link")] + public string Link { get; set; } = string.Empty; + } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoOhlc.cs b/CoinGecko.Net/Objects/Models/CoinGeckoOhlc.cs index dac2452..4f405b8 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoOhlc.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoOhlc.cs @@ -1,8 +1,6 @@ using CryptoExchange.Net.Converters; -using Newtonsoft.Json; using System; -using System.Collections.Generic; -using System.Text; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoPlatform.cs b/CoinGecko.Net/Objects/Models/CoinGeckoPlatform.cs index 2c0edcc..abe86b9 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoPlatform.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoPlatform.cs @@ -1,7 +1,4 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -13,12 +10,12 @@ public record CoinGeckoPlatform /// /// Decimal places /// - [JsonProperty("decimail_places")] + [JsonPropertyName("decimail_places")] public int DecimalPlaces { get; set; } /// /// Address /// - [JsonProperty("contract_address")] + [JsonPropertyName("contract_address")] public string ContractAddress { get; set; } = string.Empty; } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoPublicInterestStats.cs b/CoinGecko.Net/Objects/Models/CoinGeckoPublicInterestStats.cs index 274971a..61c9f5b 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoPublicInterestStats.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoPublicInterestStats.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,12 +10,12 @@ public record CoinGeckoPublicInterestStats /// /// Alexa rank /// - [JsonProperty("alexa_rank")] + [JsonPropertyName("alexa_rank")] public int? AlexaRank { get; set; } /// /// Bing matches /// - [JsonProperty("bing_matches")] + [JsonPropertyName("bing_matches")] public int? BingMatches { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoSearchResult.cs b/CoinGecko.Net/Objects/Models/CoinGeckoSearchResult.cs index d2e98ff..a17e1a9 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoSearchResult.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoSearchResult.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -12,20 +12,28 @@ public record CoinGeckoSearchResult /// /// Assets found /// - [JsonProperty("coins")] + [JsonPropertyName("coins")] public IEnumerable Assets { get; set; } = Array.Empty(); /// /// Exchanges found /// + [JsonPropertyName("exchanges")] public IEnumerable Exchanges { get; set; } = Array.Empty(); /// /// Categories found /// + [JsonPropertyName("categories")] public IEnumerable Categories { get; set; } = Array.Empty(); /// /// Nfts found /// + [JsonPropertyName("nfts")] public IEnumerable Nfts { get; set; } = Array.Empty(); + /// + /// Icos + /// + [JsonPropertyName("icos")] + public IEnumerable Icos { get; set; } = Array.Empty(); } /// @@ -36,34 +44,37 @@ public record CoinGeckoAssetResult /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Api symbol /// - [JsonProperty("api_symbol")] + [JsonPropertyName("api_symbol")] public string? ApiSymbol { get; set; } /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Market cap rank /// - [JsonProperty("market_cap_rank")] + [JsonPropertyName("market_cap_rank")] public int? MarketCapRank { get; set; } /// /// Thumbnail /// - [JsonProperty("thumb")] + [JsonPropertyName("thumb")] public string? ThumbnailImage { get; set; } /// /// Large image /// - [JsonProperty("large")] + [JsonPropertyName("large")] public string? LargeImage { get; set; } } @@ -75,25 +86,27 @@ public record CoinGeckoExchangeResult /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Market type /// - [JsonProperty("market_type")] + [JsonPropertyName("market_type")] public string MarketType { get; set; } = string.Empty; /// /// Thumbnail /// - [JsonProperty("thumb")] + [JsonPropertyName("thumb")] public string? ThumbnailImage { get; set; } /// /// Large image /// - [JsonProperty("large")] + [JsonPropertyName("large")] public string? LargeImage { get; set; } } @@ -105,11 +118,13 @@ public record CoinGeckoCategoryResult /// /// Id /// - public string Id { get; set; } = string.Empty; + [JsonPropertyName("id")] + public int Id { get; set; } /// /// Name /// - public string Name { get; set; } = string.Empty; + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; } /// @@ -120,19 +135,22 @@ public record CoinGeckoNftResult /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Thumbnail /// - [JsonProperty("thumb")] + [JsonPropertyName("thumb")] public string? ThumbnailImage { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoStatusUpdate.cs b/CoinGecko.Net/Objects/Models/CoinGeckoStatusUpdate.cs index 40d9bed..c27f649 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoStatusUpdate.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoStatusUpdate.cs @@ -1,6 +1,5 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; +using System; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -12,33 +11,38 @@ public record CoinGeckoStatusUpdate /// /// Description /// + [JsonPropertyName("description")] public string Description { get; set; } = string.Empty; /// /// Category /// + [JsonPropertyName("category")] public string Category { get; set; } = string.Empty; /// /// Created time /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("created_at")] + [JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; } /// /// User name /// + [JsonPropertyName("user")] public string User { get; set; } = string.Empty; /// /// User title /// - [JsonProperty("user_title")] + [JsonPropertyName("user_title")] public string UserTitle { get; set; } = string.Empty; /// /// Is pinned /// + [JsonPropertyName("pin")] public bool Pin { get; set; } /// /// Project info /// + [JsonPropertyName("project")] public CoinGeckoProject? Project { get; set; } } @@ -50,18 +54,22 @@ public record CoinGeckoProject /// /// Type /// + [JsonPropertyName("type")] public string Type { get; set; } = string.Empty; /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Images /// + [JsonPropertyName("image")] public CoinGeckoImages? Image { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoTicker.cs b/CoinGecko.Net/Objects/Models/CoinGeckoTicker.cs index 8caa805..391bac9 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoTicker.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoTicker.cs @@ -1,8 +1,7 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Text; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -14,89 +13,95 @@ public record CoinGeckoTicker /// /// Base asset /// + [JsonPropertyName("base")] public string Base { get; set; } = string.Empty; /// /// Quote asset /// + [JsonPropertyName("target")] public string Target { get; set; } = string.Empty; /// - /// Market info + /// Exchange info /// - public CoinGeckoAssetMarket? Market { get; set; } + [JsonPropertyName("market")] + public CoinGeckoAssetExchange? Exchange { get; set; } /// /// Last price /// + [JsonPropertyName("last")] public decimal? Last { get; set; } /// /// Trade volume /// + [JsonPropertyName("volume")] public decimal? Volume { get; set; } /// /// Converted last /// - [JsonProperty("converted_last")] + [JsonPropertyName("converted_last")] public Dictionary ConvertedLast { get; set; } = new Dictionary(); /// /// Converted volume /// - [JsonProperty("converted_volume")] + [JsonPropertyName("converted_volume")] public Dictionary ConvertedVolume { get; set; } = new Dictionary(); /// /// Trust score /// - [JsonProperty("trust_score")] + [JsonPropertyName("trust_score")] public string? TrustScore { get; set; } /// /// Difference in percentage between best bid and ask /// - [JsonProperty("bid_ask_spread_percentage")] + [JsonPropertyName("bid_ask_spread_percentage")] public decimal? BidAskSpreadPercentage { get; set; } /// /// Timestamp /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("timestamp")] public DateTime? Timestamp { get; set; } /// /// Last trade timestamp /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("last_traded_at")] + [JsonPropertyName("last_traded_at")] public DateTime? LastTradedAt { get; set; } /// /// Last fetch timestamp /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("last_fetch_at")] + [JsonPropertyName("last_fetch_at")] public DateTime? LastFetchAt { get; set; } /// /// Is anomaly /// - [JsonProperty("is_anomaly")] + [JsonPropertyName("is_anomaly")] public bool IsAnomaly { get; set; } /// /// Is stale /// - [JsonProperty("is_stale")] + [JsonPropertyName("is_stale")] public bool IsStale { get; set; } /// /// Trade url /// - [JsonProperty("trade_url")] + [JsonPropertyName("trade_url")] public string? TradeUrl { get; set; } /// /// Token info url /// - [JsonProperty("token_info_url")] + [JsonPropertyName("token_info_url")] public string? TokenInfoUrl { get; set; } /// /// Coin id /// - [JsonProperty("coin_id")] + [JsonPropertyName("coin_id")] public string? CoinId { get; set; } /// /// Target coin id /// - [JsonProperty("target_coin_id")] + [JsonPropertyName("target_coin_id")] public string? TargetCoinId { get; set; } } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoTickers.cs b/CoinGecko.Net/Objects/Models/CoinGeckoTickers.cs index e8f0128..5da1f1b 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoTickers.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoTickers.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -10,12 +11,14 @@ namespace CoinGecko.Net.Objects.Models public record CoinGeckoTickers { /// - /// Coin name + /// Asset name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Tickers /// + [JsonPropertyName("tickers")] public IEnumerable Tickers { get; set; } = Array.Empty(); } } diff --git a/CoinGecko.Net/Objects/Models/CoinGeckoTrendingSearch.cs b/CoinGecko.Net/Objects/Models/CoinGeckoTrendingSearch.cs index aeb61c1..0a4cea4 100644 --- a/CoinGecko.Net/Objects/Models/CoinGeckoTrendingSearch.cs +++ b/CoinGecko.Net/Objects/Models/CoinGeckoTrendingSearch.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace CoinGecko.Net.Objects.Models { @@ -12,8 +12,18 @@ public record CoinGeckoTrendingSearch /// /// Trending assets /// - [JsonProperty("coins")] + [JsonPropertyName("coins")] public IEnumerable> Assets { get; set; } = Array.Empty>(); + /// + /// Trending NFTs + /// + [JsonPropertyName("nfts")] + public IEnumerable Nfts { get; set; } = Array.Empty(); + /// + /// Trending Categories + /// + [JsonPropertyName("categories")] + public IEnumerable Categories { get; set; } = Array.Empty(); } /// @@ -24,55 +34,220 @@ public record CoinGeckoTrendingAsset /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Asset id /// - [JsonProperty("coin_id")] - public string AssetId { get; set; } = string.Empty; + [JsonPropertyName("coin_id")] + public int AssetId { get; set; } /// /// Name /// + [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Market cap rank /// - [JsonProperty("market_cap_rank")] + [JsonPropertyName("market_cap_rank")] public int? MarketCapRank { get; set; } /// /// Thumbnail image /// - [JsonProperty("thumb")] + [JsonPropertyName("thumb")] public string? ThumbnailImage { get; set; } /// /// Small image /// - [JsonProperty("small")] + [JsonPropertyName("small")] public string? SmallImage { get; set; } /// /// Large image /// - [JsonProperty("large")] + [JsonPropertyName("large")] public string? LargeImage { get; set; } /// /// Slug /// + [JsonPropertyName("slug")] public string? Slug { get; set; } /// /// Btc price /// - [JsonProperty("price_btc")] + [JsonPropertyName("price_btc")] public decimal? PriceBtc { get; set; } /// /// Score /// + [JsonPropertyName("score")] public int Score { get; set; } } + /// + /// Nft + /// + public record CoinGeckoTrendingNft + { + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Thumb image + /// + [JsonPropertyName("thumb")] + public string Thumb { get; set; } = string.Empty; + /// + /// Nft contract id + /// + [JsonPropertyName("nft_contract_id")] + public int NftContractId { get; set; } + /// + /// Native asset symbol + /// + [JsonPropertyName("native_currency_symbol")] + public string NativeAssetSymbol { get; set; } = string.Empty; + /// + /// Floor price in native asset + /// + [JsonPropertyName("floor_price_in_native_currency")] + public decimal FloorPriceInNativeAsset { get; set; } + /// + /// Floor price 24h percentage change + /// + [JsonPropertyName("floor_price_24h_percentage_change")] + public decimal FloorPrice24hPercentageChange { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public CoinGeckoTrendingNftData Data { get; set; } = null!; + } + + /// + /// Nft data + /// + public record CoinGeckoTrendingNftData + { + /// + /// Floor price + /// + [JsonPropertyName("floor_price")] + public string FloorPrice { get; set; } = string.Empty; + /// + /// Floor price in usd 24h percentage change + /// + [JsonPropertyName("floor_price_in_usd_24h_percentage_change")] + public decimal FloorPriceInUsd24hPercentageChange { get; set; } + /// + /// Volume 24h + /// + [JsonPropertyName("h24_volume")] + public string H24Volume { get; set; } = string.Empty; + /// + /// Average sale price 24h + /// + [JsonPropertyName("h24_average_sale_price")] + public string H24AverageSalePrice { get; set; } = string.Empty; + /// + /// Sparkline + /// + [JsonPropertyName("sparkline")] + public string Sparkline { get; set; } = string.Empty; + } + + /// + /// Trending category + /// + public record CoinGeckoTrendingCategory + { + /// + /// Id + /// + [JsonPropertyName("id")] + public int Id { get; set; } + /// + /// Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// Market cap 1 hour change + /// + [JsonPropertyName("market_cap_1h_change")] + public decimal MarketCap1hChange { get; set; } + /// + /// Slug + /// + [JsonPropertyName("slug")] + public string Slug { get; set; } = string.Empty; + /// + /// Coins count + /// + [JsonPropertyName("coins_count")] + public decimal CoinsCount { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public CoinGeckoTrendingCategoryData Data { get; set; } = null!; + } + + /// + /// Category date + /// + public record CoinGeckoTrendingCategoryData + { + /// + /// Market cap + /// + [JsonPropertyName("market_cap")] + public decimal MarketCap { get; set; } + /// + /// Market cap btc + /// + [JsonPropertyName("market_cap_btc")] + public decimal MarketCapBtc { get; set; } + /// + /// Total volume + /// + [JsonPropertyName("total_volume")] + public decimal TotalVolume { get; set; } + /// + /// Total volume btc + /// + [JsonPropertyName("total_volume_btc")] + public decimal TotalVolumeBtc { get; set; } + /// + /// Market cap change percentage24h + /// + [JsonPropertyName("market_cap_change_percentage_24h")] + public Dictionary MarketCapChangePercentage24h { get; set; } = null!; + /// + /// Sparkline + /// + [JsonPropertyName("sparkline")] + public string Sparkline { get; set; } = string.Empty; + } + + + /// /// Item /// @@ -82,6 +257,7 @@ public record ItemWrapper /// /// Item info /// + [JsonPropertyName("item")] public T Item { get; set; } = default!; } } diff --git a/CoinGecko.Net/Objects/Options/CoinGeckoRestOptions.cs b/CoinGecko.Net/Objects/Options/CoinGeckoRestOptions.cs index 85a499a..fc0c11b 100644 --- a/CoinGecko.Net/Objects/Options/CoinGeckoRestOptions.cs +++ b/CoinGecko.Net/Objects/Options/CoinGeckoRestOptions.cs @@ -5,7 +5,7 @@ namespace CoinGecko.Net.Objects.Options /// /// CoinGecko Rest API options /// - public class CoinGeckoRestOptions : RestExchangeOptions + public class CoinGeckoRestOptions : RestExchangeOptions { /// /// Default options for the CoinGecko client diff --git a/CoinGecko.Net/Usings.cs b/CoinGecko.Net/Usings.cs index 7ef0a6f..eee8684 100644 --- a/CoinGecko.Net/Usings.cs +++ b/CoinGecko.Net/Usings.cs @@ -1 +1 @@ -global using CryptoExchange.Net.Converters.JsonNet; \ No newline at end of file +global using CryptoExchange.Net.Converters.SystemTextJson; \ No newline at end of file diff --git a/Examples/CoinGecko.Examples.Api/CoinGecko.Examples.Api.csproj b/Examples/CoinGecko.Examples.Api/CoinGecko.Examples.Api.csproj index f7d60e3..59eda18 100644 --- a/Examples/CoinGecko.Examples.Api/CoinGecko.Examples.Api.csproj +++ b/Examples/CoinGecko.Examples.Api/CoinGecko.Examples.Api.csproj @@ -1,16 +1,19 @@ - net7.0 + net8.0 enable enable true - + + + + diff --git a/Examples/CoinGecko.Examples.Api/Program.cs b/Examples/CoinGecko.Examples.Api/Program.cs index 0beea8d..bf3845a 100644 --- a/Examples/CoinGecko.Examples.Api/Program.cs +++ b/Examples/CoinGecko.Examples.Api/Program.cs @@ -1,5 +1,4 @@ using CoinGecko.Net.Interfaces; -using CryptoExchange.Net.Authentication; using Microsoft.AspNetCore.Mvc; var builder = WebApplication.CreateBuilder(args); @@ -14,10 +13,7 @@ /* builder.Services.AddCoinGecko(restOptions => { - restOptions.RequestTimeout = TimeSpan.FromSeconds(5); -}, socketOptions => -{ - socketOptions.ApiCredentials = new ApiCredentials("", ""); + restOptions.ApiCredentials = new CoinGeckoApiCredentials(""); }); */ diff --git a/Examples/CoinGecko.Examples.Console/CoinGecko.Examples.Console.csproj b/Examples/CoinGecko.Examples.Console/CoinGecko.Examples.Console.csproj index dd2f30c..16bdbcf 100644 --- a/Examples/CoinGecko.Examples.Console/CoinGecko.Examples.Console.csproj +++ b/Examples/CoinGecko.Examples.Console/CoinGecko.Examples.Console.csproj @@ -2,13 +2,13 @@ Exe - net7.0 + net8.0 enable enable - + diff --git a/Examples/Examples.sln b/Examples/Examples.sln index ad35521..3e6049b 100644 --- a/Examples/Examples.sln +++ b/Examples/Examples.sln @@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34330.188 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoinGecko.Examples.Console", "CoinGecko.Examples.Console\CoinGecko.Examples.Console.csproj", "{72F29164-3C3E-4EB1-9C2B-BC9BA5FCD5AA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoinGecko.Examples.Console", "CoinGecko.Examples.Console\CoinGecko.Examples.Console.csproj", "{72F29164-3C3E-4EB1-9C2B-BC9BA5FCD5AA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoinGecko.Examples.Api", "CoinGecko.Examples.Api\CoinGecko.Examples.Api.csproj", "{2E6BB5F7-6F04-4122-8CB6-6B89E822040A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoinGecko.Examples.Api", "CoinGecko.Examples.Api\CoinGecko.Examples.Api.csproj", "{2E6BB5F7-6F04-4122-8CB6-6B89E822040A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoinGecko.Net", "..\CoinGecko.Net\CoinGecko.Net.csproj", "{746FABEF-5160-499C-ACE4-9B1C40E38B7C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +23,10 @@ Global {2E6BB5F7-6F04-4122-8CB6-6B89E822040A}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E6BB5F7-6F04-4122-8CB6-6B89E822040A}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E6BB5F7-6F04-4122-8CB6-6B89E822040A}.Release|Any CPU.Build.0 = Release|Any CPU + {746FABEF-5160-499C-ACE4-9B1C40E38B7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {746FABEF-5160-499C-ACE4-9B1C40E38B7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {746FABEF-5160-499C-ACE4-9B1C40E38B7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {746FABEF-5160-499C-ACE4-9B1C40E38B7C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/README.md b/README.md index 075fcf5..464cf43 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,10 @@ The NuGet package files are added along side the source with the latest GitHub r *REST Endpoints* ```csharp -// Get the ETH/USDT ticker via rest request -var restClient = new CoinGeckoRestClient(); +// Get the ETH price via rest request var tickerResult = await restClient.Api.GetMarketsAsync("USD"); -var lastPrice = tickerResult.Data.First().CurrentPrice; +var lastPrice = tickerResult.Data.Single(x => x.Name == "Ethereum").CurrentPrice; +Console.ReadLine(); ``` For information on the clients, dependency injection, response processing and more see the [CoinGecko.Net documentation](https://jkorf.github.io/CoinGecko.Net), [CryptoExchange.Net documentation](https://jkorf.github.io/CryptoExchange.Net), or have a look at the examples [here](https://github.com/JKorf/CoinGecko.Net/tree/master/Examples) or [here](https://github.com/JKorf/CryptoExchange.Net/tree/master/Examples). @@ -73,24 +73,26 @@ CryptoExchange.Net also allows for [easy access to different exchange API's](htt 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 +Note that only the public endpoints are supported, but setting API key is supported and the correct API urls will be selected. ### V3 API |API|Supported|Location| |--|--:|--| |Ping|✓|`restClient.Api`| +|Key|✓|`restClient.Api`| |Simple|✓|`restClient.Api`| |Coins|✓|`restClient.Api`| -|Contract|X|| +|Contract|✓|`restClient.Api`| |Asset Platforms|✓|`restClient.Api`| |Categories|✓|`restClient.Api`| |Exchanges|✓|`restClient.Api`| |Derivatives|✓|`restClient.Api`| -|Nfts|X|| +|Nfts|✓|`restClient.Api`| |Exchange Rates|✓|`restClient.Api`| |Search|✓|`restClient.Api`| |Trending|✓|`restClient.Api`| |Global|✓|`restClient.Api`| -|Companies|X|| +|Companies|✓|`restClient.Api`| ## Support the project Any support is greatly appreciated. diff --git a/docs/index.html b/docs/index.html index c828ffe..efd1e99 100644 --- a/docs/index.html +++ b/docs/index.html @@ -191,27 +191,23 @@

API Access


- - +
+

Examples

+ + Get Asset info
+

Get details on an asset

+
var coinGeckoClient = new CoinGeckoRestClient();
+
+var result = await restClient.Api.GetAssetDetailsAsync("ethereum");
+
+ Get tickers
+

Get tickers for an asset

+
var coinGeckoClient = new CoinGeckoRestClient();
+
+var result = await restClient.Api.GetTickersAsync("ethereum");
+
+
+