Skip to content

Instantly share code, notes, and snippets.

@dgarcia360
Created February 8, 2019 09:05
Show Gist options
  • Save dgarcia360/dc64e73c7b60606d93d914d536c8fce6 to your computer and use it in GitHub Desktop.
Save dgarcia360/dc64e73c7b60606d93d914d536c8fce6 to your computer and use it in GitHub Desktop.
Get all transactions from an account NIS1
import fetch from 'node-fetch';
const address = "" //replace with addres;
const pageSize = 100;
let transactions = [];
const nextPage = () => {
getAllTransactions(address, pageSize, transactions[transactions.length - 1].meta.id, nextPage)
};
const getAllTransactions = (address, pageSize, id, resolve) => {
let id_formatted = '';
if (id){
id_formatted = "&id=" + id;
}
fetch("http://san.nem.ninja:7890/account/transfers/incoming?address=" + address + "&pageSize=" + pageSize + id_formatted)
.then(res => {
res.json().then( response => {
transactions = transactions.concat(response.data);
if (response.data.length == pageSize) {
resolve();
} else{
// Print to csv here
console.log(transactions);
console.log(transactions.length);
}
});
})
.catch(err => {
console.log(err);
})
};
getAllTransactions(address, pageSize, null, nextPage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment