Skip to content

Latest commit

 

History

History
114 lines (65 loc) · 4.13 KB

USAGE.md

File metadata and controls

114 lines (65 loc) · 4.13 KB

Bitcoin Price Image Generator

The bitcoin price image generator is a simple tool that creates a dynamic image of a price in BTC, based on a fixed USD price. The resulting image can be embedded in a forum post, for example, and it will always show an up-to-date BTC equivalent price. This is useful when you want to show a price for something in BTC, but you want the price to be pinned to a USD value (and not have to update your post every day as the BTC/USD exchange rate fluctuates). This tool relies on the global weighted average from BitcoinAverage.

Problems? Suggestions? Open an issue.

Source available on GitHub.

The advanced version of the tool allows for a choice of currency (anything supported by BitcoinAverage). Read about it below.

Usage

Simply build a URL of the form:

http://btc-priceimg.herokuapp.com/img/<price_in_usd>

Where <price_in_usd> is the price you want in USD.

You can also add an optional color argument to change the color of the text:

http://btc-priceimg.herokuapp.com/img/<price_in_usd>/<color>

The color code should be an html-like hex code (for white: ffffff or fff or simply f). See wikipedia for more info. The background of the image will be transparent.

Example

Say you want to sell an item for $10. You can generate an image using:

http://btc-priceimg.herokuapp.com/img/10.00

Which will yield the image:

If you want to change the color (to more closely match the text in your forum post, for example), use:

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

Which yields:

You can then embed the image in your post using that URL. In BBCode, this would be:

[img]http://btc-priceimg.herokuapp.com/img/10.00[/img]

Higher resolution images can be generated by including a device pixel ratio in the url path:

http://btc-priceimg.herokuapp.com/img@2x/10.00

Which yields:

Note that this will require scaling the image down using CSS. In the above example, the <img> tag includes the inline style height: 11px.

Advanced Version

The advanced version is available to allow changing the display currency, and allow for fancier options in the future. The URL format is of the form:

http://btc-priceimg.herokuapp.com/advimg?price=<price>&currency=<currency>&color=<color>&dpr=<dpr>

Arguments:

  • price: the desired price in USD, e.g. 10.0. Include a currency code to use something else as your reference, like 1.5EUR.
  • currency: e.g. BTC, ETH, LTC. Defaults to BTC.
  • color: same as in the basic version above.
  • dpr: device pixel ratio, e.g. 2x. Defaults to 1x.

Example:

http://btc-priceimg.herokuapp.com/advimg?price=10USD&currency=ETH&color=f00&dpr=1x

Balance Checker

An additional tool allows you to check the balance of any bitcoin address using the API from blockchain.info. Simply build a URL of the form:

http://btc-priceimg.herokuapp.com/balance/<address>/<color>

As in the basic version above, the color argument is optional and accepts html-like hex codes.

Example:

http://btc-priceimg.herokuapp.com/balance/1E765eZrLQnhANCmgBSu3Hy2DbZktEFQ7h

This endpoint also includes a high resolution form:

Example:

http://btc-priceimg.herokuapp.com/balance@2x/1E765eZrLQnhANCmgBSu3Hy2DbZktEFQ7h

by Ford Hurley (1E765eZrLQnhANCmgBSu3Hy2DbZktEFQ7h)