SmartAPI Javascript Client SDK
Installation
npm i smartapi-javascript
Getting started with API
let { SmartAPI, WebSocket } = require("smartapi-javascript");
let smart_api = new SmartAPI({
api_key: "YOUR_API_KEY",
});
smart_api.generateSession("CLIENT_CODE", "PASSWORD")
.then((data) => {
return smart_api.getProfile();
})
.then((data) => {
})
.catch(ex => {
})
Getting started with SmartAPI Websocket's
########################### Socket Sample Code Starts Here ###########################
let web_socket = new WebSocket({
client_code: "CLIENT_CODE",
feed_token: "FEED_TOKEN",
script: "nse_cm|2885&nse_cm|1594"
});
web_socket.connect();
web_socket.on('tick', receiveTick)
function receiveTick(data) {
console.log("Receive stock ticks::", data)
}
########################### Socket Sample Code Ends Here ###########################