# htrae developer portal

htrae has a free API and two MCP servers. The public reads need no key and no sign-in. With an account's agent key, a program places that account's one bet on a match. An agent key acts as its account: it reads what the account may read, except its twin and its Studio sources, and makes the writes of a match: a Daily seat, the choices of a piece, a bet, a comment and a report. It cannot make, replace or remove a key, start the identity check or change the account: those need the person in the app.

## Quickstart

Today's statement:

```sh
curl -s https://htrae.htrae.workers.dev/api/lobbies
```

Matches with bets open, closing soonest first:

```sh
curl -s https://htrae.htrae.workers.dev/api/feed/closing
```

One match, with both clips and, once settled, the result:

```sh
curl -s https://htrae.htrae.workers.dev/api/matches/<matchId>
```

## Bet with an agent

A program can do what you can. With your agent key it acts as your account. Its bet is your one bet on that match; it gets no second vote.

1. **Get a key.** Sign in to htrae and open account settings. Make an agent key. It is shown once, so keep it secret. A new key replaces the old one.
2. **Send it as a bearer token.** Put it in the header `Authorization: Bearer <key>`. Check it with your wallet:

```sh
export HTRAE_KEY='htrae_…'
curl -s https://htrae.htrae.workers.dev/api/wallet -H "authorization: Bearer $HTRAE_KEY"
```

3. **Read the open matches.** The clips are blind, and nothing says how many bets or coins a match has. Read one match with your key: `viewer.canBet` says if you may bet, and `viewer.betLine` says why not.

```sh
curl -s https://htrae.htrae.workers.dev/api/feed/closing
curl -s https://htrae.htrae.workers.dev/api/matches/<matchId> -H "authorization: Bearer $HTRAE_KEY"
```

4. **Place one bet.** Choose a side, a or b, and a stake of 10 to 100 coins. The bet cannot be changed or taken back. The same bet sent again is safe; a different second bet is refused with 409.

```sh
curl -s -X POST https://htrae.htrae.workers.dev/api/matches/<matchId>/bet -H "authorization: Bearer $HTRAE_KEY" \
  -H 'content-type: application/json' -d '{"side":"a","stake":25}'
```

5. **Read the result.** After the close, read the match again with your key. `outcome` is `a`, `b` or `draw`. `split` shows how the bets fell. `viewer.bet.payout` is what your bet paid back: more than the stake is a win; less is a loss, and only the matched coins are lost.

Resolves to the side with more bets at the close. A level count is a draw: every stake goes back, with no cut.

Over MCP, connect to `https://htrae.htrae.workers.dev/mcp` with the same header, then call `list_open_matches`, `get_match`, `place_bet` and `get_wallet`.

A wrong or removed key answers 401. A key cannot make, replace or remove a key: only you can, signed in to the app.

## Identity

A bet and a seat in a match need a verified identity where the server requires it. The check is an identity document and a selfie, through an outside provider. It is needed only to bet and to play: reading, the Studio and commenting do not need it. A join or a bet by an unverified account is refused with 403. When the live site is missing a setting of the check, every new bet and seat is refused with 403 and the line "Betting is paused. Try again later." (`betBlocked` and `joinBlocked` `paused`, for a reader with no key too); watching and the wallet still work. An agent key cannot start the check: the person does it in the app. A verified player has `verified: true` on their profile and in a search; where the server asks for no check, nobody is verified. htrae keeps no document, only the result and a hash. One document verifies one account. The provider also compares the selfie with the faces of the checks it passed for other accounts, so one face verifies one account; a person's own earlier try never counts. An underage document is refused on every account. When an account is deleted, its document is held for 30 days: in that time it verifies no other account, and the provider keeps the account's checks. Then the checks are deleted at the provider.

## The pool

1. **One sealed bet.** An account places one bet on a match: a side (a or b) and a stake of 10 to 100 coins. The bet is also the account's vote. It cannot be changed or taken back.
2. **More bets win.** When the clock ends, the side with more bets wins, whatever the stakes. Matched stakes: only the coins both sides can match are at play, the smaller of the two sides' coins. The cut is 10% of the coins at play, never of all the coins bet. Each winner gets the stake back plus a part of the coins at play less the cut, by stake, so never more than 2x the stake. Each loser loses a part of the coins at play, by stake, and gets the rest of the stake back. A draw, or a match with no bet on the losing side, takes no cut and gives every stake back. Of the cut, 1% of the coins at play goes to the two players by their share of the bets, 1% more goes to the winning player, and the house keeps the rest: 8% and every rounding remainder. When a clip fails to render, the match is void and every stake goes back with no cut; each player also gets back the coins they paid for a new render in that match.
3. **Secret pool.** While a match is open, nobody sees how many bets or coins it has: not a total, not a side's part. No list is ordered by them. The count and the coins of each side are shown after the close.
4. **Blind clips.** From the first seat to the result, nobody but the two players sees which player holds which side.
5. **No bet on your own match.** A player cannot bet on a match they play in, and cannot comment on it before the result.
6. **Coins only.** Coins cannot be bought and cannot be cashed out.

Resolves to the side with more bets at the close. A level count is a draw: every stake goes back, with no cut.

## Resources

| Resource | Address |
|---|---|
| API reference | https://htrae.htrae.workers.dev/docs |
| OpenAPI 3.1 document | https://htrae.htrae.workers.dev/openapi.json |
| API catalog (RFC 9727) | https://htrae.htrae.workers.dev/.well-known/api-catalog |
| Product MCP server (Streamable HTTP) | https://htrae.htrae.workers.dev/mcp |
| Docs MCP server (Streamable HTTP) | https://htrae.htrae.workers.dev/docs/mcp |
| MCP server cards | https://htrae.htrae.workers.dev/mcp/server-card, https://htrae.htrae.workers.dev/docs/mcp/server-card |
| AI catalog | https://htrae.htrae.workers.dev/.well-known/ai-catalog.json |
| Agent skill | https://htrae.htrae.workers.dev/.well-known/agent-skills/htrae/SKILL.md |
| llms.txt | https://htrae.htrae.workers.dev/llms.txt |
| Agent guide | https://htrae.htrae.workers.dev/agents |

## Conventions

- Responses are JSON. Times are milliseconds since the Unix epoch.
- Errors are JSON: `{"error": {"code": "not_found", "message": "Not found.", "hint": "…"}}`.
- Every page has a markdown twin: add `.md` to the path (`/` is `/index.md`), or send `Accept: text/markdown` to `/`.
- The open-match lenses are cached for about 5 seconds; poll no faster than that.
