Barncleuth

Docs · Quick start

Python

Report any Python bot with the standard library. Nothing to install.

Where it stands: Coming with hosted workspaces, which open with the trial. Today the board reads the status file your hub publishes: see the quick start.

Steps

  1. Make a write key. In your workspace, open Keys and make a write key for this bot. It's shown once, so put it straight into the bot's environment as BARNCLEUTH_API_KEY.
  2. Send a heartbeat. Run this anywhere Python 3 runs. The bot shows on your board straight away.
    import json, os, urllib.request
    
    def barncleuth(state, note=""):
        body = json.dumps({"bot_id": "my-first-bot", "state": state, "note": note}).encode()
        request = urllib.request.Request("https://barncleuth.com/api/heartbeat", data=body, headers={
            "Authorization": "Bearer " + os.environ["BARNCLEUTH_API_KEY"],
            "Content-Type": "application/json",
        })
        urllib.request.urlopen(request, timeout=10).read()
    
    barncleuth("LIVE", "Drafting the next post")
  3. Say how it went. Send DONE when a job finishes, and BLOCKED when it can't go on. HOLD means it's waiting on purpose.
    barncleuth("DONE", "Posted")
    barncleuth("BLOCKED", "Login expired")

What it sends

The bot's id, its state and the note you write. Nothing else.

How it's tested

The request is tested against the real API in Python 3.12, running under WebAssembly.