Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: mahurovihamilo on May 17, 2024, 12:55:45 AM



Title: Outdated API code translation
Post by: mahurovihamilo on May 17, 2024, 12:55:45 AM
Hi y'all ...

So I am trying to convert some code that uses an outdated API to any other API service but I need some help desciphering what the original code is intending to do, so here it is:


listfile="\n".join(f'wget -qO- https://chain.so/api/v2/get_tx_spent/BTC/{line.rstrip()[:]} > index.data' for line in myfile)




So I know all APIs are different, but not having access to the original API documents I am having to guess (here it is my question): What data is the code trying to access from the online block explorer?


Is it the transaction hash? is it all transactions for that wallet? is it outputs of transactions? When I know what the code is tring to find, Ill be able to replicate that for another API that I actually have access to.

Please give me your reading of it. many thanks. m.


Title: Re: Outdated API code translation
Post by: pooya87 on May 17, 2024, 03:50:58 AM
v2 is a deprecated API version on chain.so and the `get_tx_spent` simply return the transactions related to the given address. It is replaced by the `transactions` endpoint like this:
Code:
/api/v3/transactions/{{network}}/{{address}}/{{page}}
You can see what it returns in the API docs https://chain.so/api/ the old response was similar to this one as well. It did return transaction hashes alongside some other information such as the amount transferred and the signature/witness in that transaction.


Title: Re: Outdated API code translation
Post by: mahurovihamilo on May 17, 2024, 09:57:18 PM
Hello pooya87

Thank you, that clarifies everything. Now I'll be able to try to replicate that call from another block explorer because chain.so now charges $150 a month  to get an API key...