How to filter transactions by type

Query only swaps, transfers, NFT sales, or other specific transaction types. Pass the type parameter to the Helius Enhanced API.

Try it with different types

Copy the code

// Get transactions filtered by type
// Uses Enhanced API with type parameter
import { Helius } from 'helius-sdk';

const helius = new Helius('YOUR_API_KEY');

async function getFilteredTransactions(
address: string,
type: 'TRANSFER' | 'SWAP' | 'NFT_SALE' | 'STAKE_SOL' // etc.
) {
// Add type parameter to filter results
const response = await fetch(
`https://api.helius.xyz/v0/addresses/${address}/transactions?api-key=YOUR_API_KEY&type=${type}&limit=20`
);

const transactions = await response.json();
return transactions;
}

// Example: Get only SWAP transactions
const swaps = await getFilteredTransactions(
'86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY',
'SWAP'
);

console.log(`Found ${swaps.length} swap transactions`);
swaps.forEach(tx => {
console.log(` ${tx.description}`);
});

How to use filters

  • Filter by type: Add type=SWAP to get only swap transactions. Other types: TRANSFER, NFT_SALE, NFT_MINT, STAKE_SOL.
  • Filter by source: Add source=JUPITER to get swaps from a specific DEX. Works with MAGIC_EDEN, TENSOR, RAYDIUM, etc.
  • Combine both: Use type=SWAP&source=JUPITER to get only Jupiter swaps.

Frequently Asked Questions

How do I filter transactions by type on Solana?
Add the type parameter to the Helius Enhanced API request, e.g., type=SWAP for only swap transactions. You can filter by TRANSFER, SWAP, NFT_SALE, NFT_MINT, STAKE_SOL, and more.
Can I filter by DEX or marketplace source?
Yes, use the source parameter. For example, source=JUPITER for Jupiter swaps, source=MAGIC_EDEN for Magic Eden NFT transactions, or source=RAYDIUM for Raydium trades.
Can I combine type and source filters?
Yes, combine parameters like type=SWAP&source=JUPITER to get only Jupiter swap transactions. This is useful for analyzing activity on specific protocols.