This module enables efficient and easy use of the SolanaTracker API
.
The following features are available:
- Unified API querying.
- Preparing and performing swaps with the
SolanaTracker API
. - (In Progress) Establishing and updating WebSocket connections.
- Create an account on
https://www.solanatracker.io
and generate an API key. - Download the repository.
import { TrackerAPI, examples } from '../src/index.mjs'
const st = new TrackerAPI({
'apiKey': `{{your_api_key}}`
})
const { route, params } = examples[0]
const response = await st.request({ route, params })
console.log(response)
This method initializes the class.
Method
.constructor({ apiKey, nodeUrl })
Key | Type | Description | Required |
---|---|---|---|
apiKey | string | Sets the apiKey for the SolanaTracker API. If not provided, the .getData() method will not be available. |
No (recommended) |
nodeUrl | string | Required, for example, to send transactions. If no nodeUrl is set, .getSwapQuote and .postSwap cannot be used. |
No (recommended) |
Example
import { TrackerAPI } from './src/index.mjs'
const st = new TrackerAPI({
'apiKey': '{{your_api_key}}',
'nodeUrl': '{{my_solana_node}}'
})
Returns
true
This method creates, sends, and evaluates requests to the SolanaTracker API.
Method
async .getData({ route, params })
Key | Type | Description | Required |
---|---|---|---|
route | string | Specifies the method to query. A list of methods can be found under routes. | Yes |
params | object | Parameters can be passed here. Required parameters can be found under routes. | Yes |
Example
import { TrackerAPI } from './src/index.mjs'
const st = new TrackerAPI({
'apiKey': '{{your_api_key}}'
})
await st.getData({
'route': 'search',
'params': {
'query': 'GOAT'
}
})
Returns
Object
This helper function displays all available routes. A list is also available under routes.
Method
.getRoutes()
Example
import { TrackerAPI } from './src/index.mjs'
const st = new TrackerAPI({
'apiKey': '{{your_api_key}}'
})
console.log(st.getRoutes())
Returns
Array of Strings
This method retrieves a quote and all necessary data to perform a swap with Solana Tracker
. The actual swap is triggered using .postSwap()
.
Method
async .getSwapQuote({ ...params })
Key | Description | Required |
---|---|---|
amount | The amount of the base token to swap. Can be a specific value, "auto" to use full wallet amount, or a percentage (e.g., "50%") to use that portion of the wallet balance | Yes |
from | The base token address | Yes |
payer | Public key of the wallet sending the transaction | Yes |
slippage | Maximum acceptable slippage percentage | Yes |
to | The quote token address | Yes |
fee | Charge a custom fee to your users for each transaction (earn sol for each swap) | No |
feeType | Fee application type | No |
priorityFee | Amount in SOL to increase transaction processing priority | No |
priorityFeeLevel | Required if priorityFee is set to auto | No |
txVersion | Transaction version | No |
Example
import { TrackerAPI } from './src/index.mjs'
const st = new TrackerAPI({
'nodeUrl': '{{my_solana_node}}'
})
const publicKey = '{{my_public_key}}'
const quote = await st.getSwapQuote({
'from': 'So11111111111111111111111111111111111111112', // Solana Address
'to': 'UEPp8H46WkPiBmi7nw35nyfFDNpxp9LWRPxSMHXpump',
'amount': 0.0001,
'slippage': 15,
'payer': publicKey,
'priorityFee': 0.0005,
'feeType': 'add',
'fee': `${publicKey}:0.0001`
})
Returns
Object
This method triggers the actual swap after retrieving a quote with the .getSwapQuote()
method.
Method
async .postSwap({ quote, privateKey, skipConfirmation })
Key | Type | Description | Required |
---|---|---|---|
quote | object | Pass the response from the .getSwapQuote method here. |
Yes |
privateKey | string | Provide the privateKey . This must match the public key provided in the .getSwapQuote() method. |
Yes |
skipConfirmation | boolean | Before executing the swap, the user is asked to confirm. Setting skipConfirmation to true disables this prompt. |
No |
Example
import { TrackerAPI } from './src/index.mjs'
const st = new TrackerAPI({
'nodeUrl': '{{my_solana_node}}'
})
const publicKey = '{{my_public_key}}'
const quote = await st.getSwapQuote({
'from': 'So11111111111111111111111111111111111111112', // Solana Address
'to': 'UEPp8H46WkPiBmi7nw35nyfFDNpxp9LWRPxSMHXpump',
'amount': 0.0001,
'slippage': 15,
'payer': publicKey,
'priorityFee': 0.0005,
'feeType': 'add',
'fee': `${publicKey}:0.0001`
})
const swap = await st.postSwap({
quote,
'privateKey': '{{my_private_key}}',
'skipConfirmation': false
})
console.log(swap['swap']['id'])
Returns
Array of Strings
This overview provides a list of all available methods and their descriptions.
Key | Description | Route | Example | Response |
---|---|---|---|---|
chartData | GET /chart/{token} | X | X | |
chartDataByPool | Get OLCVH (Open, Low, Close, Volume, High) data for charts. | GET /chart/{token}/{pool} | X | X |
firstBuyersOfToken | Retrieve the first 100 buyers of a token (since API started recording data) with Profit and Loss data for each wallet. | GET /first-buyers/{token} | X | X |
graduatedTokens | Overview of all graduated pumpfun/moonshot tokens (Pumpvision / Photon Memescope style). | GET /tokens/multi/graduated | X | X |
latestTokens | Retrieve the latest 100 tokens. | GET /tokens/latest | X | X |
multiPriceInformation | Get price information for multiple tokens (up to 100). | GET /price/multi | X | X |
multiTokenInformation | Get an overview of latest, graduating, and graduated tokens (Pumpvision / Photon Memescope style). | GET /tokens/multi/all | X | X |
paginatedTopTraders | Get the most profitable traders across all tokens, with optional pagination. | GET /top-traders/all/{page} | X | X |
pnlForSpecificToken | Get Profit and Loss data for a specific token in a wallet. | GET /pnl/{wallet}/{token} | X | X |
postMultiPrice | Similar to GET /price/multi, but accepts an array of token addresses in the request body. | POST /price/multi | X | X |
postPrice | Similar to GET /price, but accepts token address in the request body. | POST /price | X | X |
priceHistory | Get historic price information for a single token. | GET /price/history | X | X |
priceInformation | Get price information for a single token. | GET /price | X | X |
profitAndLossData | Get Profit and Loss data for all positions of a wallet. | GET /pnl/{wallet} | X | X |
search | The /search endpoint provides a flexible search interface for pools and tokens with support for multiple filtering criteria and pagination. | GET /search | X | X |
tokenAth | Retrieve the all time high price of a token (since data api started recording) | GET /tokens/{tokenAddress}/ath | X | X |
tokenHolders | Get the top 100 holders for a specific token. | GET /tokens/{tokenAddress}/holders | X | X |
tokenInformation | Retrieve all information for a specific token. | GET /tokens/{tokenAddress} | X | X |
tokenStats | Get detailed stats for a token over various time intervals. | GET /stats/{token} | X | X |
tokenStatsByPool | Get detailed stats for a token-pool pair over various time intervals. | GET /stats/{token}/{pool} | X | X |
tokenTrades | Get the latest trades for a token across all pools. | GET /trades/{tokenAddress} | X | X |
tokenTradesByPool | Get the latest trades for a specific token and pool pair. | GET /trades/{tokenAddress}/{poolAddress} | X | X |
tokenTradesByPoolAndOwner | Get the latest trades for a specific token, pool, and wallet address. | GET /trades/{tokenAddress}/{poolAddress}/{owner} | X | X |
tokenVolume | Retrieve the top 100 tokens sorted by highest volume. | GET /tokens/volume | X | X |
topTraders | Get the most profitable traders | GET /top-traders/all | X | X |
topTradersForToken | Get top 100 traders by PnL for a token. | GET /top-traders/{token} | X | X |
tradesByWallet | Get the latest trades for a specific token and wallet address. | GET /trades/{tokenAddress}/by-wallet/{owner} | X | X |
trendingTokens | Get the top 100 trending tokens based on transaction volume in the past hour. | GET /tokens/trending | X | X |
trendingTokensByTimeframe | Returns trending tokens for a specific time interval. | GET /tokens/trending/{timeframe} | X | X |
walletInformation | Get all tokens in a wallet with current value in USD. | GET /wallet/{owner} | X | X |
walletTrades | Get the latest trades of a wallet. | GET /wallet/{owner}/trades | X | X |
This project is licensed under the MIT License. Details can be found in the LICENSE file.