Guides

Record matches

Recording a match is what moves ratings. One call writes the match and rates it.

Record a match

curl -X POST https://api.inhouseranks.com/v1/match/record \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "matchExternalId": "m_1042",
    "ranked": true,
    "name": "Grand Final",
    "matchResult": {
      "teams": [
        { "place": 1, "constituents": [{ "mmrEntityExternalId": "alice" }] },
        { "place": 2, "constituents": [{ "mmrEntityExternalId": "bob" }] }
      ]
    }
  }'
  • A team is a placement bucket. Everyone who shared a result goes in one team. Teams need no id or name: send them in a list and the server labels them.
  • place 1 is the winner. Lower is better.
  • The ids are yours. matchExternalId names the match and mmrEntityExternalId names each player. An mmrEntityExternalId the pool hasn't seen gets a player created for it.
  • No pool means the default pool. Add "poolId": "<poolId>" to record in another one: the _id it was created with.

The reply is { match, matchPlayers } with the match recorded. Each row of matchPlayers carries that player's rating before and after. The full reply is in the reference: Record a match.

Send ranked true

ranked defaults to false. An unranked match is an exhibition. It goes into history and adds to each player's matchCount, but it changes no rating, wins or losses, and its players stay off /leaderboard. Send "ranked": true for every match that should count.

Match shapes

Game Send
1v1 Two teams with one player each, places 1 and 2.
Free-for-all One team per player, places 1 to N.
Team game One team per side, with every member in its constituents. One place per side.
Draw The same place on the tied teams.

A 2v2:

curl -X POST https://api.inhouseranks.com/v1/match/record \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "matchExternalId": "m_1044",
    "ranked": true,
    "matchResult": {
      "teams": [
        {
          "place": 1,
          "constituents": [
            { "mmrEntityExternalId": "alice" },
            { "mmrEntityExternalId": "carol" }
          ]
        },
        {
          "place": 2,
          "constituents": [
            { "mmrEntityExternalId": "bob" },
            { "mmrEntityExternalId": "dave" }
          ]
        }
      ]
    }
  }'

Teammates share the result, not the size of the change. A side's chance of winning comes from its players' average rating, so everyone on a side is expected to win or lose together. How far each player then moves is their own: their K-factor on Elo (from their own rating or match count), or their own rating deviation on Glicko-2. A new player moves further than the veterans they win with. Teammates whose numbers match move the same.

Retry safely

Your matchExternalId names the match, and /match/record looks it up first:

Your matchExternalId names What happens
No match yet, or you sent none The match is created from matchResult, then rated.
A match that isn't rated yet It's rated. It was opened by /match/score or made by the matchmaker.
A match already recorded 409 match-already-recorded. Nothing changes.

A recorded match is final, so nothing is ever rated twice. That makes retries simple:

  • Always send a matchExternalId. Without one, a retry writes a second match.
  • After a timeout, send the same call again. 409 match-already-recorded means the first one went through.
  • After 409 rating-update-conflict or a 5xx, retry with only the matchExternalId: { "matchExternalId": "m_1042" }. A new match is written first and rated second, so the match may exist unrated. Sending its matchResult again answers 400 match-not-pending.

A new match needs a matchResult. A matchExternalId that names no match, sent without one, is 404 match-not-found. A result whose teams have neither places nor points is 400 match-has-unplaced-teams, and nothing is written.

Score players as results come in

When you don't know the outcome up front (a race, a tournament round, a score-attack session), don't wait. Post each player's score when it lands, then record the match once everyone is in. There is no setup call: the first /score for an unseen matchExternalId opens the match as pending.

curl -X POST https://api.inhouseranks.com/v1/match/score \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "matchExternalId": "m_1043",
    "ranked": true,
    "scores": [
      {
        "mmrEntityExternalId": "alice",
        "pointsScored": 12,
        "caption": "clean run"
      }
    ]
  }'

Repeat as results arrive. Players you don't mention keep what they have:

curl -X POST https://api.inhouseranks.com/v1/match/score \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "matchExternalId": "m_1043",
    "scores": [{ "mmrEntityExternalId": "bob", "pointsScored": 7 }]
  }'

Then record it. Places are worked out from the scores:

curl -X POST https://api.inhouseranks.com/v1/match/record \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "matchExternalId": "m_1043" }'

How scoring behaves:

  • /score never rates and never sets a place. It records pointsScored and caption only.
  • Only the players named in scores are touched. Everyone else keeps their score and caption. Scores are per team, so scoring one player sets their whole team's score and caption.
  • A player who wasn't in the match is added, as a team of their own.
  • The pool's winCondition ranks the teams when the match is recorded. mostPoints, the default on every pool, puts the highest score first. leastPoints (golf, say) puts the lowest first.
  • Equal scores share a place: a draw. A player with no score, or a score of 0, comes in tied last, behind every scored player.

The first /score can also carry the pool, ranked, name and description of the match it opens. See Score a match.

To use leastPoints, set it when you create the pool, or later with /v1/pool/update. It applies to matches opened after that:

curl -X POST https://api.inhouseranks.com/v1/pool/update \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "poolId": "6b01eb7991a8d0c2e72af67e",
    "gameConfig": {
      "teams": {},
      "positions": {},
      "winCondition": "leastPoints"
    }
  }'

Record a match that already exists

/match/record also takes scores: who placed where, set on the match just before it's rated. For a match the matchmaker made, or one /match/score opened, that is the whole result in one call:

curl -X POST https://api.inhouseranks.com/v1/match/record \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "matchId": "6b01eb7991a8d0c2e72af694",
    "scores": [
      { "teamId": "<teamAId>", "place": 1 },
      { "teamId": "<teamBId>", "place": 2 }
    ]
  }'
  • An entry names one team or one player. A team by teamId (the match.found event gives it), a player by mmrEntityExternalId. Results are per team, so a player's entry sets their team's result. In a team game, one entry per team is enough.
  • Give every team a place, the same one for tied teams. Or give pointsScored and let the pool's winCondition place them.
  • Entries must name someone already in the match.
  • A refused entry writes no scores and rates nothing. Fix the body and send it again.

The fields and refusals are under Scores.

Rename a match or change its result

/match/update patches a match. Every field is optional and only the fields you send are written:

curl -X POST https://api.inhouseranks.com/v1/match/update \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "matchExternalId": "m_1045", "name": "Grand Final (replay)" }'
Field Can change How
name, description In any status, even after the match is recorded Send a value to overwrite, null or "" to clear, or leave the field out to keep it.
matchResult, ranked Only while the match is pending Afterwards it's 400 match-not-pending. matchResult replaces the whole result.

name and description are labels and behave the same everywhere they appear, including /match/record, /match/create and /match/score. Leaving one out never clears the other. A name is at most 80 characters and a description at most 300.

To add to an unfinished result one player at a time, use /match/score instead.

Other match calls

To Call
Write a match now and rate it later POST /v1/match/create. Optional: /match/score opens a match by itself.
Delete a match POST /v1/match/delete. Pending matches only: a recorded match can't be deleted.
Read one match with its players GET /v1/match/get
Page through a pool's history GET /v1/match/list. Pages start at 0 here.
Record many old matches at once POST /v1/match/import