Author

Topic: How to determine the sender of BTC through an API (Read 241 times)

hero member
Activity: 1540
Merit: 759
Thank you so much and our reply was helpful. However, assuming I wanted using a script on chron, to check for transations in my wallet from an address, can that be possible?

You're probably best mentioning the programming language you plan on using for this (whether it be PHP, python etc) and then we'll go from there. Many of us can provide examples of something that could technically be run automatically every x minutes.
jr. member
Activity: 38
Merit: 19
Thank you so much and our reply was helpful. However, assuming I wanted using a script on chron, to check for transations in my wallet from an address, can that be possible?
You could, for example, hit Blockcypher's address API endpoint[1] to get the latest transaction and then use it to hit the endpoint posted above to get the data you need. Then do the rest of the handling on your code.

[1] https://api.blockcypher.com/v1/btc/main/addrs/1ArgjWtWL8a2yshyeJUqtTtqgqKpZFGst5

the main problem is parsing the JSON response that the API sends back which would require additional libraries that are designed to do that, and i don't think it is possible to do this with a simple script.

If you're writing a shell script, you can use the jq tool for parsing the response and extracting the field(s) you want: https://stedolan.github.io/jq/tutorial/
legendary
Activity: 4298
Merit: 3209
I don't know what your goal is, but it might be useful to remember that bitcoins don't have to come from an address. Also, expecting bitcoins to come from a particular address might be problematic because the sending wallet generally decides which address(es) to use.
legendary
Activity: 2758
Merit: 6830
the main problem is parsing the JSON response that the API sends back which would require additional libraries that are designed to do that, and i don't think it is possible to do this with a simple script.
Not really. You can parse a JSON response with pretty much every existing programming language (python, js, php, etc...) without any additional library.
legendary
Activity: 2114
Merit: 1292
There is trouble abrewing
Thank you so much and our reply was helpful. However, assuming I wanted using a script on chron, to check for transations in my wallet from an address, can that be possible?
You could, for example, hit Blockcypher's address API endpoint[1] to get the latest transaction and then use it to hit the endpoint posted above to get the data you need. Then do the rest of the handling on your code.

[1] https://api.blockcypher.com/v1/btc/main/addrs/1ArgjWtWL8a2yshyeJUqtTtqgqKpZFGst5

the main problem is parsing the JSON response that the API sends back which would require additional libraries that are designed to do that, and i don't think it is possible to do this with a simple script.
legendary
Activity: 2758
Merit: 6830
Thank you so much and our reply was helpful. However, assuming I wanted using a script on chron, to check for transations in my wallet from an address, can that be possible?
You could, for example, hit Blockcypher's address API endpoint[1] to get the latest transaction and then use it to hit the endpoint posted above to get the data you need. Then do the rest of the handling on your code.

[1] https://api.blockcypher.com/v1/btc/main/addrs/1ArgjWtWL8a2yshyeJUqtTtqgqKpZFGst5
newbie
Activity: 14
Merit: 0
Thank you so much and our reply was helpful. However, assuming I wanted using a script on chron, to check for transations in my wallet from an address, can that be possible?
legendary
Activity: 2114
Merit: 1292
There is trouble abrewing
Blockcypher API includes the "sender's" address in its API response.
for example from the last block:
https://api.blockcypher.com/v1/btc/main/txs/499003ee50065a93bd786f792e3f72f99c8d308940fa1e5937178650a6a80fa2?limit=50

the "1ArgjWtWL8a2yshyeJUqtTtqgqKpZFGst5" is the sender's address. you will find each address in "inputs" list under "addresses" of that input.

ps. if the payment that you receive is important you may want to start running your own full node or at least an SPV node instead of relying on centralized services such as blockchain APIs.
newbie
Activity: 14
Merit: 0
Assuming I was expecting two BTC transactions of the same amount from different wallet addresses. is there an available API I can use to check which of the two addresses made the transaction?
Jump to: