Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Downloading All Instruments

    C#/.Net SDK
    0
    3
    44
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      vcb last edited by

      In the c# API, which function / command to use to download all instruments ?

      S 1 Reply Last reply Reply Quote 0
      • S
        saleem @vcb last edited by

        @vcb
        Implement a class like this...
        public class NSEInstrument
        {
        [JsonProperty("token")]
        public string token { get; set; }
        [JsonProperty("symbol")]
        public string symbol { get; set; }
        [JsonProperty("name")]
        public string name { get; set; }
        }

        And write this function...
        public List<NSEInstrument> GetNSEInstruments()
        {
        WebRequest webRequest = WebRequest.Create("https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json");
        HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
        if (response.StatusDescription == "OK")
        {
        Stream dataStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(dataStream);
        string responseFromServer = reader.ReadToEnd();
        List<NSEInstrument> data = JsonConvert.DeserializeObject<List<NSEInstrument>>(responseFromServer);
        return data;
        }
        return null;
        }

        Call this function to get all the instruments and tokens

        1 Reply Last reply Reply Quote 1
        • S
          saleem last edited by

          Write a class and code like this...

          public class NSEInstrument
          {
          [JsonProperty("token")]
          public string token { get; set; }
          [JsonProperty("symbol")]
          public string symbol { get; set; }
          [JsonProperty("name")]
          public string name { get; set; }
          }

            public List<NSEInstrument> GetNSEInstruments()
          	{
               WebRequest webRequest = WebRequest.Create("https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json");
               HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
               if (response.StatusDescription == "OK")
               {
                  Stream dataStream = response.GetResponseStream();
                  StreamReader reader = new StreamReader(dataStream);
                  string responseFromServer = reader.ReadToEnd();
                  List<NSEInstrument> data = JsonConvert.DeserializeObject<List<NSEInstrument>>(responseFromServer);
                  return data;
               }
               return null;
            }
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post