CoinGecko.Net can be configured using Dotnet dependency injection, after which the clients can be injected into your services. It also correctly configures logging and HttpClient usage.
-builder.Services.AddCoinGecko(options => {
- // Options can be configured here
+ // Configure options from config file
+// see https://github.com/JKorf/CryptoExchange.Net/tree/master/Examples/example-config.json for an example
+builder.Services.AddCoinGecko(builder.Configuration.GetSection("CoinGecko"));
+
+// OR
+
+ builder.Services.AddCoinGecko(options => {
+ // Configure options in code
+ options.RequestTimeout = TimeSpan.FromSeconds(10);
});
The ICoinGeckoRestClient
can then be injected.