Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: glascake on October 13, 2021, 02:32:32 PM



Title: Check address balance api
Post by: glascake on October 13, 2021, 02:32:32 PM
Hello community,
I am looking for a api exactly like this one:
https://blockchain.info/rawaddr/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD
All I need is the "total_received" :/
sadly my server ip gets banned after a few requests.
Any alternative?
If you suggest a selfhosted solution it has to run on win and linux.

PS: I cannot run electrum or download the whole blockchain.


Title: Re: Check address balance api
Post by: NeuroticFish on October 13, 2021, 03:01:22 PM
Hello community,
I am looking for a api exactly like this one:
https://blockchain.info/rawaddr/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD
All I need is the "total_received" :/
sadly my server ip gets banned after a few requests.
Any alternative?
If you suggest a selfhosted solution it has to run on win and linux.

PS: I cannot run electrum or download the whole blockchain.

Since you asked for received, here you are: https://chain.so/api/v2/get_address_received/BTC/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD
The result is in bitcoin, not satoshi, but I hope that's not a problem.

For actual balance you may need get_address_balance instead of get_address_received.
I'll add:
* docu is https://chain.so/api/
* 300 requests/minute are free-of-charge for now; try to not get over that value, else they may ban you too  :D


Title: Re: Check address balance api
Post by: PrimeNumber7 on October 13, 2021, 08:45:05 PM
PS: I cannot run electrum or download the whole blockchain.
If this is true, you will ultimately need to pay to receive access to this information. When you use an API, you are ultimately using someone else's resources and data. Many APIs have a "free" tier in which devs can test the API and use it in low volumes.


Title: Re: Check address balance api
Post by: HCP on October 14, 2021, 01:35:09 AM
If you suggest a selfhosted solution it has to run on win and linux.

PS: I cannot run electrum or download the whole blockchain.
Any self-hosted solution will likely involve Bitcoin Core and downloading the whole blockchain. There isn't really any other way to be able to check "random" address balances without having the entire blockchain data to be able to scan/parse.

If you are unable to host this data locally, then you'll either need:

1. to rely on API's hosted elsewhere
or
2. host the data remotely (ie. on a rented server etc)


Given it appears that you're looking for a "free" solution, then option #1 is probably your best bet... unfortunately, as mentioned above, "free" API's are going to come with limitations. Usually on the number of requests able to be made in a specific time period. The only way around those limits will generally require having a paid account/subscription.


What sort of volume of requests are you looking at making? ???


Title: Re: Check address balance api
Post by: NotATether on October 14, 2021, 08:08:39 AM
I spoke with Getblock.io admins and they said it's possible to do with their API (their free tier, definitely).

Their BTC endpoint is https://btc.getblock.io/mainnet/ but you need an API key to access it which you get from creating an account. They do give you 40k free requests per month however. You can apparently give it bitcoind JSON-RPC requests - the same ones as Bitcoin Core, even! (It just passes them on to their node).


Title: Re: Check address balance api
Post by: glascake on October 14, 2021, 06:52:52 PM
@NotATether that is awesome

@HCP you are right this is limiting, but relying on an api to check balance isnt that bad.
for the beginning i am ofcourse looking for a free solution. but i have no problem paying once my shop gets profitable. Im justing trying to reduce the upfront cost.

I think @NeuroticFish 's solution might be the best, I think 5 requests per second might be enought. I am not too optimistic :D


Title: Re: Check address balance api
Post by: PawGo on October 14, 2021, 07:06:07 PM
Hello community,
I am looking for a api exactly like this one:
https://blockchain.info/rawaddr/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD
All I need is the "total_received" :/
sadly my server ip gets banned after a few requests.

There is simpler one:
Code:
https://blockchain.info/balance?active=1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD
which produces
Code:
{"1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD":{"final_balance":4654010,"n_tx":16,"total_received":4654010}}

BUT! You may ask for several addresses at the same time:
Code:
https://blockchain.info/balance?active=1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD,12g7ex6Grdt4FUAmXoZxwN4a4Pbt8SkKT2

I do not know how many requests you need to launch, but in my program I check 10 addresses every 2 seconds and it works - I have never been blacklisted.


Title: Re: Check address balance api
Post by: glascake on October 14, 2021, 08:06:26 PM
@PawGo do you request 10 address every 2 seconds so:
A) 1 request with multiple addresses
or B) 10 requests with one address each


Title: Re: Check address balance api
Post by: PawGo on October 14, 2021, 08:13:35 PM
@PawGo do you request 10 address every 2 seconds so:
A) 1 request with multiple addresses
or B) 10 requests with one address each

A


Title: Re: Check address balance api
Post by: glascake on October 14, 2021, 09:06:11 PM
@PawGo
Hm, their site states 1request/10sec
https://www.blockchain.com/api/q


im going to use the other suggested api