The Flashnet SDK provides methods to query historical swap data, allowing you to track trading activity across the AMM, for specific pools, or for individual users.
Retrieve the trading history for a specific user. If no user public key is provided, it defaults to the client’s wallet public key.
Copy
Ask AI
async function getMySwapHistory() { try { // Gets history for the client's own wallet const history = await client.getUserSwaps(); console.log('My swap history:', history.swaps); } catch (error) { console.error('Failed to get my swap history:', error); }}async function getAnyUserSwapHistory(userPublicKey: string) { try { const history = await client.getUserSwaps(userPublicKey, { limit: 50, sort: "timestampDesc", }); console.log(`History for ${userPublicKey}:`, history.swaps); } catch(error) { console.error('Failed to get user swap history:', error); }}
All history methods support limit and offset for pagination, as well as other filters like startTime and endTime. Refer to the ListPoolSwapsQuery, ListGlobalSwapsQuery, and ListUserSwapsQuery types in src/types/index.ts for a full list of available filters.