CoinMarketCapDotNet 2.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CoinMarketCapDotNet --version 2.3.0
                    
NuGet\Install-Package CoinMarketCapDotNet -Version 2.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoinMarketCapDotNet" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoinMarketCapDotNet" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="CoinMarketCapDotNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoinMarketCapDotNet --version 2.3.0
                    
#r "nuget: CoinMarketCapDotNet, 2.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CoinMarketCapDotNet@2.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoinMarketCapDotNet&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=CoinMarketCapDotNet&version=2.3.0
                    
Install as a Cake Tool

CoinMarketCapDotNet

NuGet Downloads License

CoinMarketCapDotNet is a C# wrapper for the CoinMarketCap API, providing convenient access to cryptocurrency market data.

Migrating from v1?

See MIGRATION-V1-TO-V2.md for the full v1 → v2 migration guide.

Installation

You can install CoinMarketCapDotNet via NuGet Package Manager or by using the .NET CLI:

NuGet Package Manager

Search for CoinMarketCapDotNet in the NuGet Package Manager UI or run the following command in the Package Manager Console:

Install-Package CoinMarketCapDotNet

.NET CLI

Run the following command in your project directory:

dotnet add package CoinMarketCapDotNet

Package Manager

Run the following command:

NuGet\Install-Package CoinMarketCapDotNet

v2 multi-targets netstandard2.0 and net8.0. On .NET 8 the package has zero runtime dependencies; on netstandard2.0 it brings only System.Text.Json 8.x.

Usage

Quick start

using CoinMarketCapDotNet.Api;

var api = new CoinMarketCapAPI("YOUR_API_KEY");
var data = await api.Cryptocurrency.GetMapAsync();

To use sandbox mode:

var api = new CoinMarketCapAPI("YOUR_API_KEY", useSandbox: true);
using CoinMarketCapDotNet.Api;
using CoinMarketCapDotNet.Configuration;

var api = new CoinMarketCapAPI(new CoinMarketCapOptions
{
    ApiKey = "YOUR_API_KEY",
    UseSandbox = false,
    Timeout = TimeSpan.FromSeconds(30)
});

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
var data = await api.Cryptocurrency.GetMapAsync(cancellationToken: cts.Token);

Error handling

using CoinMarketCapDotNet.Models.Exceptions;

try
{
    var data = await api.Cryptocurrency.GetMapAsync();
}
catch (CoinMarketCapRateLimitException)  { /* back off */ }
catch (CoinMarketCapAuthException)       { /* check your API key */ }
catch (CoinMarketCapException ex)
{
    // Catch-all preserves ex.StatusCode, ex.ErrorCode, ex.CmcErrorMessage
}

CoinMarketCapAPI

Endpoints

  • CryptocurrencyEndpoint: Provides endpoints related to cryptocurrencies.
  • FiatEndpoint: Provides endpoints related to fiat currencies.
  • ExchangeEndpoint: Provides endpoints related to exchanges.
  • GlobalMetricsEndpoint: Provides endpoints related to global market metrics.
  • ToolsEndpoint: Provides miscellaneous tools and utilities.
  • BlockchainEndpoint: Provides endpoints related to blockchain statistics.
  • KeyEndpoint: Provides endpoints related to API keys.
  • ContentEndpoint: Provides endpoints related to content (news, articles, etc.).
  • CommunityEndpoint: Provides endpoints related to the community.

CryptocurrencyEndpoint

Methods

  • GetAirdropAsync: Retrieves airdrop details asynchronously.
  • GetAirdropsAsync: Retrieves a list of airdrops asynchronously.
  • GetCategoriesAsync: Retrieves a list of cryptocurrency categories asynchronously.
  • GetCategoryAsync: Retrieves category details asynchronously.
  • GetMapAsync: Retrieves a mapping of all cryptocurrencies to unique CoinMarketCap IDs asynchronously.
  • GetInfoAsync: Retrieves cryptocurrency information asynchronously.
  • GetListingLatestAsync: Retrieves the latest cryptocurrency listings asynchronously.
  • GetListingHistoricalAsync: Retrieves historical cryptocurrency listings asynchronously.
  • GetListingNewAsync: Retrieves new cryptocurrency listings asynchronously.
  • GetTrendingGainersLosersAsync: Retrieves trending gainers and losers asynchronously.
  • GetTrendingLatestAsync: Retrieves the latest trending cryptocurrencies asynchronously.
  • GetTrendingMostVisitedAsync: Retrieves the most visited trending cryptocurrencies asynchronously.
  • GetMarketPairsLatestAsync: Retrieves the latest cryptocurrency market pairs asynchronously.
  • GetOHLCVLatestAsync: Retrieves the latest cryptocurrency OHLCV (Open, High, Low, Close, Volume) data asynchronously.
  • GetOHCLVHistoricalAsync: Retrieves historical cryptocurrency OHLCV (Open, High, Low, Close, Volume) data asynchronously.
  • GetPricePerformanceStatsLatestAsync: Retrieves the latest cryptocurrency price performance statistics asynchronously.
  • GetQuotesHistoricalV2Async: Retrieves historical cryptocurrency quotes using V2 endpoint asynchronously.
  • GetQuotesLatestAsync: Retrieves the latest cryptocurrency quotes asynchronously.
  • GetQuotesHistoricalV3Async: Retrieves historical cryptocurrency quotes using V3 endpoint asynchronously.

FiatEndpoint

Methods

  • GetMapAsync: Retrieves a mapping of all fiat currencies to unique CoinMarketCap IDs asynchronously.

ExchangeEndpoint

Methods

  • GetAssetsAsync: Retrieves a list of exchange assets asynchronously.
  • GetInfoAsync: Retrieves exchange information asynchronously.
  • GetMapAsync: Retrieves a mapping of all exchanges to unique CoinMarketCap IDs asynchronously.
  • GetListingLatestAsync: Retrieves the latest exchange listings asynchronously.
  • GetMarketPairsAsync: Retrieves exchange market pairs asynchronously.
  • GetQuotesHistoricalAsync: Retrieves historical exchange quotes asynchronously.
  • GetQuotesLatestAsync: Retrieves the latest exchange quotes asynchronously.

GlobalMetricsEndpoint

Methods

  • GetQuotesHistoricalAsync: Retrieves historical global market metrics quotes asynchronously.
  • GetQuotesLatestAsync: Retrieves the latest global market metrics quotes asynchronously.

ToolsEndpoint

Methods

  • GetPriceConversionAsync: Retrieves price conversion data asynchronously.

BlockchainEndpoint

Methods

  • GetStatisticsLatestAsync: Retrieves the latest blockchain statistics data asynchronously.

KeyEndpoint

Methods

  • GetKeyInfoAsync: Retrieves API key details and usage stats asynchronously.

ContentEndpoint

Methods

  • GetContentLatestAsync: Retrieves the latest crypto-related posts from the CMC Community asynchronously.
  • GetPostCommentsAsync: Retrieves comments of a CMC Community post asynchronously.
  • GetPostLatestAsync: Retrieves the latest crypto-related posts from the CMC Community asynchronously.
  • GetPostTopAsync: Retrieves the top crypto-related posts from the CMC Community asynchronously.

CommunityEndpoint

Methods

  • GetTrendingTokenAsync: Retrieves the latest trending tokens from the CMC Community asynchronously.
  • GetTrendingTopicAsync: Retrieves the latest trending topics from the CMC Community asynchronously.

For example, to get the cryptocurrency map:

var data = await api.Cryptocurrency.GetMapAsync();  // Retrieves a mapping of all cryptocurrencies to unique CoinMarketCap IDs.

Extensions to make life easier

Enum Extensions:

.GetEnumMemberValue(): Example:

CurrencyEnum currency = CurrencyEnum.EUR;
string enumMemberValue = currency.GetEnumMemberValue(); // Should return "USD" you can use this to fetch USD from endpoints.

.GetId(): Example:

CurrencyEnum currency = CurrencyEnum.USD;
int id = currency.GetId(); // You should get the cmc equivalent of EUR id.

.GetSymbol(): Example:

CurrencyEnum currency = CurrencyEnum.TRY; // You should get "TRY"
string symbol = currency.GetSymbol();

.GetCurrencyIds(): Example:

string symbols = "USD,EUR,TRY";
List<int> ids = symbols.GetCurrencyIds(); // Returns the symbol strings as a id list to be used in endpoints.

.GetAllIds(): Example:

List<int> allIds = EnumExtensions.GetAllIds<CategoryEnum>(); // Will return all the ids of a given enum

.GetAllSymbols(): Example:

List<string> enumMemberValues = EnumExtensions.GetAllSymbols<CurrencyEnum>(); // Will return all the symbols of a given enum

Refer to the CoinMarketCap API documentation for more information on available endpoints and their usage.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

MIT License

Release Notes

v2.3.0

  • Expanded the DEX endpoint group with three new sub-groups:
    • api.Dex.Pairs.* (2 endpoints) — GetSpotPairsLatestAsync, GetQuotesLatestAsync for DEX trading pair data.
    • api.Dex.Platform.* (2 endpoints) — GetListAsync, GetDetailAsync for blockchain network metadata.
    • api.Dex.Kline.* (2 endpoints) — GetPointsAsync, GetCandlesAsync for DEX OHLCV chart data.
  • Fully additive release — no breaking changes from v2.2.0.
  • DEX Holders endpoints are deferred to v2.4.0.

v2.2.0

  • Added DEX endpoint group with Token sub-group: 14 new methods under api.Dex.Token.* (trending, batch query, batch price, new list, meme list, gainer/loser, token detail, price, pools, liquidity, transactions, security, search, liquidity change).
  • Added public PostDataAsync<T>(endpoint, body, cancellationToken) transport method on CoinMarketCapAPI for POST endpoints.
  • Refactored shared response handling into a private HandleResponseAsync<T> helper used by both GetDataAsync and PostDataAsync. No behavior changes for existing GET endpoints.
  • Fully additive release — no breaking changes from v2.1.0.
  • DEX Pairs, Holders, Platform, and K-line endpoints are deferred to v2.3.0 / v2.4.0.

v2.1.0

  • Added Fear and Greed Index endpoint group: api.FearAndGreed.GetLatestAsync(), api.FearAndGreed.GetHistoricalAsync(...).
  • Added CMC Index endpoint group with CMC 100 and CMC 20 latest + historical: api.Index.GetCmc100LatestAsync(), api.Index.GetCmc100HistoricalAsync(...), api.Index.GetCmc20LatestAsync(), api.Index.GetCmc20HistoricalAsync(...).
  • Added v3 cryptocurrency methods: GetQuotesLatestV3Async and GetListingLatestV3Async. The existing v1/v2 methods are unchanged.
  • Fully additive release — no breaking changes from v2.0.0.

v2.0.0

  • Multi-targets netstandard2.0 and net8.0.
  • Migrated to System.Text.Json — zero runtime dependencies on .NET 8.
  • Typed exception hierarchy under CoinMarketCapDotNet.Models.Exceptions.
  • CancellationToken on every async method.
  • Options-pattern configuration via CoinMarketCapOptions.
  • Injectable HttpClient for IHttpClientFactory / DI scenarios.
  • Nullable reference types enabled throughout.
  • See MIGRATION-V1-TO-V2.md for upgrade instructions.

For older v1.x release notes, see the GitHub Releases page.

Known Issues

Sandbox results are kind of different than the live ones. Tests that pass when the sandbox is true don't pass on live mode and cause serialization issues. The endpoints are tested on sandbox results. Not all endpoints are available for the free tier.

Unless CoinMarketCap provides an enterprise key I won't be able to make sure everything is on point. Please create an issue if you encounter a problem.

On top of that, the API Docs Response Schema is not always the same as the response we get. I will be sticking with the response schema for now.

Buy me a coffee?

BTC: 1NxUuEQcR4Scw8ge3oto6ykLqBpe9LGikS
ETH: 0x9cda155f73220073a9f024daaa72eb06b5c06c86
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.5.1 102 4/22/2026
2.5.0 95 4/21/2026
2.4.0 101 4/21/2026
2.3.0 99 4/21/2026
2.2.0 97 4/21/2026
2.1.0 95 4/21/2026
2.0.0 96 4/21/2026
1.0.10 967 8/21/2023
1.0.9 277 8/11/2023
1.0.8 278 7/10/2023
1.0.7 299 7/6/2023
1.0.6 268 7/5/2023
1.0.5 304 7/4/2023
1.0.4 291 7/4/2023
1.0.3 285 7/4/2023
1.0.2 287 7/4/2023
1.0.1 298 6/11/2023
1.0.0 292 6/11/2023