Skip to main content

Overview

Master advanced filtering techniques to find exactly the transactions you need. This guide covers all available filters, search patterns, and optimization strategies. What you’ll learn:
  • Filter by multiple criteria
  • Combine filters effectively
  • Search strategies
  • Performance optimization
  • Common filtering patterns

Available Filters

All filter parameters for transaction queries:
FilterTypeDescriptionExample
statusstringTransaction statusSUCCESS, PENDING, FAILED
typestringTransaction typeDEBIT, CREDIT, PEER-TRANSFER
currencystringCurrency codeNGN, USD, SOL, ETH
minAmountnumberMinimum amount1000
maxAmountnumberMaximum amount50000
startDatestringStart date2024-02-01
endDatestringEnd date2024-02-29
sortBystringSort fieldcreatedAt, amount, updatedAt
sortOrderstringSort directionasc, desc
pagenumberPage number1
limitnumberItems per page20

Filter by Status

Get transactions by status.
import MoneiSDK from 'monei-sdk';

const monei = new MoneiSDK({
  apiKey: process.env.MONEI_API_KEY,
});

// Get successful transactions
const successful = await monei.transactions.getUserTransactions({
  status: 'SUCCESS',
  limit: 20
});

console.log('Successful:', successful.pagination.total);

// Get pending transactions
const pending = await monei.transactions.getUserTransactions({
  status: 'PENDING',
  limit: 20
});

console.log('Pending:', pending.pagination.total);

// Get failed transactions
const failed = await monei.transactions.getUserTransactions({
  status: 'FAILED',
  limit: 20
});

console.log('Failed:', failed.pagination.total);

// Get completed transactions
const completed = await monei.transactions.getUserTransactions({
  status: 'COMPLETED',
  limit: 20
});

console.log('Completed:', completed.pagination.total);

Filter by Type

Get transactions by type (DEBIT, CREDIT, etc.).
// Money out (debits)
const debits = await monei.transactions.getUserTransactions({
  type: 'DEBIT',
  limit: 20
});

console.log('Debits (Money Out):', debits.pagination.total);
debits.transactions.forEach(tx => {
  console.log(`  - ₦${tx.amount} to ${tx.narration}`);
});

// Money in (credits)
const credits = await monei.transactions.getUserTransactions({
  type: 'CREDIT',
  limit: 20
});

console.log('\nCredits (Money In):', credits.pagination.total);
credits.transactions.forEach(tx => {
  console.log(`  + ₦${tx.amount} from ${tx.narration}`);
});

// Peer transfers
const p2p = await monei.transactions.getUserTransactions({
  type: 'PEER-TRANSFER',
  limit: 20
});

console.log('\nP2P Transfers:', p2p.pagination.total);

Filter by Currency

Get transactions for specific currencies.
// Naira transactions
const ngnTxns = await monei.transactions.getUserTransactions({
  currency: 'NGN',
  limit: 20
});

console.log('NGN Transactions:', ngnTxns.pagination.total);

// USD transactions
const usdTxns = await monei.transactions.getUserTransactions({
  currency: 'USD',
  limit: 20
});

console.log('USD Transactions:', usdTxns.pagination.total);

// SOL transactions
const solTxns = await monei.transactions.getUserTransactions({
  currency: 'SOL',
  limit: 20
});

console.log('SOL Transactions:', solTxns.pagination.total);

// ETH transactions
const ethTxns = await monei.transactions.getUserTransactions({
  currency: 'ETH',
  limit: 20
});

console.log('ETH Transactions:', ethTxns.pagination.total);

Filter by Amount Range

Get transactions within specific amount ranges.
// Small transactions (under ₦1,000)
const small = await monei.transactions.getUserTransactions({
  maxAmount: 1000,
  currency: 'NGN',
  limit: 20
});

console.log('Small (<₦1K):', small.pagination.total);

// Medium transactions (₦1,000 - ₦10,000)
const medium = await monei.transactions.getUserTransactions({
  minAmount: 1000,
  maxAmount: 10000,
  currency: 'NGN',
  limit: 20
});

console.log('Medium (₦1K-₦10K):', medium.pagination.total);

// Large transactions (₦10,000 - ₦100,000)
const large = await monei.transactions.getUserTransactions({
  minAmount: 10000,
  maxAmount: 100000,
  currency: 'NGN',
  limit: 20
});

console.log('Large (₦10K-₦100K):', large.pagination.total);

// Very large transactions (>₦100,000)
const veryLarge = await monei.transactions.getUserTransactions({
  minAmount: 100000,
  currency: 'NGN',
  limit: 20
});

console.log('Very Large (>₦100K):', veryLarge.pagination.total);

Filter by Date Range

Get transactions within specific time periods.
// Today
const today = new Date().toISOString().split('T')[0];
const todayTxns = await monei.transactions.getUserTransactions({
  startDate: today,
  endDate: today,
  limit: 100
});

console.log('Today:', todayTxns.pagination.total);

// This week
const thisWeekStart = new Date();
thisWeekStart.setDate(thisWeekStart.getDate() - 7);
const thisWeek = await monei.transactions.getUserTransactions({
  startDate: thisWeekStart.toISOString().split('T')[0],
  endDate: today,
  limit: 100
});

console.log('This Week:', thisWeek.pagination.total);

// This month
const thisMonthStart = new Date();
thisMonthStart.setDate(1);
const thisMonth = await monei.transactions.getUserTransactions({
  startDate: thisMonthStart.toISOString().split('T')[0],
  endDate: today,
  limit: 100
});

console.log('This Month:', thisMonth.pagination.total);

// Last month
const lastMonthStart = new Date();
lastMonthStart.setMonth(lastMonthStart.getMonth() - 1);
lastMonthStart.setDate(1);
const lastMonthEnd = new Date();
lastMonthEnd.setDate(0);
const lastMonth = await monei.transactions.getUserTransactions({
  startDate: lastMonthStart.toISOString().split('T')[0],
  endDate: lastMonthEnd.toISOString().split('T')[0],
  limit: 100
});

console.log('Last Month:', lastMonth.pagination.total);

// Custom range
const custom = await monei.transactions.getUserTransactions({
  startDate: '2024-01-01',
  endDate: '2024-01-31',
  limit: 100
});

console.log('January 2024:', custom.pagination.total);

Combine Multiple Filters

Combine filters for precise queries.
// Successful debits over ₦10,000 this month
const results = await monei.transactions.getUserTransactions({
  type: 'DEBIT',
  status: 'SUCCESS',
  minAmount: 10000,
  currency: 'NGN',
  startDate: '2024-02-01',
  endDate: '2024-02-29',
  sortBy: 'amount',
  sortOrder: 'desc',
  limit: 50
});

console.log('Matching Transactions:', results.pagination.total);

// Display results
results.transactions.forEach(tx => {
  console.log(`₦${tx.amount.toLocaleString()} - ${tx.narration}`);
  console.log(`  Date: ${new Date(tx.createdAt).toLocaleDateString()}`);
  console.log(`  Ref: ${tx.reference}`);
  console.log('');
});

// Failed transactions this week
const failed = await monei.transactions.getUserTransactions({
  status: 'FAILED',
  startDate: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
  endDate: new Date().toISOString().split('T')[0],
  limit: 20
});

console.log('Failed This Week:', failed.pagination.total);

// Credits (money in) over ₦5,000
const largeCredits = await monei.transactions.getUserTransactions({
  type: 'CREDIT',
  minAmount: 5000,
  currency: 'NGN',
  sortBy: 'createdAt',
  sortOrder: 'desc',
  limit: 20
});

console.log('Large Credits:', largeCredits.pagination.total);

Sorting

Sort transactions by different fields.
// Sort by date (newest first)
const newest = await monei.transactions.getUserTransactions({
  sortBy: 'createdAt',
  sortOrder: 'desc',
  limit: 20
});

// Sort by date (oldest first)
const oldest = await monei.transactions.getUserTransactions({
  sortBy: 'createdAt',
  sortOrder: 'asc',
  limit: 20
});

// Sort by amount (highest first)
const highestAmount = await monei.transactions.getUserTransactions({
  sortBy: 'amount',
  sortOrder: 'desc',
  limit: 20
});

// Sort by amount (lowest first)
const lowestAmount = await monei.transactions.getUserTransactions({
  sortBy: 'amount',
  sortOrder: 'asc',
  limit: 20
});

// Sort by last updated
const recentlyUpdated = await monei.transactions.getUserTransactions({
  sortBy: 'updatedAt',
  sortOrder: 'desc',
  limit: 20
});

Common Filtering Patterns

// Get all transactions for a specific month
async function getMonthlyReport(year, month) {
  const startDate = `${year}-${String(month).padStart(2, '0')}-01`;
  const lastDay = new Date(year, month, 0).getDate();
  const endDate = `${year}-${String(month).padStart(2, '0')}-${lastDay}`;
  
  const txns = await monei.transactions.getUserTransactions({
    startDate: startDate,
    endDate: endDate,
    limit: 1000
  });
  
  return txns;
}

// Usage
const feb2024 = await getMonthlyReport(2024, 2);
console.log('February 2024:', feb2024.pagination.total);

Best Practices

Specific Filters

Use specific filters to reduce response size

Date Ranges

Always use date ranges for large datasets

Limit Results

Use appropriate page limits (max 100)

Cache Results

Cache frequently accessed filter results

Sort Wisely

Sort by indexed fields (createdAt, amount)

Pagination

Always implement pagination for UX

Next Steps

Management

Learn transaction management basics

Webhooks

Set up real-time transaction notifications

Analytics

Analyze transaction patterns

Export

Export transaction data