Free API to get Gold and Silver rates as per market in ASP.Net

Last Reply on Jan 18, 2013 04:17 AM By Mudassar

Posted on Jan 17, 2013 05:52 AM

hello sir i wnt API(Free/Paid) for Gold, Silver rate which gng to b increase or decrease as per share market .....

You are viewing reply posted by: Mudassar on Jan 18, 2013 04:17 AM.
Posted on Jan 18, 2013 04:17 AM

After lot of searching I managed to find one free international API that for Gold in USD

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        string url = "http://www.quandl.com/api/v1/datasets/BUNDESBANK/BBK01_WT5511.xml??utf8=%E2%9C%93&trim_start={0}&trim_end={1}&collapse=daily&transformation=&commit=Refine";
        DateTime today = DateTime.Now;
        url = string.Format(url, today.AddDays(-1).ToString("yyyy-MM-dd"), today.AddDays(-1).ToString("yyyy-MM-dd"));
        using (System.Net.WebClient client = new System.Net.WebClient())
        {
            string xml = client.DownloadString(url);
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(xml);
            string rate = doc.SelectNodes("/dataset/data/datum/datum")[1].InnerText;
        }
}