Created
September 27, 2022 03:28
-
-
Save itoldya/910e75589458c7a1369caf43f77fb1da to your computer and use it in GitHub Desktop.
Get transactions from CoinKeeper
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 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