Get started
Quick start
Five steps take you from a key to a solved flop and its turn.
In short
- You need a test key, and curl, Python or Node. A test key is free.
- Each step has one sample. Choose one language and stay with it: the samples build on each other.
Before you start: what each language needs
Choose one language and follow its samples through all five steps: the samples of one language build on each other. Work in one new folder and one terminal window. Every language needs the two export lines of step 1 in that terminal, and the file spot.json of step 2 in that folder.
- curl
- You need
curlandjq. Check withjq --version. To install jq:brew install jqon macOS,sudo apt install jqon Ubuntu. Paste each sample into the terminal, step after step. On Windows use WSL or Git Bash, or follow the Python or JavaScript samples. - Python
- You need Python 3 and the
requestspackage: the three lines below install it into the folder. Put the samples of all steps in one file,quickstart.py, in order, and runpython3 quickstart.py. - JavaScript
- You need Node 18 or later. Check with
node --version. There is nothing to install. Put the samples of all steps in one file,quickstart.mjs, in order, and runnode quickstart.mjs.
python3 -m venv .venv source .venv/bin/activate pip install requests
- In PowerShell, write
$env:GECKO_API = "https://api.gtogecko.com"and$env:GECKO_KEY = "gecko_test_..."in place of the twoexportlines. - The terminal of macOS runs zsh. It prints
command not found: #for a comment line in a shell sample. That is harmless, andsetopt interactivecommentsstops it. - The Python that comes with macOS prints a
NotOpenSSLWarningline. That is harmless too.
Step 1 of 5
Get a key
- Open the console and sign in with Google, or with the email address and password of your GTO Gecko account.
- Fill in “Create your API account”: your name, your company and your country, and accept the Terms. The API is for businesses: an account needs a company name, and the payment page asks for the company's address and tax number.
- Press “Create key”, choose the type Test and copy the key. It is shown one time. A test key costs nothing and works at once.
- Put the address and your key where your program reads them, and check the key.
No GTO Gecko account yet?
“Continue with Google” makes one. To sign in with an email address and a password, make a free account at play.gtogecko.com first and verify its email address. It is the account of the GTO Gecko app.
export GECKO_API="https://api.gtogecko.com" export GECKO_KEY="gecko_test_..." curl -sS "$GECKO_API/v1/account" -H "Authorization: Bearer $GECKO_KEY" | jq .
# first, in your shell: the two export lines of the curl sample
import json, os
import requests
API = os.environ["GECKO_API"]
AUTH = {"Authorization": f"Bearer {os.environ['GECKO_KEY']}"}
WAIT = {**AUTH, "Prefer": "wait=30"} # hold an answer up to 30 seconds
def call(method, path, **kwargs):
"""One request. An error answer becomes an exception with its code and request id."""
response = requests.request(method, API + path, timeout=40, **kwargs)
if not response.ok:
problem = response.json()
raise RuntimeError(f"{problem['code']}: {problem['detail']} ({problem['request_id']})")
return response.json()
print(call("GET", "/v1/account", headers=AUTH)["key"]["env"]) # test
// first, in your shell: the two export lines of the curl sample
import { readFile } from "node:fs/promises";
const API = process.env.GECKO_API;
const auth = { Authorization: `Bearer ${process.env.GECKO_KEY}` };
const wait = { ...auth, Prefer: "wait=30" }; // hold an answer up to 30 seconds
// One request. An error answer becomes an exception with its code and request id.
async function call(method, path, { headers = auth, body } = {}) {
const response = await fetch(API + path, {
method,
headers: body ? { ...headers, "Content-Type": "application/json" } : headers,
body: body ? JSON.stringify(body) : undefined,
signal: AbortSignal.timeout(40_000),
});
const data = await response.json();
if (!response.ok) throw new Error(`${data.code}: ${data.detail} (${data.request_id})`);
return data;
}
console.log((await call("GET", "/v1/account")).key.env); // test
- What comes back
- Your account, with
"env": "test"underkey. A wrong key answers401 invalid_key: paste the whole key in place ofgecko_test_.... More in Keys and authentication.
Step 2 of 5
Describe the spot
A spot is a board, a pot, the stack behind, and one range for each player: out of position first, then in position. Save this as spot.json in your folder.
{
"board": ["As", "Ks", "7h"],
"pot": 100,
"stack": 300,
"ranges": [
{"AA": 1, "KK": 1, "QQ": 1, "JJ": 1, "TT": 1, "99": 1, "88": 1, "77": 1, "66": 1,
"55": 1, "44": 1, "33": 1, "22": 1, "AKs": 1, "AKo": 1, "AQs": 1, "KQs": 1, "JTs": 1},
{"AA": 1, "KK": 1, "QQ": 1, "JJ": 1, "TT": 1, "99": 1, "88": 1, "77": 1, "66": 1,
"55": 1, "44": 1, "33": 1, "22": 1, "AKs": 1, "AKo": 1, "AQs": 1, "AQo": 1, "AJs": 1,
"KQs": 1, "QJs": 1, "T9s": 1}
],
"bet_sizes": [0.33],
"raise_sizes": [1.0]
}
- The sizes
"bet_sizes": [0.33]is one bet of 33% of the pot."raise_sizes": [1.0]is one raise of the pot. The all-in is on by default, so each player can also bet or raise all 300 chips.- What comes back
- Nothing yet: this file is the body of the request in step 3. The spot lists every field you can send.
Step 3 of 5
Solve
POST /v1/solves answers 202 with a solve. Prefer: wait=30 holds the answer up to 30 seconds while the solver works. A solve is finished when its status is complete.
While it is pending, queued or running, ask again with GET /v1/solves/{id} and Prefer: wait=30. The helper wait_for in each sample does that. With a live key the first solve after a quiet period needs about 45 seconds, more than one wait: see warm and cold.
curl -sS -X POST "$GECKO_API/v1/solves" \
-H "Authorization: Bearer $GECKO_KEY" -H "Content-Type: application/json" \
-H "Prefer: wait=30" -d @spot.json -o flop.json
wait_for() {
while jq -e '.status | IN("pending", "queued", "running")' "$1" > /dev/null; do
curl -sS "$GECKO_API/v1/solves/$(jq -r .id "$1")" \
-H "Authorization: Bearer $GECKO_KEY" -H "Prefer: wait=30" -o "$1"
done
}
wait_for flop.json
FLOP=$(jq -r .id flop.json)
jq '{id, status}' flop.json
def wait_for(solve):
"""Ask again until the solve, and every solve under it, is finished."""
while (solve["status"] in ("pending", "queued", "running")
or (solve.get("tree") or {}).get("status") == "running"):
solve = call("GET", f"/v1/solves/{solve['id']}", headers=WAIT)
return solve
spot = json.load(open("spot.json"))
flop = wait_for(call("POST", "/v1/solves", json=spot, headers=WAIT))
print(flop["id"], flop["status"])
// Ask again until the solve, and every solve under it, is finished.
async function waitFor(solve) {
while (["pending", "queued", "running"].includes(solve.status) || solve.tree?.status === "running") {
solve = await call("GET", `/v1/solves/${solve.id}`, { headers: wait });
}
return solve;
}
const spot = JSON.parse(await readFile("spot.json", "utf8"));
const flop = await waitFor(await call("POST", "/v1/solves", { headers: wait, body: spot }));
console.log(flop.id, flop.status);
- What comes back
- A solve with
"status": "complete", anidthat starts withslv_, andresult: the path of the answer. Every field is in the solve object.
Step 4 of 5
Read the answer
The result holds every decision of the street. Each decision lists its actions and, for each hand, one probability and one EV for each action. Here: what the hand AhKh does at the first decision.
curl -sS "$GECKO_API/v1/solves/$FLOP/result" \
-H "Authorization: Bearer $GECKO_KEY" \
--compressed -o flop-result.json
jq '.tree.strategy | {actions, plays: .strategy.AhKh, evs: .evs.AhKh}' flop-result.json
result = call("GET", f"/v1/solves/{flop['id']}/result", headers=AUTH)
first = result["tree"]["strategy"] # the first decision: out of position
for action, share, ev in zip(first["actions"], first["strategy"]["AhKh"], first["evs"]["AhKh"]):
print(action, round(share, 4), round(ev, 2))
# with a live key: with a test key:
# b300 0.0001 104.66 b300 0.3333 0.0
# b33 0.7832 130.85 b33 0.3333 0.0
# c 0.2167 130.94 c 0.3333 0.0
const result = await call("GET", `/v1/solves/${flop.id}/result`);
const first = result.tree.strategy; // the first decision: out of position
first.actions.forEach((action, i) => {
console.log(action, first.strategy.AhKh[i].toFixed(4), first.evs.AhKh[i].toFixed(2));
});
// with a live key: with a test key:
// b300 0.0001 104.66 b300 0.3333 0.00
// b33 0.7832 130.85 b33 0.3333 0.00
// c 0.2167 130.94 c 0.3333 0.00
- The actions
cis check or call.fis fold.b33is a bet or raise that puts 33 chips in on the street.b300is the all-in: the stack is 300.- What comes back
- Three actions with a share and an EV each. With a live key the hand bets 33 chips 78% of the time and checks 22%. With a test key every action has the same share and EV 0. Results explains the whole format.
Step 5 of 5
Go on to the turn
Continue from the flop solve with the line that ended the street and the turn card. The line ["c", "b33", "c"] is: the first player checks, the second bets 33 chips, the first calls.
Then the 2 of clubs comes. Each street is one call.
curl -sS -X POST "$GECKO_API/v1/solves" \
-H "Authorization: Bearer $GECKO_KEY" -H "Content-Type: application/json" \
-H "Prefer: wait=30" -o turn.json \
-d "$(jq -n --arg parent "$FLOP" '{parent: $parent, line: ["c", "b33", "c"], card: "2c"}')"
wait_for turn.json
TURN=$(jq -r .id turn.json)
jq '{street, board, pot, stack, status}' turn.json
turn = wait_for(call("POST", "/v1/solves", headers=WAIT, json={
"parent": flop["id"],
"line": ["c", "b33", "c"],
"card": "2c",
}))
print(turn["street"], turn["board"], turn["pot"], turn["stack"])
# turn ['As', 'Ks', '7h', '2c'] 166 267
const turn = await waitFor(await call("POST", "/v1/solves", {
headers: wait,
body: { parent: flop.id, line: ["c", "b33", "c"], card: "2c" },
}));
console.log(turn.street, turn.board, turn.pot, turn.stack);
// turn [ 'As', 'Ks', '7h', '2c' ] 166 267
- What comes back
- A turn solve: board
As Ks 7h 2c, pot 166, stack 267. Read its result as in step 4. The line is written in the tokens the answers use: see lines and their tokens.
Where to go next: three ways to get later streets, how to wait for a result, and the checklist in Going to production. A test key gives placeholder numbers: for real solutions, go live.