Develop Ethereum Price Feed Plugin Using .Net Core

In my earlier post Bitcoin Price API, I talked about how to use data feed provided by CoinDesk to implement a .Net Core widget to display latest Bitcoin prices. I was also looking for data feed that would allow to build similar widget for Ethereum prices as well. Unfortunately I could not find any published API that could provide Ethereum price data. Then I ran into web site. I did some digging into their HTTP requests and found that their page is making asyn requests to one of their end points to get Ethereum price data for last 10 minutes. I took that HTTP end point, looked at the response body and adapted to my .Net Core widget project. Feed

On their chart display page, the web site uses following GET requests to get the data.

This GET request returns Json data in following format.


Actual response returns 60 elements in an array for last minutes. You can not request less than that data. It is controlled by range query string parameter. This was enough information for me to build my C# data structure to deserialize the response into proper format.

Ethereum Price

Feed Data Structure

public record EthereumPriceFeedModel : BaseAmgrModel
        public record PriceIndexValue
            public double Rate { get; set; }
            public double UpdateTime { get; set; }
            public double Volume { get; set; }

MVC Controller To Fetch Data

        public async Task<IActionResult> LatestPrice()
                var httpClient = _httpClientFactory.CreateClient(AmgrHttpDefaults.DefaultHttpClientForCompressedResponse);
                var priceFeed = await httpClient.GetStringAsync
                  (string.IsNullOrEmpty(_feedSettings.PriceFeedUrl) ? PriceIndexFeedUrl: _feedSettings.PriceFeedUrl);
                var priceIndexFeed = JsonConvert.DeserializeObject<IList<EthereumPriceFeedModel.PriceIndexValue>>(priceFeed);
                var priceIndexValues = new List<EthereumPriceModel>();
                if (null == priceIndexFeed) return Json(priceIndexValues);
                foreach (var priceIndexValue in priceIndexFeed)
                    priceIndexValues.Add(new EthereumPriceModel
                        UpdatedAtUtc = _dateTimeHelper.ConvertToTimeFromUnixTime
                           (priceIndexValue.UpdateTime).ToString("MMM dd, yyyy HH:mm:ss UTC"),
                        Price = priceIndexValue.Rate

                return Json(priceIndexValues);
            catch (Exception ex)
                await _logger.ErrorAsync($"Error getting latest ethereum price", ex);

            return Json("");

There is a small caveat in this implementation. The website returns data in compressed format. You will need to uncompress it before you can deserialize it. I will show that trick in another post. You can see this Widget in action in my another blog World of Hobby Craft where the prices are displayed in right side column of page layout.




13.4 °C / 56.2 °F

weather conditions Clouds

Monthly Posts

Blog Tags