Translating old API code

2 replies 418 views
nickaltMember
Posts: 32 · Reputation: 129
#1Mar 6, 2017, 11:21 PM
Hey everyone... I'm working on translating some code that relies on an old API into something for a different API service, but I could really use some help understanding what the original code is doing. Here’s the code: listfile="\n".join(f'wget -qO- https://chain.so/api/v2/get_tx_spent/BTC/{line.rstrip()[:]} > index.data' for line in myfile) I get that all APIs have their own quirks, but since I can't access the original API documentation, I'm kinda left guessing. So here’s my question: What kind of data is this code trying to pull from the block explorer online? Is it the transaction hash? Does it pull all transactions for that specific wallet? Or is it just the outputs of certain transactions? Once I figure out what this code is aiming for, I can find a way to replicate that with another API I can actually use. Would love to hear your thoughts on this. Thanks a ton! m.
6 Reply Quote Share
im_apeHero Member
Posts: 629 · Reputation: 3824
#2Mar 7, 2017, 03:20 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: 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.
4 Reply Quote Share
nickaltMember
Posts: 32 · Reputation: 129
#3Mar 7, 2017, 07:28 AM
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...
4 Reply Quote Share

Related topics