2

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.. :)

Rikin Thakkar
  • 1,268
  • 3
  • 13
  • 27
  • You want (a) a link to call the webservice, (b) information about using jQuery with that, (c) information about how to parse the json data, and (d) sample code? That's quite a tall order! – Wai Ha Lee Dec 26 '15 at 13:05
  • try nsepy library! – Gaurav Dec 22 '19 at 16:44

5 Answers5

11

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

Amar Gadekar
  • 387
  • 4
  • 11
6

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.

Amar Gadekar
  • 387
  • 4
  • 11
  • 1
    You should probably delete [your other answer](http://stackoverflow.com/a/34471533/1364007) and include the information in this one. – Wai Ha Lee Dec 26 '15 at 13:00
  • I'm unable to add more than two links in one post due to reputation error. Minimum 10 reputation is required to post more than two links in an answer. I'm new to stackoverflow. – Amar Gadekar Dec 26 '15 at 13:04
  • To be fair, this question is probably too broad anyway - I'm not sure it's worth your while answering it unless the OP edits it (unlikely since it's an old question and they've not been seen online for several months). – Wai Ha Lee Dec 26 '15 at 13:07
  • Yeah true, but this might help someone searching for the same... – Amar Gadekar Dec 26 '15 at 13:12
3

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.

hirenhcm
  • 93
  • 1
  • 10
2

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

Community
  • 1
  • 1
0

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)
       {
       }
        }

    }
}
Jay
  • 1,317
  • 4
  • 16
  • 40