Data Services - MCX Commodity

This path is about the data services of MCX Commodity : /Api/V1/Data/McxCom

URL

Example POST API Request

https://uat.tickermarket.com/TPILWebAPI/Api/V1/Data/McxCom

Request

Key Required Value Discription
Segments TPIL_MCX 2 MCX Segment
Instrument TPIL_MCX_F&O, Spot 1, 2 Future and Options Instruments, Spot
Request Type MCX Commodity 1 - 15 MCX Spot and F&O Data Services
Otherinfo Optional 0 Timestamp-Seconds
                            
                              {
                                "sid":"2",
                                "instId":"1",
                                "rType":"2"
                            }
                          
                        
                                                      
                            Authorization: Bearer GciOiJIUzUxMiJ9.eyJzdWIiOiJERkRFTU8wMDAxICAgICAiLCJleHAiOjE2MjkyMTEyNDMsImlhdCI6MTYyOTE5MzI0M30.7GQJ_UxBecVe-
                            Content-Type: application/json
                            Accept: application/json
                          
                        
                          [
    {

      "Segment": "MCX",
        "Instrument": "FUTCOM",
        "TPILCode": 4907,
        "Symbol": "GLDAUGOC22",
        "ExpiryDate": "05AUG2022",
        "IdentifierOfTheUnderlying": 240086,
        "DateTime": "1-August-2022 9:0:7",
        "BestBuyQty": 0,
        "BestBuyPrice": 0.00,
        "BestSellQty": 0,
        "BestSellPrice": 0.00,
        "LastTradedPrice": 0.00,
        "Volume": 0,
        "NetChange": 0.00,
        "PercentChange": 0.00,
        "OpenPrice": 0.00,
        "HighPrice": 0.00,
        "LowPrice": 0.00,
        "ClosePrice": 180.00,
        "OpenInterest": 0,
        "Value": 0.0,
        "nMsgTimeStamp": 1343811607,
        "CommodityName": "Gold",
        "PriceQuotationUnit": "10 GRMS ",
        "nExpiryDate": 1344124800,
        "nSegmentId": 2,
        "nInstrumentType": 1,
        "nInstrumentIdentifier": 240086,
        "nStrikePrice": 0,
        "sOptionType": "XX",
        "AverageTradedPrice": 0.00
                         }
    ]
                        
                      
                                                      
                            {
                              "sid":"2",
                              "instId":"1",
                              "rType":"1"
                                                                               }
                                                                              
                                                      
                            Authorization: Bearer GciOiJIUzUxMiJ9.eyJzdWIiOiJERkRFTU8wMDAxICAgICAiLCJleHAiOjE2MjkyMTEyNDMsImlhdCI6MTYyOTE5MzI0M30.7GQJ_UxBecVe-
                            Content-Type: application/json
                            Accept: application/xml
                          
                        
                          <McxComList>
                        <item>
                          <Segment>MCX</Segment>
                          <Instrument>FUTCOM</Instrument>
                          <TPILCode>4944</TPILCode>
                          <IndexName>MCXCOMDEX</IndexName>
                          <DateTime>6-February-2020 23:55:13</DateTime>
                          <CurrentIndexValue>3798.69</CurrentIndexValue>
                          <OpenIndexValue>0.00</OpenIndexValue>
                          <HighIndexValue>3798.69</HighIndexValue>
                          <LowIndexValue>0.00</LowIndexValue>
                          <CloseIndexValue>3798.69</CloseIndexValue>
                          <NetChange>0.00</NetChange>
                          <PercentChange>0.00</PercentChange>
                          <nMsgTimeStamp>1265500513</nMsgTimeStamp>
                          <nSegmentId>2</nSegmentId>
                          <nInstrumentType>1</nInstrumentType>
                          </item>
                            </McxComArrayList>
                        
                      
                        
                        // Java Data Services - MCX
                      URL url = new
                      URL("https://uat.tickermarket.com/TPILWebAPI/Api/V1/Data/McxComm");

//Open URL connection
HttpURLConnection http = (HttpURLConnection)url.openConnection();

//POST Request
http.setRequestMethod("POST");
http.setDoOutput(true);
http.setRequestProperty("Accept", "application/json");
http.setRequestProperty("Content-Type", "application/json");
http.setRequestProperty("Authorization", "Bearer GciOiJIUzUxMiJ9.eyJzdWIiOiJERkRFTU8wMDAxICAgICAiLCJleHAiOjE2MjkyMTEyNDMsImlhdCI6MTYyOTE5MzI0M30.7GQJ_UxBecVe-");

//Create the Request Body
String data = "{\n  \"sid\": 2,\n  \"instId\": 1,\n  \"rType\": 1,\n  }";
byte[] out = data.getBytes(StandardCharsets.UTF_8);

// Response Data
OutputStream stream = http.getOutputStream();
stream.write(out);
System.out.println(http.getResponseCode() + " " + http.getResponseMessage());
http.disconnect();

                    
                  
                        
                        // C# Data Services - MCX
                                var  url = "https://uat.tickermarket.com/TPILWebAPI/Api/V1/Data/McxComm");
                                var httpRequest= (HttpWebRequest) WebRequest.Create(url);

                                

                        //POST Request
                                http.setRequestMethod("POST");
                                
                                httpRequest.Accept("application/json");
                                
                                http.Headers("Authorization", "Bearer GciOiJIUzUxMiJ9.eyJzdWIiOiJERkRFTU8wMDAxICAgICAiLCJleHAiOjE2MjkyMTEyNDMsImlhdCI6MTYyOTE5MzI0M30.7GQJ_UxBecVe-");
                                httpRequest.ContentType("application/json");

                        //Create the Request Body
                                var data = "{\n  \"sid\": 2,\n  \"instId\": 1,\n  \"rType\": 1,\n  }";
                                Using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
                                {
                                streamWriter.Write(data);
                                }


                        // Response Data

                                var httpResponse = (HttpWebResponse) httpRequest.GetResponse();
                                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                                {
                                Var result= streamReader.ReadToEnd();
                                }
                                Console.WriteLine(httpResponse.StatusCode);

                            
                            
                                //PHP Data Services - MCX

                                ?php

                                $url = ("https://uat.tickermarket.com/TPILWebAPI/Api/V1/Data/McxComm");
                                $curl = (curl_init($url));
                                curl_seropt($curl, CURLOPT_URL, $url);
                                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);



                                

                                //POST Request



                                $headers = array("Authorization":"Bearer GciOiJIUzUxMiJ9.eyJzdWIiOiJERkRFTU8wMDAxICAgICAiLCJleHAiOjE2MjkyMTEyNDMsImlhdCI6MTYyOTE5MzI0M30.7GQJ_UxBecVe-" , Content-Type : application/json);
                                Curl_setopt($curl ,, CURLOPT_HTTPHEADER, , $headers);


                                //Create the Request Body
                                $data= DATA{ {
                                "sid" : 2,
                                "instId" : 1,
                                "rType": 1
                                };




                                // Response Data

                                Curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                                $resp=curl_exec($curl);
                                curl_close($curl);
                                var_dump($resp);
                                ?>

                            
                        
                        //Python Data Services - MCX
                                Import requests
                                From requests.structure import CaseInsensitiveDict

                                url = ("https://uat.tickermarket.com/TPILWebAPI/Api/V1/Data/McxComm");
                                headers = CaseInsensitiveDict()



                                

                        //POST Request


                                headers [ "Accept"] = "application/json"
                                headers["Authorization"] = " Bearer GciOiJIUzUxMiJ9.eyJzdWIiOiJERkRFTU8wMDAxICAgICAiLCJleHAiOjE2MjkyMTEyNDMsImlhdCI6MTYyOTE5MzI0M30.7GQJ_UxBecVe- "
                                headers["Content-Type"] = "application/json"


                        //Create the Request Body
                                data= """
                                {
                                "sid" : "2",
                                "instId": "1",
                                "rType": "1"
                                }
                                """




                        // Response Data

                                resp = request.post(url, headers=headers, data=data)
                                print(resp.status_code)


                            
                        
                        //Javascript Data Services - MCX


                                Var url=("https://uat.tickermarket.com/TPILWebAPI/Api/V1/Data/McxComm" )
                                Var xhr = new XMLHttpRequest();




                                

                        //POST Request


                                xhr.open("POST", url);
                                xhr.setRequestHeader("Accept","application/json" );
                                xhr.setRequestHeader("Authorization","Bearer GciOiJIUzUxMiJ9.eyJzdWIiOiJERkRFTU8wMDAxICAgICAiLCJleHAiOjE2MjkyMTEyNDMsImlhdCI6MTYyOTE5MzI0M30.7GQJ_UxBecVe- " );
                                xhr.setRequestHeader(Content-Type, "application/json" );

                                xhr.onreadystatechange= function() {
                                if(xhr.readyState = = = 4)
                                {
                                Console.log(xhr.status);
                                Console.log(xhr.responseText);
                                }};



                        //Create the Request Body
                                Var data = '{
                                "sid" : 3,
                                "instId" : 1,
                                "rType": 1
                                }';





                        // Response Data

                                Xhr.send(data);
                                Console.log(xhr.status);



                            
                            
                                //CURL Data Services - MCX


                                #! /bin/bash
                                #Login:


                                //POST Request


                                curl -d  "{ \ username\" :  \ "ABB \" , \"password\" : \"password\"}" "-H content-type: application/json" " https://uat.tickermarket.com TPILWebAPI/Api/V1/Users/Login"

                                Curl -X POST https://uat.tickermarket.com/TPILWebAPI/Api/V1/Data/McxComm   -H "Authorization: Bearer GciOiJIUzUxMiJ9.eyJzdWIiOiJERkRFTU8wMDAxICAgICAiLCJleHAiOjE2MjkyMTEyNDMsImlhdCI6MTYyOTE5MzI0M30.7GQJ_UxBecVe-"  -H
                                "Content-Type: application/json"


                                //Create the Request Body
                                - - data-binary @- << DATA
                                {
                                "sid" : "3",
                                "instId": "1",
                                " rType": "1""
                                }
                                DATA