Solana: How to track the price or market cap of spl tokens?

Follow -up price or market ceiling of soil tokens (Solana) with Python

As a muzzle focused on Solana, you are probably interested in monitoring the price and market capitalization of recent sool tokens. In this article, we will explore how to follow these values ​​using Python and interact with Solana API.

Premises:

  • You have configured a solar knot (eg so Sola Mainnet or Test) and created an account on Pumpfun.

  • You have the Pumpunda library ( PIP installs pumpy).

Step 1: Create a new Python Script

Create a new file with a .py extension, for example,solana_market_cap.py. This script will manage the interactions with the solar API.

`Python

Import operating system

Import requests

from import dotenv load_dotenv

Variables of loading environment from .env file

Load_Dotenv ()

def get_token_data (token):

“” ”Get token data from Pumpfun '' '

URL = f "

headers = {

"Authorization": os.Getenv ("pumpfun_api_token"),

"Typ Content": "Application/JSON",

}

Answer = Requests.Get (URL, headers = headers)

Return Response.Json ()

def get_market_cap_data (token):

"" Get market capitalization data for a solar "" "

URL = f "

headers = {

"Authorization": os.Getenv ("pumpfun_api_token"),

"Typ Content": "Application/JSON",

}

Answer = Requests.Get (URL, headers = headers)

Return Response.Json ()

Def Main ():

token = input (“Please enter the token soil you want to watch:“)

data = get_token_data (token)

Get market capitalization data

Market_cap_Data = get_market_cap_data (token)

Printing (F "market capitalization: {market_cap_data ['totalsupply']}")

If __Name__ == "__main__":

main()

Step 2: Set up the solar node environment

Solana: How to track the price or market cap of spl tokens?

Make sure the Solana node is rolled and accessible from your Python script. You can do this by adding aSolana ‘environment variable in your file.

`Bash

Pumpfun_pi_token = your_pi_token_here

Replaceyour_pi_token_here with the real api token from Pumpfun.

Step 3: Roll the Script

Save the script and run it using Python. When prompted, enter the soil token you want to follow.

`

Python Solana_market_cap.py

This will print the market capitalization data for the specified soil token.

Tips and Variations:

  • To get price data instead of the market ceiling, updateURLin the GET_ToSL_DATA () to indicate solar price flow.

  • Consider adding errors and recording to make your script more robust.

  • You can use this script as a starting point and add more features, such as mapping or filtering ID with token.

Following these steps, you have successfully created a Python script that follows the price and market capitalization of the recent soil tokens using Pumpfun API.

Monero Capitalization Cosmos Atom

دیدگاه‌ها

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *