C# Code Example

The following code using C# to output the PE Ratio in Valuation Ratio for WMT.

First, we will need to download the json.net library from https://json.codeplex.com

                  using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace gurufocus
{
 class Program
 {
 static void Main(string[] args)
 {
  using (var webClient = new System.Net.WebClient())
  {
    String URL = "https://api.gurufocus.com/public/user/{api_token}/stock/WMT/keyratios";
    var json = webClient.DownloadString(URL);
    dynamic array = JsonConvert.DeserializeObject(json);

    var valuation = array.["Valuation Ratio"];

    Console.WriteLine(valuation["PE Ratio"]);
  }

  Console.WriteLine("Press any key to exit.");
  Console.ReadKey();
 }
 }
}

The C# output of PE Ratio:

14.61

Continue to read: Code Examples - Python