BitFetch.io - Integrate Bitcoin & Cryptocurrency Data into Home Assistant! Beta Testers Needed!

Hello all!

Several of our team members, including myself, have been long time Home Assistant users and therefore we wanted to share and gather feedback for our new service with the Home Assistant community first, before we shared it anywhere else!

BitFetch is an API service that provides free & paid plans to access cryptocurrency market data from multiple exchanges, across hundreds of trading pairs. The API is uniform, so you don’t need one integration for Coinbase, and another for Binance and the responses are lightning fast. We plan to add more exchanges and data sources quickly, if you have a request, we’d LOVE to hear it!

During development, our entire team was using BitFetch APIs in Home Assistant in their own homes for everything from displaying the price of Ethereum in lovelace, to my project, having an RGB LED lightbulb change colors and brightness based on the price of Bitcoin.

BitFetch is brand new, the website was just finished this week, but the APIs have been in development for months. We thought the Home Assistant community was a great place to show off what we have built, find any potential bugs, and give back to the HA community.

Our 100% FREE plan was built with HA users in mind! For any HA users that need more data and more API Credits, we’re happy to offer HA users our PRO plan as well for free for multiple months in exchange for your feedback, just send us a message here on the HA forums and we will upgrade your account.

We have plans to create a custom component for HA (if the great developers in this community do not beat us to it first!), we would even be thrilled to see BitFetch supported natively in HA at some point in the future. But for now we will simply share my project that uses Node Red to update an RGB LED bulb based on the price of BTC every second.
Custom Component Now Available! See Below.

BitFetch was built for application developers, website owners, etc to show crypto data, but as passionate members of the HA community that automate every tiny thing around our homes, we want to fully support the individual HA user as well, and listen to your feedback.

We’d love to hear any and all feature requests, bugs found, or any other feedback. We’ll be monitoring this thread closely and are happy to answer any questions regarding the RGB Lightbulb project or any others you can think of!

BitFetch API Documentation: https://docs.bitfetch.io
BitFetch Website: https://bitfetch.io

BitFetch.io Custom Component is now available! We got some great feedback in the last 24 hours from HA users and the question we got most was “When will the custom component be ready!?”

Due to that feedback, one of our Engineers dedicated his Friday afternoon to learning how to build an HA component, and how to make it available on HACS.

Now, to use BitFetch in Home Assistant you simply need to:

  1. Get a FREE API Key by signing up at https://bitfetch.io
  2. Add the repository https://github.com/BitFetch/bitfetch-home-assistant as a custom repo in HACS (category: Integration)
  3. Install BitFetch via HACS
  4. Add something like this to your configuration.yml:
sensor:
  - platform: bitfetch
    pair: BTCUSD
    api_key: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 
    scan_interval: 1

Restart HA and you’ll have a brand new sensor you can use anywhere in HA!

More detailed Instructions: https://github.com/BitFetch/bitfetch-home-assistant

As always, we’re interested in hearing your feedback, suggestions, bug, reports, etc!

1 Like

Hello, you’re created good component for crypto exchange rates monitoring!
I’ve added minor changes to sensor.py (“unit_of_measurement” option), to easy generating history graphs.
Git pull is created: https://github.com/BitFetch/bitfetch-home-assistant/pull/2
How it looks like now in my HA:
image

Thanks for adding this, we’ve merged your changes!

1 Like

What is the cost of API requests?
I have free plan and “Monthly API Credits” are out already (10,510 of 10,000 is used) on 12 of October.
I have 3 pairs added in HomeAssistant with scan_interval: 300.

10,000 credits a month are completely FREE under the Free plan for all users, and as you see we generously allow users to go over that limit by about 5% before we disable access.

If you are querying 3 pairs every 5 minutes you would be using 12 credits, per hour, per pair, or 864 credits per day (12 * 24 * 3), which would only last just over 11 days before you ran out of Free credits.

The Pro Plan is $5/mo and gives you 1,000,000 (1 Million) credits a month, along with other benefits. We can also build a custom plan just for you if the Pro plan does not fit your needs exactly. Just DM us here or contact us via the support email in your BitFetch Account Dashboard and we will be happy to chat and get the perfect plan set up for your needs at the right price!

Note: If you signed up during our promo period in August and September, you likely have a $5 credit on your account currently, so you can try the PRO plan free for 1 month to try it out! No payment info needed for the trial.

Anymore updates on this? I curious if the betatesting is over and how did it work?

@gdreelin beta testing completed at the end of September. We have hundreds of customers now using BitFetch (not necessarily with HA). As far as we know everything is working as expected for all users, if you encounter any bugs or issues please don’t hesitate to DM us and we would be happy to help.

Hi,

Firstly thank you for the awesome custom component - It has been working a charm, but recently It is randomly loading only some of the sensors. For Eg. On restart of HA the BTC sensor will be present, and the ETH sensor will be missing. When restarting again, the opposite happens. These two pairs are only used as an example, but happens at random between all the pairs configured.

I have checked to ensure I have sufficient credits available on the API, and I am will within quota (967 / 10000)

I also have found the following in the logs:

2021-04-22 01:06:01 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up bitfetch platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.bitfetch.io', port=443): Read timed out. (read timeout=2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 205, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bitfetch/sensor.py", line 43, in setup_platform
    BitFetchData(pair, api_key).update()
  File "/config/custom_components/bitfetch/sensor.py", line 123, in update
    data = requests.request("GET", url + self.pair, timeout=2, headers=headers)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.bitfetch.io', port=443): Read timed out. (read timeout=2)
2021-04-22 01:06:01 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up bitfetch platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.bitfetch.io', port=443): Read timed out. (read timeout=2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 205, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bitfetch/sensor.py", line 43, in setup_platform
    BitFetchData(pair, api_key).update()
  File "/config/custom_components/bitfetch/sensor.py", line 123, in update
    data = requests.request("GET", url + self.pair, timeout=2, headers=headers)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.bitfetch.io', port=443): Read timed out. (read timeout=2)
2021-04-22 01:06:01 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up bitfetch platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.bitfetch.io', port=443): Read timed out. (read timeout=2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 205, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bitfetch/sensor.py", line 43, in setup_platform
    BitFetchData(pair, api_key).update()
  File "/config/custom_components/bitfetch/sensor.py", line 123, in update
    data = requests.request("GET", url + self.pair, timeout=2, headers=headers)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.bitfetch.io', port=443): Read timed out. (read timeout=2)
2021-04-22 01:06:01 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up bitfetch platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.bitfetch.io', port=443): Read timed out. (read timeout=2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 205, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bitfetch/sensor.py", line 43, in setup_platform
    BitFetchData(pair, api_key).update()
  File "/config/custom_components/bitfetch/sensor.py", line 123, in update
    data = requests.request("GET", url + self.pair, timeout=2, headers=headers)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.bitfetch.io', port=443): Read timed out. (read timeout=2)

@BitFetch Any suggestions / help will be appreciated.

Thank you!

PS: I’m running on an RPi4 using docker. Currently on version 2021.4.6. The internet connection is available on the container, and ample bandwidth available.

Deleted by me

We have recently updated the plugin to address these hangs. Please make sure you are updated to the latest version via HACS and let us know if this problem continues. Thanks!

I apologize for the slow reply - was out of town for a while. I have just updated HA & the plugin and the issue seems to persist.

I’m unable to reproduce this. However, as a potential fix, I’ve extended the timeout from 2 seconds to 5 seconds. This will hopefully give the plugin more time to load the initial state of the sensors.

Please update via HACS again, and see if this helps at all. Happy to continue debugging this with you until we find a solution.

Hi,

Thank you so much - That seems to have done it!

PS: Which file contains the timeout should the problem creep up again that I can tweak it locally. I understand that I will have to do it after each update, but it is a small effort to ensure this works.

Just a last question: Any specific reason for the short time outs? I see in the logs HA seems to use 15 seconds on most of the components.

Glad it helped!

The timeout is largely arbitrary and we could make it configurable. Some users are using BitFetch to update their sensors very frequently, such as every 2 or 5 seconds. If there is a temporary issue reaching the API a short timeout will retry quicker instead of waiting.

You can see here how to update the timeout: Update timeout · BitFetch/[email protected] · GitHub

The big issue I was experiencing was, that should the sensor timeout on initial startup, it does not show up in HA so the configured schedule is only running on the sensors which correctly started up.

If it starts up normally, as it is doing now, it is working a charm. :slight_smile:

Wunderfull solution. worked for one day because I copied the sample with a refresh rate of 1.
so After a day I was above the limits and now I have to wait another month. I changed the 1 to 3600.

thanks for the solution!