Batch query stocks
/stock?key=Contact us to get the key
PARAMS
name | Location | type | Required | illustrate |
---|---|---|---|---|
key | query | string | yes | Contact us to get the key |
Body Parameters
json
{
"pid": "1,2" // You can query the IDs of the stocks in batches (get the IDs in the stock list interface) separated by commas. The value of pid is a string.
}
Example Response
json
[
{
"Id": 535576092, // Stock Id is also the pid of the stock
"Name": "RELIANCE INDS", // Stock Name
"Symbol": "RELIANCE", // Stock Code
"Last": "3006.4", // Latest stock price
"High": "3020.9", // Highest
"Low": "3002.3", // lowest
"Open": "3008", // Open today
"PrevClose": "3026.3", // Yesterday's harvest
"Time": "1722415578", // Price update time
"Volume": "3340162", // Trading Volume
"Chg": "-19.9", // Increase
"ChgPct": "-0.66", // Increase rate
"country_id": "14", // Country ID
"type": "NSE", // The stock's exchange
"Ratio": "29.78", // Price-to-Earnings Ratio
"MarketCap": "20.57T", // Market Cap
"Eps": "101.61", // Earnings per share
"Bid": "3006.05", // Buy Price
"Ask": "3006.4", // Ask Price
"Beta": "1.0468383", // Beta
"NumSymbol": "3816" // Malaysian stocks have digital codes only in Malaysia
}
]
Example Request
java
import java.io.*;
import okhttp3.*;
public class main {
public static void main(String []args) throws IOException{
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \"pid\": \"1,2\" }");
Request request = new Request.Builder()
.url("/stock?key=Contact us to get the key")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
php
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/stock?key=Contact us to get the key',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"pid": "1,2"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;