Barawakar API Documentation
Welcome to the Barawakar API! This service provides real-time and end-of-day National Stock Exchange (NSE) India data in a simple JSON format.
Base URL: https://api.barawakar.com/api/
All endpoints require a valid API key for authentication.
Table of Contents
Authentication
To use this API, you must include your API key as a query parameter in every request.
Parameter: key
Example: ?key=rajendra-key-2025
Keep your API key confidential and do not share it publicly.
Endpoints
1. Top Gainers
Returns a list of the top gaining securities (e.g., for the day).
- URL:
/gainers - Method:
GET - Query Parameters:
key(string, required): Your API key.
- Success Response:
- Code: 200 OK
- Content:
{ "data": [ ... ] }(Array of gainer objects)
2. Top Losers
Returns a list of the top losing securities (e.g., for the day).
- URL:
/losers - Method:
GET - Query Parameters:
key(string, required): Your API key.
- Success Response:
- Code: 200 OK
- Content:
{ "data": [ ... ] }(Array of loser objects)
3. Nifty Indices
Returns data for major Nifty indices (like NIFTY 50, NIFTY BANK, etc.).
- URL:
/indices - Method:
GET - Query Parameters:
key(string, required): Your API key.
- Success Response:
- Code: 200 OK
- Content:
{ "data": [ ... ] }(Array of index objects)
4. Sectoral Indices
Returns data for a specific Nifty sectoral index.
- URL:
/sectors-:indexName - Method:
GET - URL Parameters:
indexName(string, required): The name of the sectoral index (e.g.,NIFTY-IT,NIFTY-PHARMA,NIFTY-FIN-SERVICE).
- Query Parameters:
key(string, required): Your API key.
- Example URL:
/sectors-NIFTY-IT?key=rajendra-key-2025 - Success Response:
- Code: 200 OK
- Content:
{ "data": [ ... ] }(Array of constituent stocks for the sector)
5. Intraday Gainers
Returns a list of the top intraday gaining securities.
- URL:
/intraday-gainers - Method:
GET - Query Parameters:
key(string, required): Your API key.
- Success Response:
- Code: 200 OK
- Content:
{ "data": [ ... ] }(Array of intraday gainer objects)
6. Intraday Losers
Returns a list of the top intraday losing securities.
- URL:
/intraday-losers - Method:
GET - Query Parameters:
key(string, required): Your API key.
- Success Response:
- Code: 200 OK
- Content:
{ "data": [ ... ] }(Array of intraday loser objects)
7. FII/DII Equity Data
Returns Foreign Institutional Investor (FII) and Domestic Institutional Investor (DII) activity data for the equity cash segment.
- URL:
/fiidii-equity - Method:
GET - Query Parameters:
key(string, required): Your API key.
- Success Response:
- Code: 200 OK
- Content:
{ "data": { ... } }(Object containing FII and DII buy/sell values)
8. Stock Chart Data
Returns historical or intraday chart data for a specific stock symbol.
- URL:
/chart/:symbol - Method:
GET - URL Parameters:
symbol(string, required): The NSE symbol of the company (e.g.,RELIANCE,TCS,INFY).
- Query Parameters:
key(string, required): Your API key.
- Example URL:
/chart/RELIANCE?key=rajendra-key-2025 - Success Response:
- Code: 200 OK
- Content:
{ "data": [ ... ] }(Array of data points, e.g.,[timestamp, open, high, low, close, volume])
Response Format
All successful responses follow a similar JSON structure:
json
{
"data": [ ... ] // or { ... } depending on the endpoint
}
The contents of the data field will be an array of objects (for lists) or a single object (for specific data points like FII/DII).
Example /gainers response:
json
{
"data": [
{
"symbol": "COMPANY1",
"open": 150.00,
"high": 165.50,
"low": 149.50,
"lastPrice": 164.75,
"previousClose": 150.25,
"change": 14.50,
"pChange": 9.65
},
{
"symbol": "COMPANY2",
"...": "..."
}
]
}
Error Handling
The API uses standard HTTP status codes and returns an error message in the JSON body.
- 401 Unauthorized: Invalid or missing API key.json{ “error”: “Invalid API key” }
- 404 Not Found: The requested endpoint or resource (e.g., stock symbol) was not found.json{ “error”: “Endpoint not found” }
- 500 Internal Server Error: An error occurred on the server.json{ “error”: “Internal server error. Please try again later.” }
Example Usage
Here’s how to fetch the top gainers using JavaScript’s fetch:
javascript
const apiKey = 'rajendra-key-2025';
const url = `https://api.barawakar.com/api/gainers?key=${apiKey}`;
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('Top Gainers:', data.data);
// Process your data here
})
.catch(error => {
console.error('There was a problem fetching the data:', error);
});
Using Python with the requests library:
python
import requests
api_key = "rajendra-key-2025"
url = f"https://api.barawakar.com/api/indices?key={api_key}"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
indices = data['data']
for index in indices:
print(f"{index['indexName']}: {index['lastPrice']}")
else:
print(f"Error: {response.status_code}", response.json().get('error', 'Unknown error'))
For any questions or support regarding this API, please contact the administrator.