Download trades and payment data from the Stellar blockchain network as a CSV file for accounting purposes.
Stellar Downloader uses Node and the Stellar Javascript SDK to pull payments and effects from Horizon.
It uses the /effects endpoint to get all payments and trades, ordering them by the paging_token in ascending order.
It uses the /payments endpoint to fill in data that is unavailable from the /effects endpoint such as the initial funder of an account or the counterparty of a payment.
Everytime it encounters a new trustline, it adds it to the list of headers and prints out the headers to stdout. From that point on, it always prints the cumulative balance of that asset in a new column on the right. In this manner, you will always have the latest balance for all assets on each row in CSV format.
Note: This script will not include any fees paid by the account, and as such, balances for XLM may be slightly off.
This is what the script outputs:
- trades and payments to
stdoutin CSV format. - column headers to
stdoutin CSV format. It prefixes headers with-so it can be removed usinggrepin the bash script. See the How to Run (Advanced) section for more details. - new accounts to
stderr.
Note: This script will not include any path_payments made by the account at this point in time, although you can easily update the script to include this.
Note: This script will not include any fees paid by the account, and as such, balances for XLM may be slightly off.
- You can clone the repo by running the following command:
git clone git@github.com:nikhilsaraf/stellar-downloader.git
- Make sure you install Node.js
- Set up the Stellar Javascript SDK by installing it from npm:
npm install --save stellar-sdk
Run the trades.js script for your account (replace GA... with your account):
node trades.js GA...
You can redirect stdout and stderr to files as desired. See the How to Run (Advanced) section below for more details.
This process will allow you to spider an account, i.e. you can pull data from the initial account as well as all accounts created by the initial account. This will create N files, 1 per account. Note the script will modify your input file, so be careful if you run it more than once.
- create a new file called
newAccounts.txtwith the initial account you want to start with on the first line as follows (replaceGA...with your account):new account: GA.... - run the bash script
runForAccounts.shas follows:./runForAccounts.sh newAccounts.txt
Please feel free to ask questions by opening an issue or to contribute to the code using a Pull Request.