How to get market cap of a coin using the CoinGecko C# API?

1.4k Views Asked by At

I narrowed it down to:

ICoinGeckoClient CGClient = CoinGeckoClient.Instance;
var result2 = CGClient.CoinsClient.GetAllCoinsData ();

but I have to provide some arguments to GetAllCoinsData, but they don't make a lot of sense to me and I couldn't find any mention of this function or the original CoinGecko function seems to be a web based API. So not sure how I can pass a symbol, etc and get the coin data back to get the market cap data.

Any ideas on how to achieve this?

1

There are 1 best solutions below

0
On

It seems you should use

        Task<CoinFullDataById> GetAllCoinDataWithId(string id);

Using the propper id.

There is a id/symbol list at: https://docs.google.com/spreadsheets/d/1wTTuxXt8n9q7C4NDXqQpI3wpKu1_5bGVmP9Xz0XGSyU/edit#gid=0

You can also download the code and check the comments/tests at: https://github.com/tosunthex/CoinGecko

        /// <summary>
    /// List all coins with data (name, price, market, developer, community, etc) - paginated by 50
    /// </summary>
    /// <returns></returns>
    Task<IReadOnlyList<CoinFullData>> GetAllCoinsData();

    /// <summary>
    /// List all coins with data (name, price, market, developer, community, etc) - paginated by 50
    /// </summary>
    /// <param name="order">order by</param>
    /// <param name="perPage">Total results per page</param>
    /// <param name="page">Page through results</param>
    /// <param name="localization">Set to false to exclude localized languages in response</param>
    /// <param name="sparkline">Include sparkline 7 days data (true/false) [default: false]</param>
    /// <returns></returns>
    Task<IReadOnlyList<CoinFullData>> GetAllCoinsData(string order, int? perPage, int? page, string localization,
        bool? sparkline);