If you're trying to obtain the price of a token, you just need to obtain it using any of the available endpoints, like Get Token Info By Id. The price will be in the latest_price
key, if available. If you're using the Get Token Timeseries endpoint, the latest price will be for the latest timestamp.
Token Prices might not always be available
Some times we might not have the price for a token available, in which case the
latest_price
key might be missing. Prepare your code for this eventuality.
You can also use the SDK to fetch this information like this:
import PulsarSDK from 'pulsar_sdk_js'
const sdk = new PulsarSDK(API_KEY)
sdk.tokens.get_token_info_by_id('YOUR TOKEN ID').then((token) => {
console.log(token.latest_price)
})
from pulsar_sdk_py import PulsarSDK
sdk = PulsarSDK(api_key=API_KEY)
token = sdk.tokens.get_token_info_by_id(token_id="YOUR TOKEN ID")
token_price = token.latest_price