Package Name: @a6b8/tracker-api
This module enables efficient and easy use of the SolanaTracker API.
The following features are available:
- Data Methods: Unified API querying with queryData() and route discovery
- Trading Methods: Preparing and performing swaps with the SolanaTracker API
- WebSocket Methods: Real-time connections with filtering and room management
- Event-Driven Methods: Asynchronous operations with progress events and flexible error handling
- Core Methods: Configuration management and health monitoring
npm install @a6b8/tracker-api- Create an account on
https://www.solanatracker.ioand generate an API key. - Install the package using npm.
import { TrackerAPI, examples } from '@a6b8/tracker-api'
const st = new TrackerAPI({
'apiKey': `{{your_api_key}}`
})
const { route, params } = examples[0]
const response = await st.queryData({ route, params })
console.log(response)// Listen for events
st.on('collection', (data) => {
console.log(`Status: ${data.status}`)
})
// Execute multiple API calls with progress tracking
st.performDataCollection({
batch: [
{ route: 'tokenInformation', params: { tokenAddress: 'SOL-address' }},
{ route: 'priceInformation', params: { token: 'USDC-address' }}
],
onError: 'continue' // Continue on validation errors
})const st = new TrackerAPI({ wsUrl: '{{websocket_url}}' })
// Connect and subscribe to token events
st.connectWebsocket()
st.updateWebsocketRoom({
roomId: 'graduatingTokens',
type: 'join',
params: { poolId: 'your-pool-id' }
})
// Listen for real-time events
st.on('graduatingTokens', (tokenData) => {
console.log('New token graduated:', tokenData)
})- TrackerAPI
This method initializes the class.
Method
.constructor({ apiKey, nodeHttp, nodeWs, wsUrl })| Key | Type | Description | Required |
|---|---|---|---|
| apiKey | string | Sets the apiKey for the SolanaTracker API. If not provided, data methods will not be available. |
No (recommended) |
| nodeHttp | string | Solana RPC HTTP endpoint. Required for swap transactions. | No (recommended) |
| nodeWs | string | Solana RPC WebSocket endpoint. Required for swap transaction confirmations. | No |
| wsUrl | string | SolanaTracker WebSocket URL. Required for WebSocket functionality. | No |
Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({
'apiKey': '{{your_api_key}}',
'nodeHttp': '{{my_solana_http_node}}',
'nodeWs': '{{my_solana_ws_node}}',
'wsUrl': '{{tracker_websocket_url}}'
})Returns
trueThis method returns the health status of the TrackerAPI instance.
Method
.health()Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({ 'apiKey': '{{your_api_key}}' })
console.log(st.health())Returns
trueThis method returns the current configuration of the TrackerAPI instance.
Method
.getConfig()Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({ 'apiKey': '{{your_api_key}}' })
const config = st.getConfig()
console.log(config)Returns
Object // Current configuration objectThis method updates the configuration of the TrackerAPI instance.
Method
.setConfig({ config })| Key | Type | Description | Required |
|---|---|---|---|
| config | object | New configuration object | Yes |
Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({ 'apiKey': '{{your_api_key}}' })
st.setConfig({ config: newConfigObject })Returns
trueThis method creates, sends, and evaluates requests to the SolanaTracker API.
Method
async .queryData({ 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 '@a6b8/tracker-api'
const st = new TrackerAPI({
'apiKey': '{{your_api_key}}'
})
await st.queryData({
'route': 'search',
'params': {
'query': 'GOAT'
}
})Returns
ObjectThis helper function displays all available routes for queryData(). A list is also available under routes.
Method
.getDataRoutes()Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({
'apiKey': '{{your_api_key}}'
})
console.log(st.getDataRoutes())Returns
Array of StringsThis method retrieves a quote for a swap transaction without executing it. Use with .postSwapTransaction() for more control.
Method
async .getSwapQuote( params, id )| Key | Type | Description | Required |
|---|---|---|---|
| params | object | Swap parameters (same as performSwap params object) | Yes |
| id | string | Optional identifier for tracking (default: 'n/a') | No |
Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({
'nodeHttp': '{{my_solana_http_node}}',
'nodeWs': '{{my_solana_ws_node}}'
})
const quote = await st.getSwapQuote({
'from': 'So11111111111111111111111111111111111111112', // SOL
'to': 'UEPp8H46WkPiBmi7nw35nyfFDNpxp9LWRPxSMHXpump',
'amount': 0.0001,
'slippage': 15,
'payer': '{{my_public_key}}',
'priorityFee': 0.0005
})
console.log('Quote:', quote)Returns
{
status: boolean,
messages: Array,
data: Object, // Quote data with transaction details
id: string
}This method executes a previously obtained swap quote. Must be used after .getSwapQuote().
Method
async .postSwapTransaction({ quote, privateKey, skipConfirmation })| Key | Type | Description | Required |
|---|---|---|---|
| quote | object | Quote object returned from getSwapQuote() | Yes |
| privateKey | string | Private key for transaction signing | Yes |
| skipConfirmation | boolean | Skip user confirmation prompt (default: false) | No |
Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({
'nodeHttp': '{{my_solana_http_node}}',
'nodeWs': '{{my_solana_ws_node}}'
})
// First get quote
const quote = await st.getSwapQuote({
'from': 'So11111111111111111111111111111111111111112',
'to': 'UEPp8H46WkPiBmi7nw35nyfFDNpxp9LWRPxSMHXpump',
'amount': 0.0001,
'slippage': 15,
'payer': '{{my_public_key}}'
})
// Review quote, then execute
if (quote.status) {
const result = await st.postSwapTransaction({
quote,
'privateKey': '{{my_private_key}}',
'skipConfirmation': false
})
console.log('Swap result:', result)
}Returns
{
data: {
status: boolean,
messages: Array,
data: {
request: Object,
quote: Object,
swap: {
id: string, // Transaction ID
tx: Object // Transaction object
}
},
id: string
}
}This method establishes a connection to the SolanaTracker WebSocket server.
Method
.connectWebsocket()Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({
'wsUrl': '{{tracker_websocket_url}}'
})
const result = st.connectWebsocket()
console.log(result)Returns
{ status: boolean, messages: Array, data: Object }This method creates a filter function that can be used to filter WebSocket messages.
Method
.addWebsocketFilter({ funcName, func })| Key | Type | Description | Required |
|---|---|---|---|
| funcName | string | Name identifier for the filter function | Yes |
| func | function | Filter function that returns true/false | Yes |
Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({ 'wsUrl': '{{tracker_websocket_url}}' })
const pumpFilter = st.addWebsocketFilter({
'funcName': 'isPumpFun',
'func': (data) => data.token.createdOn === 'https://pump.fun'
})Returns
{ funcName: string, func: function, type: 'filter' }This method creates a modifier function that transforms WebSocket message data.
Method
.addWebsocketModifier({ funcName, func })| Key | Type | Description | Required |
|---|---|---|---|
| funcName | string | Name identifier for the modifier function | Yes |
| func | function | Modifier function that transforms data | Yes |
Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({ 'wsUrl': '{{tracker_websocket_url}}' })
const dataModifier = st.addWebsocketModifier({
'funcName': 'extractEssentials',
'func': (data) => ({
name: data.token.name,
mint: data.token.mint,
price: data.price
})
})Returns
{ funcName: string, func: function, type: 'modifier' }This method joins or leaves WebSocket rooms with optional filtering and data modification.
Method
.updateWebsocketRoom({ roomId, type, params, filters, modifiers })| Key | Type | Description | Required |
|---|---|---|---|
| roomId | string | The room to join/leave | Yes |
| type | string | Action type: 'join' or 'leave' | Yes |
| params | object | Parameters for the room (e.g., tokenId, poolId) | No |
| filters | array | Array of filter objects from addWebsocketFilter() | No |
| modifiers | array | Array of modifier objects from addWebsocketModifier() | No |
Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({ 'wsUrl': '{{tracker_websocket_url}}' })
// Create filters and modifiers
const filter1 = st.addWebsocketFilter({
'funcName': 'isPumpFun',
'func': (data) => data.token.createdOn === 'https://pump.fun'
})
const modifier1 = st.addWebsocketModifier({
'funcName': 'extractEssentials',
'func': (data) => ({ name: data.token.name, mint: data.token.mint })
})
// Join room with filters and modifiers
st.updateWebsocketRoom({
'roomId': 'graduatingTokens',
'type': 'join',
'params': { poolId: 'GmJaZvdNptvofC4qe3tvuBNgqLm65p1of5pk6JFHpump' },
'filters': [filter1],
'modifiers': [modifier1]
})
// Listen for events
st.on('graduatingTokens', (data) => {
console.log('Filtered and modified data:', data)
})Returns
{ status: boolean, messages: Array, data: Object }These methods perform asynchronous operations and emit events through the EventEmitter pattern. Listen for events using .on(eventName, callback).
Executes multiple API requests in parallel and emits progress events throughout the process.
Method
.performDataCollection({ batch, onError })| Key | Type | Description | Required |
|---|---|---|---|
| batch | array | Array of request objects with route and params | Yes |
| onError | string | Error handling mode: 'throw' or 'continue' (default: 'throw') | No |
Events Emitted:
collection- Emitted during different stages of the collection process
Event Data Structure:
{
id: string, // Unique operation ID
status: string, // 'started', 'progress', 'completed', 'error'
total?: number, // Total number of requests (on 'started')
completed?: number, // Number completed so far (on 'progress')
result?: object, // Individual result (on 'progress')
results?: array, // All results (on 'completed')
error?: string // Error message (on 'error')
}Example
import { TrackerAPI } from '@a6b8/tracker-api'
const st = new TrackerAPI({
'apiKey': '{{your_api_key}}'
})
// Listen for collection events
st.on('collection', (data) => {
console.log(`Operation ${data.id} - Status: ${data.status}`)
if (data.status === 'started') {
console.log(`Starting collection of ${data.total} requests`)
} else if (data.status === 'progress') {
console.log(`Progress: ${data.completed}/${data.total} completed`)
console.log('Latest result:', data.result)
} else if (data.status === 'completed') {
console.log('All requests completed:', data.results)
} else if (data.status === 'error') {
console.error('Collection failed:', data.error)
}
})
// Start data collection (throw on error - default)
st.performDataCollection({
batch: [
{ route: 'tokenInformation', params: { tokenAddress: 'So11111111111111111111111111111111111111112' }},
{ route: 'priceInformation', params: { token: 'So11111111111111111111111111111111111111112' }},
{ route: 'tokenHolders', params: { tokenAddress: 'So11111111111111111111111111111111111111112' }}
],
onError: 'throw' // Will throw error on invalid batch data
})
// Alternative: Continue on validation errors (for event-driven systems)
st.performDataCollection({
batch: eventData, // Data from external source - might be invalid
onError: 'continue' // Will emit error event but continue program execution
})Returns
{ status: boolean, data: Array, id: string }Performs a complete swap transaction asynchronously and emits events during the process. This is the event-driven version of the synchronous swap methods.
Method
.performSwap({ params, privateKey, skipConfirmation, onError })| Key | Type | Description | Required |
|---|---|---|---|
| params | object | Swap parameters (from, to, amount, slippage, payer, etc.) | Yes |
| privateKey | string | Private key for transaction signing | Yes |
| skipConfirmation | boolean | Skip user confirmation prompt (default: false) | No |
| onError | string | Error handling mode: 'throw' or 'continue' (default: 'throw') | No |
Events Emitted:
swap- Emitted when swap quote is retrieved and transaction is executed, or on validation errors
Event Data Structure:
{
id: string, // Unique operation ID
eventStatus: string, // 'getQuote' or 'error'
quote?: object, // Quote data and transaction result (on success)
error?: Array // Error messages (on validation failure)
}Example
st.on('swap', (data) => {
if (data.eventStatus === 'getQuote') {
console.log('Swap completed:', data.quote)
} else if (data.eventStatus === 'error') {
console.error('Swap validation failed:', data.error)
}
})
// Default behavior - throw on validation errors
const swapId = st.performSwap({
params: {
from: 'So11111111111111111111111111111111111111112',
to: 'UEPp8H46WkPiBmi7nw35nyfFDNpxp9LWRPxSMHXpump',
amount: 0.001,
slippage: 15,
payer: '{{your_public_key}}'
},
privateKey: '{{private_key}}',
onError: 'throw' // Will throw error on invalid params
})
// Event-driven behavior - continue on validation errors
const swapId = st.performSwap({
params: eventTradeData, // Data from copy-trading event - might be invalid
privateKey: '{{private_key}}',
onError: 'continue' // Will emit error event but continue program
})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.