* 빗썸 코인정보 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 데이터

더보기

Windows API 에 대한 내용이 있는 사이트

확장 툴로도 제공한다.

https://www.pinvoke.net/

'C#' 카테고리의 다른 글

(C#) 그림판 실행하기  (0) 2018.03.22
(C#) png 파일을 ico 파일로 만들기  (0) 2018.03.21
Win API  (0) 2018.03.18
FileSystemWatcher (폴더 모니터링 기능)  (3) 2018.03.15
(C#) 나만의 커서(Cursor) 만들기  (0) 2018.03.06
(C#) 방화벽 뚫기 코드  (0) 2018.03.03

+ Recent posts