{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "http://imgarena.com/schemas/tennis.rally.tracking.events/1.1.0",
  "title": "IMGA tennis.rally.tracking.events Schema",
  "description": "Describes all the events which happened during a rally",
  "type": "object",
  "required": [
    "created",
    "id",
    "type",
    "packetDetails",
    "matchDetails",
    "events"
  ],
  "additionalProperties": false,
  "properties": {
    "created": {
      "title": "Packet Creation Datetime",
      "type": "string",
      "format": "date-time"
    },
    "id": {
      "title": "Packet ID",
      "type": "string",
      "format": "uuid"
    },
    "type": {
      "title": "Packet Type",
      "const": "rally.tracking.events"
    },
    "packetDetails": {
      "title": "Packet Details",
      "$ref": "#/$defs/packetDetail"
    },
    "matchDetails": {
      "title": "Match Details",
      "$ref": "#/$defs/matchDetail",
      "description": "The details of the match at the point this packet was sent"
    },
    "events": {
      "title": "",
      "type": "array",
      "items": {
        "$ref": "#/$defs/event"
      }
    }
  },
  "$defs": {
    "packetDetail": {
      "title": "Packet Details Schema",
      "type": "object",
      "required": [
        "set",
        "game",
        "point",
        "serve",
        "rally",
        "sequence",
        "start",
        "end"
      ],
      "additionalProperties": false,
      "properties": {
        "set": {
          "description": "The Set this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "game": {
          "description": "The Game this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "point": {
          "description": "The Point this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "serve": {
          "description": "The Serve this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "rally": {
          "description": "The Rally this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "sequence": {
          "description": "The Sequence of this packet",
          "type": "integer",
          "minimum": 1
        },
        "slice": {
          "description": "The Slice of the Sequence of this packet",
          "type": "integer",
          "minimum": 1
        },
        "shot": {
          "description": "The total number of shots so far up to and including this packet",
          "type": "integer",
          "minimum": 1
        },
        "arc": {
          "description": "The total number of arcs so far up to and including this packet",
          "type": "integer",
          "minimum": 1
        },
        "start": {
          "description": "The UTC start timestamp of this packet",
          "type": "string",
          "format": "date-time"
        },
        "end": {
          "description": "The UTC end timestamp of this packet",
          "type": "string",
          "format": "date-time"
        },
        "update": {
          "description": "Is this packet an update to a previous packet",
          "type": "boolean"
        },
        "updatedPacketId": {
          "description": "The packet ID being updated",
          "type": "string",
          "format": "uuid"
        }
      },
      "examples": [
        {
          "set": 1,
          "game": 1,
          "point": 1,
          "serve": 1,
          "rally": 1,
          "sequence": 1,
          "start": "2022-08-14T06:10:13.7513333Z",
          "end": "2022-08-14T06:10:20.4825333Z"
        }
      ]
    },
    "matchDetail": {
      "title": "Match Details Schema",
      "type": "object",
      "required": [
        "competitionId",
        "year",
        "court",
        "matchId",
        "singles",
        "wheelchair",
        "electronicLineCalling",
        "televised",
        "format",
        "round",
        "players"
      ],
      "additionalProperties": false,
      "properties": {
        "year": {
          "description": "The year of the match",
          "type": "integer",
          "minimum": 2020,
          "maximum": 2100
        },
        "competitionId": {
          "description": "The competition id for the match",
          "type": "string"
        },
        "matchId": {
          "description": "The match id",
          "type": "string"
        },
        "court": {
          "description": "The court the match is being played in",
          "type": "string"
        },
        "singles": {
          "description": "Is the match a singles match",
          "type": "boolean"
        },
        "wheelchair": {
          "description": "Is the match wheelchair based",
          "type": "boolean"
        },
        "electronicLineCalling": {
          "description": "Is electronic line calling being used",
          "type": "boolean"
        },
        "televised": {
          "description": "Is the match televised",
          "type": "boolean"
        },
        "format": {
          "description": "The match format",
          "type": "string"
        },
        "round": {
          "description": "The match round string",
          "type": "string"
        },
        "players": {
          "description": "The players involved in the match",
          "type": "array",
          "items": {
            "$ref": "#/$defs/playerDetail"
          }
        }
      },
      "examples": [
        {
          "competitionId": "5817",
          "year": 2022,
          "court": "2",
          "matchId": "LS001",
          "singles": true,
          "wheelchair": false,
          "electronicLineCalling": false,
          "televised": false,
          "format": "BestOfThreeTiebreakSets",
          "round": "RoundOf2",
          "players": [
            {
              "team": 1,
              "player": 1,
              "id": "320922",
              "seed": "",
              "firstName": "Ksenia",
              "lastName": "Laskutova"
            },
            {
              "team": 2,
              "player": 1,
              "id": "00BQ9O",
              "seed": "",
              "firstName": "Marketa",
              "lastName": "Petruzelova"
            }
          ]
        }
      ]
    },
    "playerDetail": {
      "title": "Player Detail schema",
      "type": "object",
      "required": [
        "team",
        "player",
        "id",
        "firstName",
        "lastName"
      ],
      "additionalProperties": false,
      "properties": {
        "team": {
          "title": "The team the player is in",
          "description": "This is a numeric depiction of how many teams there are and which team the player resides in",
          "type": "integer",
          "minimum": 1
        },
        "player": {
          "title": "The id of the player in the team",
          "description": "This is a numeric depiction of how many players there are in a team.",
          "type": "integer",
          "minimum": 1
        },
        "id": {
          "title": "Competition Player ID",
          "type": "string"
        },
        "seed": {
          "title": "Player Seed",
          "type": "string"
        },
        "firstName": {
          "title": "Player's first name",
          "type": "string"
        },
        "lastName": {
          "title": "Player's last name",
          "type": "string"
        }
      },
      "examples": [
        {
          "team": 1,
          "player": 1,
          "id": "320922",
          "seed": "",
          "firstName": "Ksenia",
          "lastName": "Laskutova"
        },
        {
          "team": 2,
          "player": 1,
          "id": "00BQ9O",
          "seed": "",
          "firstName": "Marketa",
          "lastName": "Petruzelova"
        }
      ]
    },
    "event": {
      "title": "Event Schema",
      "type": "object",
      "required": [
        "id",
        "team",
        "player",
        "spin",
        "speed",
        "result",
        "call",
        "time",
        "duration"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "title": "Event ID",
          "type": "string",
          "format": "uuid"
        },
        "team": {
          "description": "The team id the event belongs to",
          "type": "integer"
        },
        "player": {
          "description": "The player id in the team the event belongs to",
          "type": "integer"
        },
        "spin": {
          "description": "A classification of the resultant spin placed on the ball",
          "$ref": "#/$defs/spinDetails"
        },
        "speed": {
          "description": "Speed of the ball in mps",
          "type": "number",
          "minimum": 0
        },
        "result": {
          "title": "Outcome concluding the shot",
          "description": "The outcome concluding the shot. Possible values include: \nWinner - The shot was successfully hit without the other team touching it before it became dead, therefore ending the rally. \nError - The shot was unsuccessfully hit, therefore ending the rally.\nRally - The shot was successfully hit and the rally continues. \nExtra - The shot was hit after a previous shot was called out.",
          "enum": [
            "Winner",
            "Error",
            "Rally",
            "Extra"
          ]
        },
        "call": {
          "title": "Line call of the shot",
          "description": "The line call of the shot, as determined by the tracking system. Possible values include:\nIn - The shot would be called 'In' if challenged.\nOut - The shot would be called 'Out' if challenged.\nEstimate - The shot was taken out of the air before it could\nbounce, therefore the distance provided is an estimate had\nthe ball been allowed to bounce.",
          "enum": [
            "In",
            "Out",
            "Estimate",
            "Unknown",
            ""
          ]
        },
        "time": {
          "description": "The time from the packet start in seconds",
          "type": "number",
          "minimum": 0
        },
        "duration": {
          "description": "The duration of the event in seconds",
          "type": "number",
          "minimum": 0
        },
        "shot": {
          "title": "The shot Schema",
          "type": "string"
        }
      },
      "examples": [
        {
          "id": "37D0ED86-F2C6-4E14-82F6-358872D88042",
          "team": 1,
          "player": 1,
          "spin": {
            "type": "Back",
            "rps": -20.558
          },
          "speed": 17.181138205496335,
          "result": "Rally",
          "call": "",
          "time": 0.0,
          "duration": 2.4442231432767585
        },
        {
          "id": "A0F8C8CE-BA79-4CA2-A95B-5472CD454D62",
          "team": 1,
          "player": 1,
          "shot": "Return",
          "spin": {
            "type": "None"
          },
          "speed": 56.37009224766204,
          "result": "Rally",
          "call": "In",
          "time": 2.4442231432767585,
          "duration": 1.352568801958114
        }
      ]
    },
    "spinDetails": {
      "title": "Spin Schema",
      "type": "object",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "title": "The type Schema",
          "description": "A classification of the resultant spin placed on the ball. Possible values include:\n\nNone\nTop\nBack\nSlice (Not required for MVP)\nHook (Not required for MVP)\nSideback (Not required for MVP)\nBanana (Not required for MVP)\nUnknown",
          "enum": [
            "None",
            "Top",
            "Back",
            "Slice",
            "Hook",
            "Sideback",
            "Banana",
            "Unknown"
          ]
        },
        "rps": {
          "title": "Spin RPS",
          "type": "number"
        }
      },
      "examples": [
        {
          "type": "None",
          "vertical": "None",
          "horizontal": "None",
          "axial": ""
        }
      ]
    }
  },
  "examples": [
    {
      "created": "2022-08-14T06:10:23.4908526Z",
      "id": "e28fc19b-69ec-4504-b77b-a4e0cca6ef46",
      "type": "live.tracking.summary",
      "packetDetails": {
        "set": 1,
        "game": 1,
        "point": 1,
        "serve": 1,
        "rally": 1,
        "sequence": 1,
        "start": "2022-08-14T06:10:13.7513333Z",
        "end": "2022-08-14T06:10:20.4825333Z"
      },
      "matchDetails": {
        "competitionId": "5817",
        "year": 2022,
        "court": "2",
        "matchId": "LS001",
        "singles": true,
        "wheelchair": false,
        "electronicLineCalling": false,
        "televised": false,
        "format": "BestOfThreeTiebreakSets",
        "round": "RoundOf2",
        "players": [
          {
            "team": 1,
            "player": 1,
            "id": "320922",
            "seed": "",
            "firstName": "Ksenia",
            "lastName": "Laskutova"
          },
          {
            "team": 2,
            "player": 1,
            "id": "00BQ9O",
            "seed": "",
            "firstName": "Marketa",
            "lastName": "Petruzelova"
          }
        ]
      },
      "events": [
        {
          "id": "37D0ED86-F2C6-4E14-82F6-358872D88042",
          "team": 1,
          "player": 1,
          "spin": {
            "type": "Back",
            "rpm": -1233.454,
            "rps": -20.558
          },
          "speed": 17.181138205496335,
          "result": "Rally",
          "call": "",
          "time": 0.0,
          "duration": 2.4442231432767585
        },
        {
          "id": "A0F8C8CE-BA79-4CA2-A95B-5472CD454D62",
          "team": 1,
          "player": 1,
          "shot": "Return",
          "spin": {
            "type": "None"
          },
          "speed": 56.37009224766204,
          "result": "Rally",
          "call": "",
          "time": 2.4442231432767585,
          "duration": 1.352568801958114
        }
      ]
    }
  ]
}
