Bitcoin Forum

Bitcoin => Project Development => Topic started by: TryNinja on June 29, 2019, 11:46:51 PM



Title: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on June 29, 2019, 11:46:51 PM
Now back online!

Inspired by btc-priceimg.herokuapp.com, I've create a (pretty much identical) page that generates an image with the address' current balance.

Why?

Because the original one doesn't accept bech32 addresses (they use Blockchain.info). Mine uses Blockstream's API, so bech32 addresses are allowed.

How to use it:

BItcoin Address:
Code:
https://btc.ninjastic.space/balance/YOUR-ADDRESS/HEX-COLOR

USD to BTC: (new)
Code:
https://btc.ninjastic.space/price/AMOUNT-IN-USD/HEX-COLOR?size=20

EUR to BTC: (new)
Code:
https://btc.ninjastic.space/price/AMOUNT-IN-EUR/HEX-COLOR?size=18&ticker=EUR

Options:
color, size and ticker are optional;
default color is black;
default ticker is USD.



Example 1:
https://btc.ninjastic.space/balance/bc1qfxj5fzzhkpnuyyezy9z7j7axja7n632d5wxzj6/ff0000

Result: https://btc.ninjastic.space/balance/bc1qfxj5fzzhkpnuyyezy9z7j7axja7n632d5wxzj6/ff0000

Example 2:
https://btc.ninjastic.space/price/250/ff0000?size=15

Result: https://btc.ninjastic.space/price/250/ff0000?size=15

Example 3:
https://btc.ninjastic.space/price/250/ff0000?size=16&ticker=EUR

Result: https://btc.ninjastic.space/price/250/ff0000?size=16&ticker=EUR

Example 4: (new)
https://btc.ninjastic.space/price/3P3QsMVK89JBNqZQv5zMAKG8FK3kJM4rjt/ff0000?size=16&ticker=BRL

Result: https://btc.ninjastic.space/price/3P3QsMVK89JBNqZQv5zMAKG8FK3kJM4rjt/ff0000?size=16&ticker=BRL




Changelog:
Code:
06/30 - changed the size option to be a url query
06/30 - added a ticker option (suggested by @klaaas)
06/30 - added usd to btc price image, added size customization (suggested by @OmegaStarScream)
06/29 - released



If you have any suggestions, please let me know.


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: joniboini on June 30, 2019, 05:08:32 AM
The images that you posted above shows as invalid image for me. I use Brave with dnscrypt btw. Not sure if the problem is on my end or the code.


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: OmegaStarScream on June 30, 2019, 06:42:13 AM
The problem should be from his end.

For suggestions, do you have any plans for the other features other than the one for checking balance? Like:

Code:
https://btc-priceimg.herokuapp.com/img/10.00/00f

I understand that yours is supposed to be for SegWit support and the above command is kinda irrelevant but, having all-in-one tool can be useful.

I also think that you should make the font in the image a little bit bigger.


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on June 30, 2019, 11:08:49 AM
The images that you posted above shows as invalid image for me. I use Brave with dnscrypt btw. Not sure if the problem is on my end or the code.

Can you try again? Maybe it was because I enables HTTPS but forgot to change my urls. (also try ctrl + f5 to clear your browser’s cache)

It’s showing up fine for me.

For suggestions, do you have any plans for the other features other than the one for checking balance? Like:

Code:
https://btc-priceimg.herokuapp.com/img/10.00/00f

I understand that yours is supposed to be for SegWit support and the above command is kinda irrelevant but, having all-in-one tool can be useful.

I also think that you should make the font in the image a little bit bigger.
It’s not irrelevant. I can work on that. :)

It also makes sense since I named it "Bitcoin Price Image".


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on June 30, 2019, 12:35:46 PM
@OmegaStarScream done!

I've increased the default size a little bit, added an option to choose a custom size and the usd to btc endpoint.

New format is:
https://btc.ninjastic.space/balance/ADDRESS/HEX-COLOR/SIZE for address' balance.
https://btc.ninjastic.space/price/AMOUNT/HEX-COLOR/SIZE for usd to btc.

(color and size are optional)

 :)


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: klaaas on June 30, 2019, 01:28:47 PM
Works good over here, nice. Maybe a euro to btc version could be added.
Curious what is used as the source to pull the price from ?


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on June 30, 2019, 02:42:24 PM
Works good over here, nice. Maybe a euro to btc version could be added.
Curious what is used as the source to pull the price from ?
I'm using bitcoinaverage.com's API.

Works good over here, nice. Maybe a euro to btc version could be added.
Curious what is used as the source to pull the price from ?
Done. Now there is an ticker option (default is USD).

Since I noticed I would need to start adding a lot of params (like/this/and/it/would/be/huge/and/weird), I've added it as a query param (?ticker=USD).

Example:
https://btc.ninjastic.space/price/1250/ff0000?ticker=EUR

You can use USD, EUR, AUR, BRL, etc...


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: bitmover on July 01, 2019, 03:45:59 AM
Nice job.

Why don't you add instructions about how to use your Price Image script in https://btc.ninjastic.space/ (it may even be your OP here)

It would be nice to have instructions and more detailed information, then just enter commands based on this thread.


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on July 04, 2019, 11:53:14 PM
Bump :)


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: Stedsm on July 10, 2019, 05:28:23 AM
Checked this - https://btc.ninjastic.space/balance/bc1q3zedphng6fckmal76g89n6e3ludvw4hyfwpysn

But received a completely blank (black) page there without showing any amount whereas I've got some change amount in it. Is there any minimum value set that will only be shown, for e.g.; 1 mBTC or more?

EDIT: My mistake I didn't add the hex color I wanted to see it in. It worked out well, great job. :)

https://btc.ninjastic.space/balance/bc1q3zedphng6fckmal76g89n6e3ludvw4hyfwpysn/ff0000
Did the job for me. I'm glad we don't need a specific amount of BTC in our wallet to be able to use this and it has given significance to SegWit which I don't see in most of the explorers too (blockchain.info is still not allowing SegWit addresses to let us watch our transactions and balance in their explorer).

P.S.: Can you also create a BTC-to-ALT provider which could show our balance's value in our choice of alt based on a specific exchange?


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on July 10, 2019, 05:57:09 AM
P.S.: Can you also create a BTC-to-ALT provider which could show our balance's value in our choice of alt based on a specific exchange?
I’ll take a look at this tomorrow. :)

So... a specific address balance in your chosen alt, right? E.g the address 1Ninja... balance (1 BTC) in ETH?


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: Stedsm on July 10, 2019, 02:37:16 PM
P.S.: Can you also create a BTC-to-ALT provider which could show our balance's value in our choice of alt based on a specific exchange?
I’ll take a look at this tomorrow. :)

So... a specific address balance in your chosen alt, right? E.g the address 1Ninja... balance (1 BTC) in ETH?

Yeah, you got that right.
Not just ETH, but a few more or even all of the alts (just like you did with the Fiat currencies as I can watch almost any Fiat currency's conversion to BTC).

One last request, can you also add alts in opposite and put the price in alts and see how much BTC is it worth (like we put price in fiat)? Can be said vice-versa of what I asked first.


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on May 29, 2020, 07:18:33 PM
I don't think there is anything wrong with bumping this old thread, right? Completly forgot I had created it. :D

The project is back online after being requested here (https://bitcointalk.org/index.php?topic=5248905.msg54442461#msg54442461). I talked about how my API was limited to 5k requests/month for the price endpoint, but it looks like BitcoinAverage just randomly gave me 80k requests/month, so we are good. :D

Now you can get an address value in a currency by using /price/ with the address instead of a number:
https://btc.ninjastic.space/price/3P3QsMVK89JBNqZQv5zMAKG8FK3kJM4rjt

And now you can also use different tickers for the whole /price/ endpoint (default is USD):
https://btc.ninjastic.space/price/3P3QsMVK89JBNqZQv5zMAKG8FK3kJM4rjt?ticker=EUR
https://btc.ninjastic.space/price/250?ticker=EUR


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: bL4nkcode on September 26, 2020, 01:45:11 AM
I got here from searching, but one thing I observed is this (below). An error, and should be "0.023"ish (in decimal, base in coingecko rate) instead of 266*****.** BTC.

USD to BTC
Code:
https://btc.ninjastic.space/price/AMOUNT-IN-USD/HEX-COLOR?size=14

https://btc.ninjastic.space/price/250/ff0000?size=14

250 USD = https://btc.ninjastic.space/price/250/ff0000?size=15

Same thing with the one with other ticker parameter
Code:
https://btc.ninjastic.space/price/250/ff0000?size=16&ticker=EUR

250 USD = https://btc.ninjastic.space/price/250/ff0000?size=15&ticker=EUR


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on September 26, 2020, 12:07:04 PM
~
I changed the API and some things got messed up. Those links were actually returning the BTC value in USD (but with "BTC" at the end). That's fixed for now (USD > BTC), but I should honestly just rewrite the whole thing.

Looks like it's swapped from USD/BTC to BTC/USD. Also if you look closely when you use link to get EUR/BTC price, you got BTC/USD instead.
The EUR ticket is not working (there is a warning in the OP).


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on September 26, 2020, 12:22:11 PM
Sorry, shouldn't assume you already fixed it (since the thread last updated few months ago) before it broke again.
I haven't touched the code in a while. I only cared about keeping the primary function working (address balance to BTC and USD), since that's what most people use.

What messed up everything was BitcoinAverage (the previous API I used) wanting me to pay for a subscription. I wrote everything based on their API and changing it now would need a whole rewrite anyways. I was lazy at the time so just changed what I had to change to keep the basics. :D

I'll make everything work again when I have some free time.


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: bL4nkcode on May 28, 2021, 02:40:58 PM
Found my thread that uses this feature and wonder why the image doesn't load and drive me to see this thread. Seems like there's an error and it shows 502 bad gateway status.


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on May 28, 2021, 02:59:14 PM
Seems like there's an error and it shows 502 bad gateway status.
Thanks, it should be working now.

edit: Give it some time for the cache to clear.


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: bL4nkcode on May 28, 2021, 06:28:10 PM
Seems like there's an error and it shows 502 bad gateway status.
Thanks, it should be working now.

edit: Give it some time for the cache to clear.
All goods now. Thank you!


Title: Re: Bitcoin Price Image v2 (supporting Segwit addresses)
Post by: TryNinja on May 14, 2023, 06:44:05 PM
And... we're back!

The API is working again (and I'll keep it that way).