API reference

Players

A player in a pool is a rated user: mmrEntity in responses. You name a player by mmrEntityExternalId, your own id for them, or by mmrEntityId, which is Inhouse's (the rated user's _id). Their user names, userExternalId and userId, work anywhere the tables below list those, and a response has both (user names). See Pools and players.

Create a player

POST/v1/user/create

Creates a rated user at the pool's starting rating. Optional: a player is created anyway the first time a recorded match names their mmrEntityExternalId. Use it to set a display name, or to put a player in a pool before their first match.

The call is idempotent per mmrEntityExternalId. Calling it again with a name renames the player.

Body parameters

Field Type Required Description
mmrEntityExternalId or userExternalId string yes Your id for the player, at most 100 characters.
name string no Display name, at most 50 characters. Defaults to the mmrEntityExternalId.
poolId string no The pool. Defaults to the default pool.

Request

curl -X POST https://api.inhouseranks.com/v1/user/create \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "mmrEntityExternalId": "carol", "name": "Carol" }'

Response 200

{
  "mmrEntity": {
    "_id": "6b01eb7991a8d0c2e72af676",
    "archived": null,
    "name": "Carol",
    "poolId": "6b01eb7991a8d0c2e72af66b",
    "stats": [
      {
        "positionId": null,
        "mmr": {
          "value": 1500,
          "ratingDeviation": null,
          "volatility": null,
          "lastRatedAt": null
        },
        "wins": 0,
        "losses": 0,
        "ties": 0,
        "matchCount": 0,
        "winStreak": 0,
        "currentStreak": 0,
        "loseStreak": 0,
        "streakIgnoringTies": null,
        "seasonStartWins": null,
        "seasonStartMatchCount": null,
        "lastPlayedAt": null,
        "groupRank": null,
        "hideRating": false
      }
    ],
    "externalId": "carol",
    "lastActiveMonth": null,
    "ratingWindowMmrs": []
    // ...
  }
}

mmrEntity is the rated user. mmrEntity.externalId is the mmrEntityExternalId you sent, and mmrEntity._id is the player's mmrEntityId.

Errors

Status code When
400 user-id-required No mmrEntityExternalId. Every rated user needs your id for the player.

Get players' ratings

GET/v1/user/ratings

Returns the ratings and records of the players you name, in the order you asked. It never creates a player.

Parameters

Parameter In Required Description
mmrEntityExternalIds or userExternalIds query yes Your ids for the players, comma-separated, at most 100. An id that contains a comma can't be asked for here.
poolId query no The pool. Defaults to the default pool.

Request

curl "https://api.inhouseranks.com/v1/user/ratings?mmrEntityExternalIds=alice,bob,zoe" \
  -H "x-api-key: $INHOUSE_API_KEY"

Response 200

{
  "poolId": "6b01eb7991a8d0c2e72af66b",
  "ratings": [
    {
      "mmrEntityExternalId": "alice",
      "mmrEntity": {
        "_id": "6b01eb7991a8d0c2e72af66e",
        "name": "alice",
        "stats": [
          {
            "positionId": null,
            "mmr": { "value": 1545.086633573829 /* ... */ },
            "wins": 3,
            "losses": 0,
            "ties": 0,
            "matchCount": 3,
            "groupRank": null,
            "hideRating": false
            // ...
          }
        ],
        "externalId": "alice"
        // ...
      }
      // ...
    }
    // ... 1 more
  ],
  "missing": ["zoe"]
}
Key Contains
poolId Inhouse's id for the pool.
ratings One { mmrEntityExternalId, userExternalId, mmrEntity } per player found, in the order asked. Repeated ids collapse to one row.
missing The ids with no rated user in this pool. A player rated only in another pool is missing here.

Errors

Status code When
400 user-ids-required mmrEntityExternalIds is empty or missing. Name at least one player.
400 too-many-user-ids More than 100 ids. Split the batch. message names the limit and what you sent.

Correct a rating

POST/v1/user/update-rating

Sets a player's overall rating by hand: the stats block with positionId: null. Blocks for positions are untouched.

Only the rating changes. On Glicko-2 the block keeps its rating deviation and volatility. An open rating window on the block is closed.

Body parameters

Field Type Required Description
mmrEntityExternalId or userExternalId string one of these Your id for the player.
mmrEntityId or userId string one of these Inhouse's id for the player: the rated user's _id.
mmr number yes The new rating.
poolId string no The pool. Defaults to the default pool.

Request

curl -X POST https://api.inhouseranks.com/v1/user/update-rating \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "mmrEntityExternalId": "carol", "mmr": 1600 }'

Response 200

{
  "mmrEntity": {
    "_id": "6b01eb7991a8d0c2e72af676",
    "name": "Carol",
    "stats": [
      {
        "positionId": null,
        "mmr": { "value": 1600 /* ... */ },
        "wins": 1,
        "losses": 0,
        "ties": 0,
        "matchCount": 1,
        "groupRank": null,
        "hideRating": false
        // ...
      }
    ],
    "externalId": "carol"
    // ...
  }
}

Errors

Status code When
400 user-id-required Neither mmrEntityExternalId nor mmrEntityId was sent.
404 mmr-entity-not-found No such rated user in the pool.

Rename or archive a player

POST/v1/mmr_entities/update

Renames a rated user, or archives or restores them. The pool is the rated user's own, so no pool is needed.

An archived player drops off both leaderboards, GET /v1/pool and /v1/user/ratings (where they're reported in missing). Their mmrEntityExternalId is then free: a later match with it starts a new rated user.

Body parameters

Field Type Required Description
mmrEntityId or userId string yes Inhouse's id for the player: the rated user's _id. This call doesn't take your own id.
name string no The new display name, at most 50 characters.
archived boolean no true archives, false restores.

Request

curl -X POST https://api.inhouseranks.com/v1/mmr_entities/update \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "mmrEntityId": "6b01eb7991a8d0c2e72af676", "name": "Carol C." }'

Response 200

{
  "mmrEntity": {
    "_id": "6b01eb7991a8d0c2e72af676",
    "name": "Carol C.",
    "stats": [
      {
        "positionId": null,
        "mmr": { "value": 1600 /* ... */ },
        "wins": 1,
        "losses": 0,
        "ties": 0,
        "matchCount": 1,
        "groupRank": null,
        "hideRating": false
        // ...
      }
    ],
    "externalId": "carol"
    // ...
  }
}

Errors

Status code When
400 user-external-id-exists Restoring a player whose mmrEntityExternalId was taken by a new rated user in the meantime. Each one names one active player per pool.
400 none Validation failed: mmrEntityId is missing, or isn't an Inhouse id.
404 mmr-entity-not-found No rated user has this mmrEntityId.

Migrate players

POST/v1/user/migrate

Brings up to 1000 existing players into a pool with their ratings and records. All or nothing: a batch with a bad row writes nothing. See Migrate your players.

Body parameters

Field Type Required Description
poolId string yes The pool, which must already exist. There is no default pool here.
players array yes 1 to 1000 players, each { mmrEntityExternalId, name?, stats? }.
players[].mmrEntityExternalId or players[].userExternalId string yes Your id for the player.
players[].name string no Display name. Defaults to the mmrEntityExternalId.
players[].stats array no Stats blocks in the shape mmrEntity.stats[] comes back in. Fields left out take the pool's defaults: see What to send for each player.
overwrite boolean no true replaces the stats (and name, if sent) of players that already exist. By default they're skipped.

Request

curl -X POST https://api.inhouseranks.com/v1/user/migrate \
  -H "x-api-key: $INHOUSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "poolId": "6b01eb7991a8d0c2e72af67e",
    "players": [
      {
        "mmrEntityExternalId": "alice",
        "name": "Alice",
        "stats": [{ "mmr": { "value": 1820 }, "wins": 30, "losses": 12 }]
      },
      { "mmrEntityExternalId": "bob" }
    ]
  }'

Response 200

{
  "poolId": "6b01eb7991a8d0c2e72af67e",
  "createdCount": 1,
  "updatedCount": 0,
  "skippedCount": 1,
  "players": [
    {
      "mmrEntityExternalId": "alice",
      "userExternalId": "alice",
      "mmrEntityId": "6b01eb7991a8d0c2e72af682",
      "userId": "6b01eb7991a8d0c2e72af682",
      "status": "created"
    },
    {
      "mmrEntityExternalId": "bob",
      "userExternalId": "bob",
      "mmrEntityId": "6b01eb7991a8d0c2e72af681",
      "userId": "6b01eb7991a8d0c2e72af681",
      "status": "skipped"
    }
  ]
}

players is in request order. Each row has your id for the player (mmrEntityExternalId), Inhouse's (mmrEntityId) and a status: created, updated or skipped. The two ids also come as userExternalId and userId.

Errors

Status code When
400 group-id-required No poolId. message says what to send.
400 no-players players is empty or missing.
400 too-many-players More than 1000 players. max is the limit. Split the batch.
400 invalid-migration Some rows are bad, and nothing was written. errors holds one { index, mmrEntityExternalId, code, field, message } per bad row.
404 group-not-found The pool doesn't exist.

A row's code in errors is one of player-not-an-object, user-id-required, duplicate-user-id, unknown-field, invalid-field, unknown-position, duplicate-position, glicko2-only-field, conflicting-streaks or match-count-too-low:

{
  "code": "invalid-migration",
  "message": "Nothing was migrated: 1 of 1 players are invalid. Fix them and send the batch again.",
  "errors": [
    {
      "index": 0,
      "mmrEntityExternalId": "erin",
      "userExternalId": "erin",
      "code": "unknown-field",
      "field": "rating",
      "message": "Unknown field \"rating\". Allowed here: mmrEntityExternalId, name, stats."
    }
  ]
}