Skip to content

Instantly share code, notes, and snippets.

@itoldya
Created September 27, 2022 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itoldya/910e75589458c7a1369caf43f77fb1da to your computer and use it in GitHub Desktop.
Save itoldya/910e75589458c7a1369caf43f77fb1da to your computer and use it in GitHub Desktop.
Get transactions from CoinKeeper
const fetch = require("node-fetch");
const BATCH_SIZE = 5000;
const USER_ID = "...";
const AUTH = "...";
async function getTransactions(body) {
return fetch("https://coinkeeper.me/api/transaction/get", {
method: "POST",
headers: {
"Content-Type": "application/json",
Cookie: `__AUTH_cookie=${AUTH};`,
},
body: JSON.stringify(body),
}).then((r) => r.json());
}
async function getAllTransactions(acc = []) {
const data = await getTransactions({
userId: USER_ID,
take: BATCH_SIZE,
skip: acc.length,
});
acc = [...acc, ...data.transactions];
if (data.transactions.length) {
return getAllTransactions(acc);
}
return acc;
}
(async () => {
const transaction = await getAllTransactions();
console.log(transaction);
console.log(transaction.length);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment