728x90
728x170

 

* 빗썸 코인정보 Class

    public class CoinInfo

    {

        public string CoinType       { get; set; }

        public DateTime CoinTime     { get; set; }

        public string Status         { get; set; }

        public int OpeningPrice     { get; set; }

        public int ClosingPrice     { get; set; }

        public int MinPrice         { get; set; }

        public int MaxPrice         { get; set; }

        public string AveragePrice { get; set; }

        public string UnitsTraded   { get; set; }

        public string Volume1Day    { get; set; }

        public string Volume7Day    { get; set; }

        public int BuyPrice         { get; set; }

        public int SellPrice        { get; set; }

        public string Date           { get; set; }

    }

 

* 빗썸 데이터 가져오기

 

                //string page = "https://api.bithumb.com/public/ticker/BTC"; // 특정 화폐정보만 가져올때

                string page = "https://api.bithumb.com/public/ticker/ALL";

                HttpClient client = new HttpClient();

                var response = await client.GetAsync(page);

                if (!response.IsSuccessStatusCode) return;

 

                using (HttpContent content = response.Content)

                {

                    string result = await content.ReadAsStringAsync();

                    var o = JsonConvert.DeserializeObject(result);

                    JObject JObj = JObject.Parse(result);

 

                    //BTC,ETH,DASH,LTC,ETC,XRP,BCH,XMR,ZEC,QTUM,BTG,EOS

                    string[] coinTypes = "BTC,ETH,DASH,LTC,ETC,XRP,BCH,XMR,ZEC,QTUM,BTG,EOS".Split(',');

 

                    string status = JObj["status"].ToString();

                    if (status != "0000") return;

 

                    string date = JObj["data"]["date"].ToString();

 

                    // 데이터 가져온 시간입니다.

                    DateTime coinTime = DateTime.Now;

                    List<CoinInfo> coinInfoList = new List<CoinInfo>();

 

                    foreach (string coinType in coinTypes)

                    {

                        CoinInfo coinInfo = new CoinInfo() { CoinType = coinType, Status = status, Date = date, CoinTime = coinTime };

 

                        coinInfo.OpeningPrice = int.Parse(JObj["data"][coinType]["opening_price"].ToString());

                        coinInfo.ClosingPrice = int.Parse(JObj["data"][coinType]["closing_price"].ToString());

                        coinInfo.MinPrice = int.Parse(JObj["data"][coinType]["min_price"].ToString());

                        coinInfo.MaxPrice = int.Parse(JObj["data"][coinType]["max_price"].ToString());

                        coinInfo.AveragePrice = JObj["data"][coinType]["average_price"].ToString();

                        coinInfo.UnitsTraded = JObj["data"][coinType]["units_traded"].ToString();

                        coinInfo.Volume1Day = JObj["data"][coinType]["volume_1day"].ToString();

                        coinInfo.Volume7Day = JObj["data"][coinType]["volume_7day"].ToString();

                        coinInfo.BuyPrice = int.Parse(JObj["data"][coinType]["buy_price"].ToString());

                        coinInfo.SellPrice = int.Parse(JObj["data"][coinType]["sell_price"].ToString());

 

                        coinInfoList.Add(coinInfo);

                    }

                }

 

* 빗썸 예시 데이터 (Json) - 2019-05-21 오후10:45 데이터

728x90
그리드형
Posted by kjun
,