Group Details Private

Global Moderators

Forum wide moderators

  • S

    Hi Team,
    Based on info available here i tried to integrate following API but i'm not getting any result.
    https://smartapi.angelone.in/docs/TopGainers

    APIS:
    https://apiconnect.angelone.in/rest/secure/angelbroking/marketData/v1/putCallRatio
    https://apiconnect.angelone.in/rest/secure/angelbroking/marketData/v1/gainersLosers
    https://apiconnect.angelone.in/rest/secure/angelbroking/marketData/v1/OIBuildup

    Example:

    -------------------------------------------------------------- # TOP GAINERS / LOSERS # -------------------------------------------------------------- def get_top_gainers_losers(self): api = self.get_api() try: payload = { "exchange": "NSE" } resp = api._postRequest( "marketData/v1/gainersLosers", payload ) if not resp: return {"gainers": [], "losers": []} if not resp.get("status"): logger.warning(f"Gainers/Losers fetch failed: {resp}") return {"gainers": [], "losers": []} data = resp.get("data", {}) return { "gainers": data.get("gainers", []), "losers": data.get("losers", []) } except Exception as e: logger.error(f"Gainers/Losers API error: {e}") return {"gainers": [], "losers": []}

    While testing :
    c = SmartAPIClient()
    c.login()
    movers = c.get_top_gainers_losers()

    print("Top Gainers:") for g in movers["gainers"][:5]: print(g) print("\nTop Losers:") for l in movers["losers"][:5]: print(l)

    Getting this output.
    [2026-03-16 10:13:33,230] [INFO] main: Logging into SmartAPI...
    [I 260316 10:13:33 smartConnect:124] in pool
    [2026-03-16 10:13:33,683] [INFO] main: ✔ SmartAPI Login Successful
    [2026-03-16 10:13:33,684] [ERROR] main: Gainers/Losers API error: 'marketData/v1/gainersLosers'
    Top Gainers:

    Top Losers:

    Process finished with exit code 0

    Facing same issue with other API's as well.

    Note: I'm testing this from my local machine, where other apis are working fine but not able to get these info always both in offline market and live market

    Any help with working ways how to get the result will be helpful specially Put Call Ratio is needed.

    read more
  • P

    @algo_trading_50 hi,
    i saw that we can get expired commodity historical data.

    https://smartapi.angelbroking.com/docs/Historical

    Please correct me if i am wrong

    Historical API
    Historical API provides past data of the indices and instruments. When a successful request is placed, corresponding data is returned. A single API endpoint provides the data for all segments. The exchange parameter in the request body is used to specify the segment whose data is required.

    https://apiconnect.angelone.in/rest/secure/angelbroking/historical/v1/getCandleData
    Exchange Constants
    Param Value Description
    exchange NSE NSE Stocks and Indices
    NFO NSE Futures and Options
    BSE BSE Stocks and Indices
    BFO BSE Future and Options
    CDS Currency Derivatives
    MCX Commodities Exchange

    read more
  • A

    @p187170 Pass (4 digits) MPIN as string in the password field.

    password = "MPIN"

    read more
  • P

    Hello SmartAPI Team,

    I am trying to authenticate using the SmartAPI Python SDK with TOTP enabled.

    However, the login request consistently returns the following error:

    Error Code: AB1050
    Message: Invalid totp

    Details of my setup:

    • Python version: 3.13
    • Library: smartapi-python
    • TOTP generated using: pyotp
    • Authentication method: client_id + password + totp

    My login code:

    from SmartApi import SmartConnect
    import pyotp

    api_key = "API_KEY"
    client_id = "CLIENT_ID"
    password = "PASSWORD"
    totp_secret = "SECRET_KEY"

    totp = pyotp.TOTP(totp_secret).now()

    obj = SmartConnect(api_key)

    data = obj.generateSession(client_id, password, totp)

    print(data)

    Troubleshooting steps already performed:

    Verified that TOTP generated using pyotp matches the TOTP generated using online generator:
    https://totp.danhersam.com

    Verified that the same secret key produces identical OTP in multiple generators.

    System time synchronized with internet time server.

    Despite this, SmartAPI login still returns:

    {
    "status": False,
    "message": "Invalid totp",
    "errorcode": "AB1050"
    }

    Could you please clarify:

    Is there a specific method required to generate TOTP for SmartAPI? Does SmartAPI require TOTP generated from the SmartAPI TOTP enable page specifically? Are there any restrictions on authenticator apps (Google Authenticator / Microsoft Authenticator)?

    Any guidance would be greatly appreciated.

    Thank you.

    read more