This repository has been archived on 2026-05-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
clickthrough/examples/quickstart.py
Paul Wähner aced5be25e
All checks were successful
python-syntax / syntax-check (push) Successful in 7s
feat: migrate to v2-only API and unified response envelope
2026-05-03 19:11:11 +02:00

40 lines
953 B
Python

import os
import requests
BASE_URL = os.getenv("CLICKTHROUGH_URL", "http://127.0.0.1:8123")
TOKEN = os.getenv("CLICKTHROUGH_TOKEN", "")
SCREEN = int(os.getenv("CLICKTHROUGH_SCREEN", "0"))
headers = {}
if TOKEN:
headers["x-clickthrough-token"] = TOKEN
def main():
health = requests.get(f"{BASE_URL}/health", headers=headers, timeout=10)
health.raise_for_status()
print("health ok:", health.json().get("ok"))
observe = requests.post(
f"{BASE_URL}/v2/observe",
headers=headers,
params={"screen": SCREEN},
json={
"mode": "screen",
"include_image": False,
"ocr_mode": "none",
},
timeout=20,
)
observe.raise_for_status()
payload = observe.json()["data"]
print("observation_id:", payload["observation_id"])
print("region:", payload["region"])
print("timing_ms:", payload["timing_ms"])
if __name__ == "__main__":
main()