Group Details Private

SmartAPI Group

  • How can I get Index performance with % change.

    Hi @admin @administrators

    I just want to know that how would I know the Index performance during opening market hours. Like SS provided below:-Index_Performance.jpeg

    posted in General Discussion
  • lost charts study templates

    I lost all my charts study templates.

    There is no proper response from angel one .

    this might have been happen due to recent mobile app update from play store .

    screenshot angel app.jpeg

    posted in General Discussion
  • RE: please share some example of WebSocket 2.0 response data

    @Jaydip-Garala you are able to get bid ask price from websocket?

    posted in C#/.Net SDK
  • RE: please share some example of WebSocket 2.0 response data

    @Jaydip-Garala you are able to get best five data Buy/Sell prices (in websocket streaming) than please help me i am not able

    posted in C#/.Net SDK
  • Invalid totp
    // server.js
    const express = require('express');
    const { SmartAPI } = require('smartapi-javascript');
    const WebSocket = require('ws');
    const path = require('path');
    require('dotenv').config();
    
    const app = express();
    const port = 3000;
    
    // Middleware
    app.use(express.json());
    app.use(express.static('public'));
    
    // Initialize SmartAPI
    let smart_api;
    try {
        smart_api = new SmartAPI({
            api_key: process.env.SMART_API_KEY,    // Your API Key
            clientId: process.env.CLIENT_ID,       // Your Client ID
            clientSecret: process.env.CLIENT_SECRET // Your Client Secret
        });
        console.log('SmartAPI initialized successfully');
    } catch (error) {
        console.error('Error initializing SmartAPI:', error);
        process.exit(1);
    }
    
    // Store session data
    let session = null;
    
    // Session check middleware
    const checkSession = (req, res, next) => {
        if (!session || !session.feedToken) {
            return res.status(401).json({ success: false, message: 'Not logged in or session expired' });
        }
        next();
    };
    
    //login code test
    app.post('/api/login', async (req, res) => {
        try {
            console.log('Login attempt started...');
            const { client_code, password, totp } = req.body;
            
            if (!client_code || !password || !totp) {
                throw new Error('Missing required login parameters');
            }
    
            console.log('Generating session...');
            const data = await smart_api.generateSession(client_code, password, totp);
            
            console.log('Full API Response:', JSON.stringify(data, null, 2));
    
            if (!data || !data.jwtToken || !data.feedToken) {
                throw new Error('Session generation failed, missing tokens.');
            }
    
            console.log('Session generated successfully:', {
                hasAccessToken: !!data.accessToken,
                hasRefreshToken: !!data.refreshToken,
                hasJwtToken: !!data.jwtToken,
                hasFeedToken: !!data.feedToken
            });
    
            session = data;
            smart_api.jwtToken = data.jwtToken;
            smart_api.feedToken = data.feedToken;
    
            res.json({
                success: true,
                message: 'Login successful',
                sessionInfo: {
                    hasAccessToken: !!data.accessToken,
                    hasJwtToken: !!data.jwtToken,
                    hasFeedToken: !!data.feedToken
                }
            });
    
        } catch (error) {
            console.error('Login error details:', error);
            res.status(500).json({
                success: false,
                message: error.message || 'Login failed',
                errorDetails: error.toString()
            });
        }
    });
    
    

    clientcode:"K624646"

    posted in General Discussion
  • Invalid totp

    Here is my code

    
    // Initialize SmartAPI
    let smart_api;
    try {
        smart_api = new SmartAPI({
            api_key: process.env.SMART_API_KEY,    // Your API Key
            clientId: process.env.CLIENT_ID,       // Your Client ID
            clientSecret: process.env.CLIENT_SECRET // Your Client Secret
        });
        console.log('SmartAPI initialized successfully');
    } catch (error) {
        console.error('Error initializing SmartAPI:', error);
        process.exit(1);
    }
    
    // Store session data
    let session = null;
    
    // Session check middleware
    const checkSession = (req, res, next) => {
        if (!session || !session.feedToken) {
            return res.status(401).json({ success: false, message: 'Not logged in or session expired' });
        }
        next();
    };
    
    //login code test
    app.post('/api/login', async (req, res) => {
        try {
            console.log('Login attempt started...');
            const { client_code, password, totp } = req.body;
            
            if (!client_code || !password || !totp) {
                throw new Error('Missing required login parameters');
            }
    
            console.log('Generating session...');
            const data = await smart_api.generateSession(client_code, password, totp);
            
            console.log('Full API Response:', JSON.stringify(data, null, 2));
    
            if (!data) {
                throw new Error('Session generation failed, missing tokens.');
            }
    
            console.log('Session generated successfully:', {
                hasAccessToken: !!data.accessToken,
                hasRefreshToken: !!data.refreshToken,
                hasJwtToken: !!data.jwtToken,
                hasFeedToken: !!data.feedToken
            });
    
            session = data;
            smart_api.jwtToken = data.jwtToken;
            smart_api.feedToken = data.feedToken;
    
            res.json({
                success: true,
                message: 'Login successful',
                sessionInfo: {
                    hasAccessToken: !!data.accessToken,
                    hasJwtToken: !!data.jwtToken,
                    hasFeedToken: !!data.feedToken
                }
            });
    
        } catch (error) {
            console.error('Login error details:', error);
            res.status(500).json({
                success: false,
                message: error.message || 'Login failed',
                errorDetails: error.toString()
            });
        }
    });
    
    
    

    Response

    Generating session...
    Full API Response: {
    "status": false,
    "message": "Invalid totp",
    "errorcode": "AB1050",
    "data": null
    }
    Session generated successfully: {
    hasAccessToken: false,
    hasRefreshToken: false,
    hasJwtToken: false,
    hasFeedToken: false
    }

    ID: "k624646"

    any one help me to solve this.

    posted in NodeJS SDK
  • RE: Internal Server error for all requests

    Hello, any update on the solution regarding this issue @admin @Moderator_1 @Moderator_2 @Moderator_3 @moderator_4 @bhaveshjain @batman1234 ?

    posted in Bugs
  • RE: Internal Server error for all requests

    @ash_0001 no that's not the error, since I re-logged in, also tried creating new api credentials, still the error persists, only for the M85437 id.
    Oddly enough, the same code is working perfectly fine with other users.

    @admin @Moderator_1 @Moderator_2 @Moderator_3 @moderator_4 I request you to kindly look into this once, since the Internal Error error is still returning on the M85437 ID even after changing the API App credentials and re-authenticating.

    posted in Bugs
  • Internal Server error for all requests

    Re: INTERNAL SERVER ERROR

    Dear @admin @Moderator_1 @Moderator_2 @Moderator_3 @moderator_4 ,

    I'm facing Internal server errors for client M85437 while making any request for placeorder, orderbook or positionbook.

    I'm using the python smartApi library, and I tried re-logging, yet getting the same error.

    here are the logs for your reference:

    1. orderbook:
      [E 250124 09:56:36 smartConnect:246] Error occurred while making a GET request to https://apiconnect.angelone.in/rest/secure/angelbroking/order/v1/getOrderBook. Error: Internal Error. URL: https://apiconnect.angelone.in/rest/secure/angelbroking/order/v1/getOrderBook, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': '4b:1f:e0:38:06:ac', 'Accept': 'application/json', 'X-PrivateKey': 'NlUMc4oQ', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {}, Response: {'message': 'Internal Error', 'errorcode': 'AB2001', 'status': False, 'data': None}

    2. positions:
      [E 250124 09:56:36 smartConnect:246] Error occurred while making a GET request to https://apiconnect.angelone.in/rest/secure/angelbroking/order/v1/getPosition. Error: Internal Error. URL: https://apiconnect.angelone.in/rest/secure/angelbroking/order/v1/getPosition, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': '4b:1f:e0:38:06:ac', 'Accept': 'application/json', 'X-PrivateKey': 'NlUMc4oQ', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {}, Response: {'message': 'Internal Error', 'errorcode': 'AB2001', 'status': False, 'data': None}

    3. placeTrade:
      [E 250124 09:30:13 smartConnect:246] Error occurred while making a POST request to https://apiconnect.angelone.in/rest/secure/angelbroking/order/v1/placeOrder. Error: Internal Error. URL: https://apiconnect.angelone.in/rest/secure/angelbroking/order/v1/placeOrder, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': '4b:1f:e0:38:06:ac', 'Accept': 'application/json', 'X-PrivateKey': 'NlUMc4oQ', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'variety': 'NORMAL', 'exchange': 'NFO', 'tradingsymbol': 'BANKNIFTY30JAN2548600PE', 'symboltoken': '39480', 'duration': 'DAY', 'transactiontype': 'SELL', 'quantity': '45', 'producttype': 'CARRYFORWARD', 'ordertype': 'LIMIT', 'ordertag': '4945', 'disclosedquantity': '0', 'price': '512.0'}, Response: {'message': 'Internal Error', 'errorcode': 'AB2001', 'status': False, 'data': None}
      [E 250124 09:30:13 smartConnect:339] API request failed: {'message': 'Internal Error', 'errorcode': 'AB2001', 'status': False, 'data': None}

    I request you to kindly look into it and give me a resolution for the same.

    Thank you.
    Lookiing forward to a quick resolution.

    posted in Bugs
  • Unable to login: stuck at Enter Pin

    Dear @Moderator_1 @Moderator_2 @admin ,
    Currently, we are facing issues with the login method using [https://smartapi.angelbroking.com/publisher-login]

    We are getting the error "Something went wrong. Please try after some time" after entering the login pin, and as a result, the login process is stuck there.
    This issue has been noticed for multiple trading accounts.

    I've attached the screenshot of the error visible in the browser for your reference.

    I request you to look into this issue and solve it at the earliest, as our trading has been completely halted due to it today.

    327c5aad-d9eb-49b8-b6ca-bf26fbbf8b38-image.png

    Looking forward to a quick resolution.

    Thank you!

    posted in Bugs