AnonGTO API
AnonGTO API · guide

Review a session with batches and webhooks

Live requests are for one spot at a time. For a whole session, send a batch: one request with every spot, answered in the background, with a webhook when it is done.

1. Create the batch

curl
curl https://api.anongto.com/v1/batches \
  -H "Authorization: Bearer $ANONGTO_API_KEY" -H "Content-Type: application/json" \
  -d '{"webhook_url": "https://your-app.example.com/hooks/anongto",
       "metadata": {"session": "s-1042"},
       "requests": [
         {"mode": "ranges", "board": ["Jh", "9s", "4d"], "pot_bb": 5.5,
          "players": [{"seat": "BB", "stack_bb": 97.5, "range": {"text": "22-99, TT-JJ:0.5, A2s-A9s, ATs-AJs:0.6, K2s+, Q2s+, J4s+, T6s+, 96s+, 85s+, 74s+, 63s+, 53s+, 43s, A2o-AJo, K7o-KQo, Q8o+, J8o+, T8o+, 98o, 87o"}},
                      {"seat": "BTN", "stack_bb": 97.5, "range": {"text": "22+, A2s+, K2s+, Q4s+, J6s+, T6s+, 96s+, 85s+, 75s+, 64s+, 54s, A2o+, K8o+, Q9o+, J9o+, T8o+, 98o"}}], "actions": []},
         {"mode": "ranges", "board": ["Jh", "9s", "4d", "2c"], "pot_bb": 9.14,
          "players": [{"seat": "BB", "stack_bb": 95.68, "range": {"text": "22-99, TT-JJ:0.5, A2s-A9s, ATs-AJs:0.6, K2s+, Q2s+, J4s+, T6s+, 96s+, 85s+, 74s+, 63s+, 53s+, 43s, A2o-AJo, K7o-KQo, Q8o+, J8o+, T8o+, 98o, 87o"}},
                      {"seat": "BTN", "stack_bb": 95.68, "range": {"text": "22+, A2s+, K2s+, Q4s+, J6s+, T6s+, 96s+, 85s+, 75s+, 64s+, 54s, A2o+, K8o+, Q9o+, J9o+, T8o+, 98o"}}], "actions": [{"type": "check"}]}
       ]}'

2. Verify the webhook

When the last item is answered we POST { "type": "batch.completed", "data": { "batch": … } } to your URL. The AnonGTO-Signature header is t=<unix time>,v1=<HMAC-SHA256 of "t.body" with your webhook secret>. Your secret is on your account page. Reject anything older than five minutes.

Python (Flask)
import hmac, hashlib, os, time
from flask import Flask, request, abort

SECRET = os.environ["ANONGTO_WEBHOOK_SECRET"].encode()
app = Flask(__name__)

@app.post("/hooks/anongto")
def hook():
    parts = dict(p.split("=", 1) for p in request.headers["AnonGTO-Signature"].split(","))
    signed = f"{parts['t']}.".encode() + request.get_data()
    good = hmac.new(SECRET, signed, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(good, parts["v1"]) or abs(time.time() - int(parts["t"])) > 300:
        abort(400)
    batch = request.get_json()["data"]["batch"]
    queue_results_download(batch["id"])     # read them outside the request
    return "", 204

3. Read the results

GET /v1/batches/{id}/results returns up to 500 items a page, in request order. Each has status done (with the response) or failed (with the error, as /v1/solve would have answered). Follow next_offset until it is null.

Good to know

  • Webhooks are retried three times (after 10 seconds, 1 minute and 5 minutes) when your endpoint does not answer 2xx.
  • Up to ten unfinished batches per key at once.
  • Batch items do not use your per-minute rate or concurrency, only the daily quota.

Start building