Esempio n. 1
1
        public static List<CoinInformation> GetCoinInformation(string userAgent = "",
            BaseCoin profitabilityBasis = BaseCoin.Bitcoin)
        {
            WebClient client = new WebClient();
            if (!string.IsNullOrEmpty(userAgent))
                client.Headers.Add("user-agent", userAgent);

            string apiUrl = GetApiUrl(profitabilityBasis);

            string jsonString = client.DownloadString(apiUrl);
            JArray jsonArray = JArray.Parse(jsonString);

            List<CoinInformation> result = new List<CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                if (coinInformation.Difficulty > 0)
                    //only add coins with valid info since the user may be basing
                    //strategies on Difficulty
                    result.Add(coinInformation);
            }

            return result;
        }
Esempio n. 2
0
        public static List <CoinInformation> GetCoinInformation(string userAgent            = "",
                                                                BaseCoin profitabilityBasis = BaseCoin.Bitcoin)
        {
            WebClient client = new WebClient();

            if (!string.IsNullOrEmpty(userAgent))
            {
                client.Headers.Add("user-agent", userAgent);
            }

            string apiUrl = "http://www.coinchoose.com/api.php";

            if (profitabilityBasis == BaseCoin.Litecoin)
            {
                apiUrl = apiUrl + "?base=LTC";
            }

            string jsonString = client.DownloadString(apiUrl);
            JArray jsonArray  = JArray.Parse(jsonString);

            List <CoinInformation> result = new List <CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                result.Add(coinInformation);
            }

            return(result);
        }
Esempio n. 3
0
        public static List<CoinInformation> GetCoinInformation(string userAgent = "")
        {
            WebClient client = new WebClient();
            if (!string.IsNullOrEmpty(userAgent))
                client.Headers.Add("user-agent", userAgent);

            string jsonString = client.DownloadString("http://www.coinchoose.com/api.php");
            JArray jsonArray = JArray.Parse(jsonString);

            List<CoinInformation> result = new List<CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                result.Add(coinInformation);
            }

            return result;
        }
Esempio n. 4
0
        public static List <CoinInformation> GetCoinInformation(string userAgent = "")
        {
            WebClient client = new WebClient();

            if (!string.IsNullOrEmpty(userAgent))
            {
                client.Headers.Add("user-agent", userAgent);
            }

            string jsonString = client.DownloadString("http://www.coinchoose.com/api.php");
            JArray jsonArray  = JArray.Parse(jsonString);

            List <CoinInformation> result = new List <CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                result.Add(coinInformation);
            }

            return(result);
        }