I'm trying to write an app to track my gains/losses for tax purposes based on the swaps I've made using Bscscan APIs. I can easily retrieve all the swaps I've made using one of BscScan "accounts" module api endpoint (Get a list of 'BEP-20 Token Transfer Events' by Address to be exact). Here's an example of the body response:
{
"status": "1",
"message": "OK",
"result": [{
"blockNumber": "2304192",
"timeStamp": "1605585978",
"hash": "0x7a5abf86c82d3f97a40dd841a9f2089fbe3ac1332157c01bd1a1d89f575c45fc",
"nonce": "57",
"blockHash": "0x703438fd8ba435996895a6b9b711934cc590c3e9297a7066419aa88dd9d83acc",
"from": "0x641414e2a04c8f8ebbf49ed47cc87dccba42bf07",
"contractAddress": "0xc9849e6fdb743d08faee3e34dd2d1bc69ea11a51",
"to": "0x7bb89460599dbf32ee3aa50798bbceae2a5f7f6a",
"value": "27605634758857128698365",
"tokenName": "Bunny Token",
"tokenSymbol": "BUNNY",
"tokenDecimal": "18",
"transactionIndex": "2",
"gas": "5000000",
"gasPrice": "20000000000",
"gasUsed": "2312130",
"cumulativeGasUsed": "2475576",
"input": "deprecated",
"confirmations": "8172919"
}
]
}
So the value input ("value": "27605634758857128698365") gives the value in the underlying coin "currency" - in this case "Bunny Token" - but without knowing the quantity of that coin bought, I can't determine the cost basis of that transaction. I've looked at other bscscan APIs but I couldn't find any that would could help me retrieve the price of the coin for a given transaction.
Does anyone know if there's a way to retrieve the price of a coin (or the quantity bought) based on the transaction data using bsccan api?
TIA