Question

I want to show all stock price of NSE and BSE on simple html page.

I got information from google that i can call any web service that is already exist and they will give all information in json form. And then I have to parse that jason code.

Now I want someone to provide me link by which i can call the webservice. And let me know how can i call that web service using jQuery. And how can i parse output json data. If any one can give me sample code then it will be best..

Thank you so much for helping me.. :)

Was it helpful?

Solution

If you want to fetch the data from NSE web service, then below is the link:

http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/ajaxGetQuoteJSON.jsp?symbol=dhfl

But I'm not sure whether you can use this link or not for non commercial as well as commercial purpose.

As the site has been updated and old site is no more working, updating answers with new updated links:

Equity link - https://www.nseindia.com/api/quote-equity?symbol=RELIANCE https://www.nseindia.com/api/quote-equity?symbol=RELIANCE&section=trade_info

Derivatives link: https://www.nseindia.com/api/quote-derivative?symbol=RELIANCE

I'm not sure whether you can use this link or not for non commercial as well as commercial purpose

OTHER TIPS

For a free service you can call google finance web services or yahoo finance web services, but both are deprecated but are still working.

http://finance.yahoo.com/webservice/v1/symbols/IDFC.NS/quote?format=json&view=detail

in above URL: IDFC is the symbol of security .NS stands for NSE

For BSE just modify NS to BO

for google web service: NSE: http://finance.google.com/finance/info?client=ig&q=NSE:DHFL

for BSE just modify NSE to BOM

Just copy pate above links in a browser to see json output.

Please go to this GitHub library. It will surely help.

Currently it gives live stock from the official NSE site.

This services will give you a json response, you can parse this JSON to get the appropriate value, by just replacing the symbol with a valid NSE code.

Google provide a free web services for NSC and BOM data.

https://finance.google.com/finance?q=NSE:KELLTONTEC&output=json

For google web service NSE data- https://finance.google.com/finance?q=NSE:KELLTONTEC&output=json

For google web service BSE (BOM) data- https://finance.google.com/finance?q=BSE:KELLTONTEC&output=json

In PHP

$bse = file_get_contents("https://finance.google.com/finance?q=BSE:KELLTONTEC&output=json");
$split_slash= str_replace('//','',$bse );
$split_data = stripslashes(html_entity_decode($split_slash));
$data = json_decode($split_data);
$equity = $data[0]->l;
print_r($data[0]->l);

Its return BSE data

C# code to get live updates from NSE:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Web;
using Newtonsoft.Json.Linq; //download Newtonsoft dll from web
using Newtonsoft.Json;

namespace Check
{
    class Program
    {
        static void Main(string[] args)
        {
            //IDFCBANK

        string[] item = {"ICICIBANK","HDFCBANK"}; 

        foreach(string str in item ) 
        {
            string url = "http://finance.google.com/finance/info?client=ig&q=NSE:" + str;
            string output = "";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            try
            {
                WebResponse response = request.GetResponse();
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                    output = reader.ReadToEnd();
                    write(output);
                }
            }
            catch (WebException ex)
            {
                Console.WriteLine("Item invalid : " + str);
            }
        }

        Console.ReadKey();

    }

    static void write(string res)
    {
        try 
        {
            if (res.Length > 0)
            {
                res = res.Replace("[", "").Replace("]", "");
                JObject rss = JObject.Parse(res);

                string Title = (string)rss["t"];
                string Time = (string)rss["ltt"];
                string Charge = (string)rss["l"];
                string Change = (string)rss["c"];
                // James Newton-King
                Console.WriteLine(Title.Substring(0,3) + " " + Time + " " + Charge + "  " + Change);


            }

        }
       catch (Exception  ex)
       {
       }
        }

    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top