Aw-client for Python fails to connect to the API

Hello.

First off, thanks to the maintainers for the very cool project, It’s helped me understand my habits.

I’m messing around, and grabbed a copy of the Python aw-client and:

  1. Ran the cli aw-client buckets
  2. Attempted to experiment in the Python REPL:

from aw_client import ActivityWatchClient
from pprint import pprint

aw = ActivityWatchClient()
pprint(aw.get_buckets())

Both error out with:

requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘127.0.0.1’, port=5600): Max retries exceeded with url: /api/0/buckets/ (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7f21cdefa220>: Failed to establish a new connection: [Errno 111] Connection refused’))

ActivitiyWatch is running minimized in the tray, and the web-ui works fine. I was able to connect to the API and query perfectly fine by pulling up a browser console and fetch('http://localhost:5600/api/0/buckets').

Would appreciate any help on what I might be getting wrong :slight_smile:

Hm, that sounds strange. Since it’s clear that it’s the same address and port when running it in python and in the browser, there must be something that denies the request when running in the python environment. Not sure what that would be though, maybe if you run the python code inside some kind of container or VM but that sounds far fetched. I assume that the watchers work? They use the same library, so there must be something different with your development environment.