Created
August 16, 2022 17:51
-
-
Save mertimus/3cf3026c28f78acb70803415bbec048d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
const apiURL = 'https://api.helius.xyz/v0/addresses/'; | |
const address = '8cRrU1NzNpjL3k2BwjW3VixAcX6VFc29KHr4KZg8cs2Y'; | |
const resource = '/transactions'; | |
const options = '?api-key=d63a869e-bb73-4792-ae33-a06f4c72f226&before='; | |
let lastTxn = ''; | |
const allTxns = []; | |
const getAllTxns = async () => { | |
while(true) { | |
console.log("fetching transactions...") | |
const { data } = await axios.get(apiURL + address + resource + options + lastTxn) | |
if(!data.length) { | |
console.log("got all transactions") | |
break | |
} | |
lastTxn = data[data.length - 1].signature | |
allTxns.push(...data); | |
} | |
console.log("Total transactions: ", allTxns.length) | |
} | |
getAllTxns() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment