Which function will get LTP data using pmClient

I need to get LTP data of scrip without trading.

You can use two method

  1. Via API : Get the LTP using API call
  2. Via websocket : Get the LTP using websocket connection
    Refere below doc
    For websocket
    https://developer.paytmmoney.com/docs/api/live-market-data-webSocket-streaming/
    For API
    https://developer.paytmmoney.com/docs/api/live-market-data-api/

Hi @satyamtd,
The methods for fetching live market data via an API call or WebSocket are not yet integrated into our pmclient lib. We are working on it and will soon release a new version supporting the same.

Till then, Please use the two methods mentioned by @hemant.

Please follow the below steps for fetching data via our Live Market data WebSocket Streaming feature:

  1. Create a Public Access Token (JWT Token) using the get access token API. You can access Live Market Data WebSocket Streaming API using public access token only.

  2. To create a web socket connection with the Live Market Data WebSocket Streaming service, send a web socket connection request to

wss://developer-ws.paytmmoney.com/broadcast/user/v1/data?x_jwt_token={{PUBLIC_ACCESS_TOKEN}}
  1. Once successfully connected, you may send a preference to receive live market data.
// Subscribe to Multiple scrips 
            var preferences = 
            [
              {
                "actionType": "ADD",
                "modeType": "FULL",
                "scripType": "INDEX",
                "exchangeType": "NSE",
                "scripId": "13"
              },
              {
                "actionType": "ADD",
                "modeType": "LTP",
                "scripType": "EQUITY",
                "exchangeType": "BSE",
                "scripId": "523144"
              }
            ]; 
            
            socket.send(JSON.stringify(preferences));

For more details check the API docs for Live Market data WebSocket Streaming

You can also fetch live market data using our Live Market data API feature.
Please Use the below cURL for fetching data via the Live Market data API feature:

curl --location --request GET 'https://developer.paytmmoney.com/data/v1/price/live?mode={MODE_TYPE}&pref={PREFERENCES}' \
--header 'x-jwt-token: {YOUR_JWT_TOKEN}' 

This API Can be accessed using: {access_token} or {read_access_token}

For more details check the API docs for Live Market data API

2 Likes

Thanks for reply. I am using https://developer.paytmmoney.com/data/v1/price/live/mode=LTP&pref=NSE:13:INDEX, BUT getting 404 error.
Pls provide any example for the same.

@satyamtd, This is happening because there is an error in the URL you are hitting. You have added “/” instead of “?”.
https://developer.paytmmoney.com/data/v1/price/live**/**mode=LTP&pref=NSE:13:INDEX

The correct URL will be
https://developer.paytmmoney.com/data/v1/price/live?mode=LTP&pref=NSE:13:INDEX

1 Like

Thanks for quick response. It’s working.

1 Like

@AbhishekMehta from where did you get scripId

Hi @chetan
You can use Security Master API for fetching scrip info. The Security Master API provides a consolidated, import-ready CSV list of securities/instruments available for trading. The Response will contain several fields including scrip Ids for various instruments.

API Doc for Security Master: https://developer.paytmmoney.com/docs/api/security-master/

1 Like

@AbhishekMehta I want to use webSocket to get the live data, But api “/accounts/v1/gettoken” does not provide public_access_token it only provides access token. I can see that paytm NodeJs SDK uses v1 api only. But webSocket wants public_access_token.

Please let me know how can I get the live data using v1 api only

Hi @spratap124, We no longer support using Live Market data Websocket Streaming with access token v1 API.

We will soon release newer versions of our pmclient libraries, which will be integrated with access token v2 API as well as the live market data Websocket Streaming API.

For now, you can easily use access token v2 API to generate public_access_token

cURL for Access Token v2 API

curl --location --request POST 'https://developer.paytmmoney.com/accounts/v2/gettoken' \
--header 'Content-Type: application/json' \
--data-raw '{
"api_key" : "{{apiKey}}",
"api_secret_key" : "{{apiSecret}}",
"request_token" : "{{requestToken}}"
}'

For more info check out the API docs
API docs for access token v2
API docs for Live Market data WebSocket Streaming

1 Like