AFL API R Package Documentation
DESCRIPTIONβ
Package: cdAFLAPI
Type: Package
Version: 1.5.2
Depends: httr, httr2, jsonlite, tidyverse, data.table, purrr
Author: Champion Data
Maintainer: Aaron Brougham <aaron.brougham@championdata.com.au>
cdAFLAPI.update: Update Package Versionβ
Descriptionβ
Function to install the most recent version of cdAFLAPI. Will prompt for a session restart if using R Studio (recommended).
Usageβ
cdAFLAPI.update(...)
Examplesβ
cdAFLAPI.update()
cdAFLAPI.version: Current Version of cdAFLAPIβ
Descriptionβ
Return version details of the current version of the cdAFLAPI your system is running.
Usageβ
cdAFLAPI.version(info = "Version")
Argumentsβ
info: A string for which information to return.info='Version'will return a string of the current version number. (Default)info='Details'will return a list containing package metadata of your current version.
Examplesβ
cdAFLAPI.version()
cdAPI: Champion Data AFL APIβ
Descriptionβ
Hit the Champion Data AFL API with a given endpoint.
Usageβ
cdAPI(
endpoint,
envir = c("", "sandbox", "dev"),
base_url = "https://api.afl.championdata.io",
version = "v1",
df = TRUE
)
Argumentsβ
endpoint: The full path of an endpoint including path and query parameters, excluding the base_url and version components. eg: "Leagues" rather than "https://api.afl.championdata.io/v1/Leagues"envir: A short code representing the environment to hit. Empty string = Production, 'sandbox' = Sandbox environment, 'dev' = Development environment (Internal Champion Data use only).base_url: The base URL for the API. Defaults to the AFL API.version: The version number of the API. Defaults to 1.df: Logical. Convert to data.frame? Note: Will only work for endpoints with a flat JSON response.
Valueβ
A numerical value for league ID.
Examplesβ
cdAPI('matches/113770401')
cdAPIPOSTresponse: Champion Data AFL API Response (POST Endpoint)β
Descriptionβ
Hit either the Players or Squads Champion Data AFL API via the POST Endpoint.
Usageβ
cdAPIPOSTresponse(
matchId,
endpoint,
payload,
baseUrl = "https://api.afl.championdata.io",
version = "v1",
envir = "",
verbose = FALSE
)
Argumentsβ
matchId: A unique numerical identifier of a match.endpoint: A (case-insensitive) string detailing which endpoint to hit (either 'player' or 'squad').payload: A nested list containing the parcels of data to be returned by the API. See:createPayload()as a method of simplifying this step.version: The version number of the API. Defaults to 1.envir: A short code representing the environment to hit. Empty string = Production, 'sandbox' = Sandbox environment, 'dev' = Development environment (Internal Champion Data use only).base_url: The base URL for the API. Defaults to the AFL API.
Valueβ
A response object from the API call.
Examplesβ
cdAPIPOSTresponse(matchId = 120390401, endpoint = "player", payload = payload)
cdAPIresponse: Champion Data AFL API Responseβ
Descriptionβ
Hit the Champion Data AFL API with a given endpoint to retrieve a response object.
Usageβ
cdAPIresponse(
matchId,
endpoint,
envir = c("", "sandbox", "dev"),
base_url = "https://api.afl.championdata.io",
version = "v1",
pagination = FALSE,
verbose = FALSE
)
Argumentsβ
matchId: A unique numerical identifier of a match (only required for match-level endpoints.)endpoint: The full path of an endpoint including path and query parameters, excluding the base_url and version components. eg: "Leagues" rather than "https://api.afl.championdata.io/v1/Leagues"envir: A short code representing the environment to hit. Empty string = Production, 'sandbox' = Sandbox environment, 'dev' = Development environment (Internal Champion Data use only).base_url: The base URL for the API. Defaults to the AFL API.version: The version number of the API. Defaults to 1.verbose: Logical, default isFALSE. IfTRUE, prints the full URL string passed to the API.
Valueβ
A response object.
Examplesβ
cdAPIresponse(matchId,paste('matches',matchId,'entries',sep='/')
createPayLoad: Create POST endpoint payloadβ
Descriptionβ
Helper function to create a payload(s) for getPlayerStatsPOST() and getSquadStatsPOST() functions.
Usageβ
createPayLoad(endpoint, ...)
Argumentsβ
endpoint: A string of either "player" or "squad" dictating the POST endpoint the payload is being built for.list(s): Pass in any number of single lists to be combined into one payload.
Valueβ
A nested list in the correct structure to pass into payload arguments of getPlayerStatsPOST() and getSquadStatsPOST()
Examplesβ
D50_Tackles_Q1 = list(metricCodes = list("TACKLE"), zones = list('D50'), periods = list(1), id = "D50_Tackles_Q1")
createPayLoad(endpoint = "squad", D50_Tackles_Q1)
getAFLClubTrxFeed: AFL Club Feed Transaction Fileβ
Descriptionβ
Get the AFL Club Trx Feed file formerly available via the support site.
Usageβ
getAFLClubTrxFeed(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame in the same format and structure as the AFL Club Transaction Feed file formerly available via the support site.
MATCH_IDA unique numerical identifier of a match.MATCH_DATEThe calendar date of a match in local time.MATCH_TIMEThe local start time of a match.SEASON_IDA numerical identifier of a season.GROUP_ROUND_NOThe round number of the match. Continues to count up during finals.VENUE_NAMEThe name of the match venue.HOME_SQUADThe name of the home squad.HOME_SCOREThe score of the home squad.AWAY_SQUADThe name of the away squad.AWAY_SCOREThe score of the away squad.MATCH_TRX_IDA unique numerical identifier for a given transaction, used for ordering chronologically.SEQUENCEUnique identifier of events within a single transaction. Used for multi-player transactions.PERIODThe period (quarter) of the match.PERIOD_SECSThe elapsed time in seconds for live periods, or the period length for completed periods.STATISTIC_CODEThe statistic code for a given transaction.PERSON_IDA unique numerical identifier for the player assigned to the transaction (if applicable).FULLNAMEThe fullname of the player assigned to the transaction (if applicable).SQUAD_NAMEThe name of the squad assigned to the transaction.OPP_SQUADThe opposing squad to the one assigned to the transaction.AR_IDAway Ruck PERSON_ID (if applicable).ARAway Ruck FULLNAME (if applicable).H1_IDHome Midfielder 1 PERSON_ID (if applicable).H1Home Midfielder 1 FULLNAME (if applicable).H2_IDHome Midfielder 2 PERSON_ID (if applicable).H2Home Midfielder 2 FULLNAME (if applicable).H3_IDHome Midfielder 3 PERSON_ID (if applicable).H3Home Midfielder 3 FULLNAME (if applicable).A1_IDAway Midfielder 1 PERSON_ID (if applicable).A1Away Midfielder 1 FULLNAME (if applicable).A2_IDAway Midfielder 2 PERSON_ID (if applicable).A2Away Midfielder 2 FULLNAME (if applicable).A3_IDAway Midfielder 3 FULLNAME (if applicable).A3Away Midfielder 3 FULLNAME (if applicable).ZONE_LOGICAL_AFLThe zone in which the transaction takes place, relative to the squad in possession.ZONE_PHYSICAL_AFLThe zone in which the transaction takes place, relative to the physical ground.TRUEXThe x coordinate of the transaction.TRUEYThe y coordinate of the transaction.VENUE_LENGTHThe length of the venue in metres.VENUE_WIDTHThe width of the venue in metres.STDXThe x coordinate of the transaction transformed to a standard ground dimension (160x141).STDYThe y coordinate of the transaction transformed to a standard ground dimension (160x141).XY_FLIPINITIAL_TRX_IDThe transaction ID of the start of the chain.FINAL_TRX_IDThe transaction ID of the end of the chain.CHAIN_SQUADThe name of the squad in possession during the chain.INITIAL_STATEThe starting state of the chain.FINAL_STATEThe final state of the chain.ZONE_LOGICAL_INITIALThe zone in which the first transaction of the chain takes place, relative to the squad in possession.FINAL_ZONE_LOGICALThe zone in which the final transaction of the chain takes place, relative to the squad in possession.LAUNCH_PERSON_IDA unique numerical identifier of the player who launched the chain.LAUNCH_PLAYERThe full name of the player who launched the chain.GUILTY_PERSON_IDTurnover player PERSON_ID (if applicable).GUILTY_PLAYERTurnover player FULLNAME (if applicable).PARAM1Additional captured parameters on transactions, showing the Shot Source, Free Kick Reason, Inside 50 Side or Kick In DirectionPARAM2Additional captured parameters on transactions, showing the Shot Type, Free Kick Context or Inside 50 TypePARAM3Additional captured parameters on transactions, showing the Shot AnglePARAM4Additional captured parameters on transactions, showing the Shot DistanceKICK_FOOTOn kicking transactions, the foot of the kicking player.KICK_INTENTOn kicking transactions, the intent of the kicking player.KICK_DISTANCEOn kicking transactions, a description of the kicks distance.KICK_DIRECTIONOn kicking transactions, a description of the kicks direction.PRESSURE_LEVELThe name of the type of pressure applied (ie. Set Position).PRESSURE_PLAYER_IDA unique numerical identifier for the first pressure player.PRESSURE_PLAYERThe fullname of the first pressure player.PRESSURE_PLAYER2_IDA unique numerical identifier for the second pressure player.PRESSURE_PLAYER2The fullname of the second pressure player.PRESSURE_POINTSThe points value of the type of pressure applied.
Examplesβ
getAFLClubTrxFeed(matchId = 120390401)
getChains: Match Chainsβ
Descriptionβ
Get a list of possession chains for a match.
Usageβ
getChains(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of possession chains for a match, with one row per chain. NULL if the match is yet to start.
match.idA unique numerical identifier of a match.squad.idA unique numerical identifier of the squad.squad.nameThe name of the squad in possession during the chain.squad.codeA short code to represent the squad in possession during the chain.periodThe period of the possession chain.start.idThe transaction ID of the start of the chain.start.secsThe elapsed time within the period at the start of the chain.start.nameThe starting state of the chain.start.codeA short code representing the starting state of the chain.start.typeThe start type of the chain.start.type.codeA short code representing the starting type of the chain.start.zoneThe starting zone of the chain, relative to the squad in possession.start.zone.physicalThe starting zone of the chain, relative to the physical ground.start.xThe x-coordinate of the start of chain location.start.yThe y-coordinate of the start of chain location.launch.idA unique numerical identifier of the player who launched the chain.launch.nameThe full name of the player who launched the chain.launch.displayThe display name of the player who launched the chain, represented as first initial and surname.end.idThe transaction ID of the end of the chain.end.secsThe elapsed time within the period at the end of the chain.end.nameThe final state of the chain.end.codeA short code representing the final state of the chain.end.typeThe end type of the chain.end.type.codeA short code representing the end type of the chain.end.zoneThe final zone of the chain, relative to the squad in possession.end.zone.physicalThe final zone of the chain, relative to the physical ground.end.xThe x-coordinate of the end of chain location.end.yThe y-coordinate of the end of chain location.score.idThe transaction ID of the scoring shot, if a score was generated during the chain.score.resultA single letter representing the result scoring of the scoring shot, if a score was generated during the chain.score.result.nameThe full name of the result scoring shot, if a score was generated during the chain.score.pointsThe points generated by the scoring shot, if a score was generated during the chain.score.player.idA unique numerical identifier of the player who scored within the chain.score.player.nameThe full name of the player who scored within the chain.score.player.displayThe display name of the player who scored within the chain, represented as first initial and surname.turnover.player.idA unique numerical identifier of the player who turned the ball over at the end of the chain.turnover.player.nameThe full name of the player who turned the ball overa at the end of the chain.turnover.player.displayThe display name of the player who turned the ball overa at the end of the chain, represented as first initial and surname.turnover.typeThe type of turnover that was commited. Kick, handball or non-disposal.turnover.stateThe match state of the turnover that was commited. Clearing stoppage or General Play.turnover.creationThe creation method of the turnover that was commited. Forced/Unforced Giveaway or Opposition Takeaway.clearance.idThe transaction ID of the clearance that was won within the chain.inside50.idThe transaction ID of the first inside 50 that was generated by the squad in possession within the chain.rebound50.idThe transaction ID of the first rebound 50 that was generated by the squad in possession within the chain.stoppage.idThe first transaction ID of the chain in a stoppage chain.next.idThe transaction ID of the start of the next possession chain.prevoius.idThe transaction ID of the start of the previous possession chain.chain.metres.gainedMetres gained by a team within possession chains, combining measures towards attacking goal and away from defensive goal.chain.metres.gained.replyChain Metres conceded to the opposition in the next chain after a turnover.chain.metres.gained.netNet Metres gained in a chain of possession after subtracting opposition Metres gained after a turnover. Equal to Chain Metres minus Chain Metres Reply.
Examplesβ
getChains(216085122)
getCurrentSeason: Current Seasonβ
Descriptionβ
Get current season for a league and level.
Usageβ
getCurrentSeason(leagueId = 1, levelId = 1, ...)
Argumentsβ
leagueId: A unique numerical identifier of a league. Defaults to AFL Men's Premiership.levelId: A unique numerical identifier of a level. Defaults to Seniors....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A numerical value for season ID.
Examplesβ
getCurrentSeason(1,1)
getCurrentSeason()
getEntries: Match Entriesβ
Descriptionβ
Get a list of Inside 50 entries for a match.
Usageβ
getEntries(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of inside 50 entries for a match, with one row per entry. NULL if the match is yet to start.
match.idA unique numerical identifier of a match.entry.trx.idThe transaction ID of the entry, used for ordering chronologically.entry.periodThe period of the entry.entry.period.secsThe elapsed time within the period of the entry.entry.player.idA unique numerical identifier of the player responsible for the entry.entry.player.fullnameThe fullname of the player responsible for the entry.entry.player.display.nameThe display name of the player responsible for the entry.entry.squad.idA numerical identifier of the squad player responsible for the entry belongs to.entry.squad.nameThe name of the squad the player responsible for the entry belongs to.entry.squad.codeA short code to represent the squad the player responsible for the entry belongs to.entry.typeThe type of inside 50 entry.entry.source.nameThe game situation relative to the origin of a team's possession that results in an entry.entry.source.typeInside 50 entries where direct indicates the first chain after the specified entry.source.name - For centre bounce and midfield stoppageentry.source.name, direct indicates the entry was in the clearance chain - For repeatentry.source.name, direct indicates the entry was on the first turnover chain after an opposition rebound 50 - For transitionentry.source.name, direct indicates the entry was in the same chain as the rebound 50entry.kick.is.groundFor inside 50 entries that are kicks, was the entry from a ground kick (true/false).entry.kick.footFor inside 50 entries that are kicks, which foot did the kicking player use.entry.kick.intentFor inside 50 entries that are kicks, the intent of the kicker.entry.kick.distanceFor inside 50 entries that are kicks, the distance of the kick.entry.kick.directionFor inside 50 entries that are kicks, the direction of the kickentry.kick.launch.distance.to.goalFor inside 50 entries that are kicks, the straight line distance to goal from the launch point of the kick.entry.kick.result.distance.to.goalFor inside 50 entries that are kicks, the straight line distance to goal from the result point of the kick.entry.kick.pressure.nameFor inside 50 entries that are kicks, the name of the type of pressure applied to the kicker.entry.kick.pressure.codeFor inside 50 entries that are kicks, a short code to describe the type of pressure applied to the kicker.entry.kick.pressure.pointsFor inside 50 entries that are kicks, the number of points associated with the pressure type applied to the kicker.entry.kick.launch.location.xThe x coordinate of the inside 50 launch location.entry.kick.launch.location.yThe y coordinate of the inside 50 launch location.entry.kick.launch.location.x.stdThe x coordinate of the inside 50 launch location transformed to a standard ground dimension (160x141).entry.kick.launch.location.y.stdThe y coordinate of the inside 50 launch location transformed to a standard ground dimension (160x141).entry.kick.launch.location.rotated.xThe x coordinate of the inside 50 launch location rotated to give all squads attacking left-to-right.entry.kick.launch.location.rotated.yThe y coordinate of the inside 50 launch location rotated to give all squads attacking left-to-right.entry.kick.launch.location.rotated.x.stdThe x coordinate of the inside 50 launch location transformed to a standard ground dimension (160x141) & rotated to give all squads attacking left-to-right.entry.kick.launch.location.rotated.y.stdThe x coordinate of the inside 50 launch location transformed to a standard ground dimension (160x141) & rotated to give all squads attacking left-to-right.entry.kick.result.location.xThe x coordinate of the inside 50 result location.entry.kick.result.location.yThe y coordinate of the inside 50 result location.entry.kick.result.location.x.stdThe x coordinate of the inside 50 result location transformed to a standard ground dimension (160x141).entry.kick.result.location.y.stdThe y coordinate of the inside 50 result location transformed to a standard ground dimension (160x141).entry.kick.result.location.rotated.xThe x coordinate of the inside 50 result location rotated to give all squads attacking left-to-right.entry.kick.result.location.rotated.yThe y coordinate of the inside 50 result location rotated to give all squads attacking left-to-right.entry.kick.result.location.rotated.x.stdThe x coordinate of the inside 50 result location transformed to a standard ground dimension (160x141) & rotated to give all squads attacking left-to-right.entry.kick.result.location.rotated.y.stdThe y coordinate of the inside 50 result location transformed to a standard ground dimension (160x141) & rotated to give all squads attacking left-to-right.
Examplesβ
getEntries(216085122)
getFixture: Fixtureβ
Descriptionβ
Get the fixture for a given season.
Usageβ
getFixture(
seasonId,
squadId = NULL,
roundNumber = NULL,
leagueId = 1,
levelId = 1,
...
)
Argumentsβ
seasonId: A numerical identifier of a season. If missing, defaults to the current season of the League Level defined by 'leagueId' and 'levelId'.squadId: An (optional) parameter to specify a specific squad ID to pull in the fixture for a single squad that plays within the given season/league/level's fixture.roundNumber: An (optional) parameter to specify a round number for the given season/league/level's fixture. Defaults to most recent round if not supplied.leagueId: A unique numerical identifier of a league. Defaults to AFL Men's Premiership.levelId: A unique numerical identifier of a level. Defaults to Seniors....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with the fixture for a given season, with one row per match.
competition.nameThe name of the competition.competition.codeA short code describing the competition.competition.idA unique numerical identifier of the competition.season.idA numerical identifier of a season.season.start.dateThe start date of the season.season.end.dateThe end date of the season.round.phaseNumberThe round number of the match within the phase. Starts again from one for finals.phase.nameThe name of the phase of the season.phase.codeA short code describing the phase of the season.phase.idA unique numerical identifier of the phase.round.numberThe round number of the match. Continues to count up during finals.round.nameThe name of the round.round.codeA short code representing the name of the round.round.idA unique numerical identifier of the round.venue.nameThe name of the match venue.venue.codeA short code to represent the match venue.venue.idA unique numerical identifier of the match venue.venue.timezoneThe time zone of the match venue.match.idA unique numerical identifier of a match.type.nameA description of the match type.match.type.codeA short code representing the match type.match.type.idA numerical indicator of the match type.match.orderThe order of a match within a round, sorted by start date and time.match.dateThe calendar date of the match in local time.match.timeThe local start time of the match.match.startThe start time of the match in UTC time.status.nameThe match's current status.match.status.codeA short code representing the match's current status.status.idA numerical identifier of the match's current status.match.status.periodThe current period of the match.match.status.period.secsThe number of seconds elapsed in the current period.match.status.period.displayA display string of the current period.match.status.match.displayThe match's current status type.home.nameThe name of the home squad.home.codeA short code to represent the home squad.home.idA unique numerical identifier of the home squad.home.goalsThe number of goals kicked by the home squad.home.behindsThe number of behinds kicked by the home squad.home.pointsThe number of points scored by the home squad.away.nameThe name of the away squad.away.codeA short code to represent the away squad.away.idA unique numerical identifier of the away squad.away.goalsThe number of goals kicked by the away squad.away.behindsThe number of behinds kicked by the away squad.away.pointsThe number of points scored by the away squad.winning.squad.id.matchThe unique numerical identifier of the winning squad for the match.
Examplesβ
getFixture(2022)
getFixture()
getLadder: Ladderβ
Descriptionβ
Get the ladder for a given season.
Usageβ
getLadder(
seasonId,
roundNumber = NULL,
conference = NULL,
leagueId = 1,
levelId = 1,
...
)
Argumentsβ
seasonId: A numerical identifier of a season. If missing, defaults to the current season of the League Level defined by 'leagueId' and 'levelId'.roundNumber: An integer indicating the round number you are interested in. Returns the ladder as it stood after that round had completed. Defaults to the current ladder, or end of Home & Away for past seasons.leagueId: A unique numerical identifier of a league. Defaults to AFL Men's Premiership.levelId: A unique numerical identifier of a level. Defaults to Seniors....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with the requested ladder, with one row per squad.
season.idA numerical identifier of a season.round.numberThe round number of the match. Continues to count up during finals.positionThe squads ladder position.squad.idA unique numerical identifier of the squad.squad.nameThe name of the squad.squad.codeA short code to represent the squad.ladder.pointsThe number of ladder points accumulated by the squad.ladder.percentageThe squad's ladder percentage, calculated by points scored divided by points conceded.playedThe number of matches played by the squad.winThe number of matches the squad has won.win.pctThe percentage of completed matches the squad has won.drawThe number of matches the squad has drawn.lossThe number of matches the squad has lost.total.forThe total number of points scored by the squad.total.againstThe total number of points conceded by the squad.total.marginThe total points differential for the squad.average.forThe average number of points scored by the squad per match.average.againstThe average number of points conceded by the squad per match.average.marginThe average points differential for the squad per match.
Examplesβ
getLadder(2022)
getLadder(2022,4)
getLadder()
getLeaders: Match Stat Leadersβ
Descriptionβ
Get leading five players for selected stats for a match.
Usageβ
getLeaders(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of the five leading players for selected metrics.
match.idA unique numerical identifier of a match.codeThe metric code (ALL_CAPS format).nameThe metric name (singular).pluralThe metric name (plural).idA unique numerical identifier of a metric.player.idA unique numerical identifier of the player.player.nameThe full name of the player.player.displayThe display name of the player, represented as first initial and surname.player.jumper.numberThe jumper number worn on the players's uniform.squad.idA unique numerical identifier of the squad.squad.nameThe name of the squad.squad.codeA short code to represent the squad.valueThe numeric metric value with no formatting applied.displayThe formatted metric value as a text string.rankDense rank within metric, with ties presented as ties.method='min'.orderOrder within the metric with no ties. Ties in metric value are broken by ordering by player surname then firstname.
Examplesβ
getLeaders(216085122)
getLeaguesLevelsInfo: League/Level Metadataβ
Descriptionβ
Get details about all leagues and levels exposed in the Champion Data AFL API.
Usageβ
getLeaguesLevelsInfo(leagueId, levelId, ...)
Argumentsβ
leagueId: A unique numerical identifier of a league. (ie.leagueId = 3)levelId: A unique numerical identifier of a level. (ie.level = 1)...: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with details about a league and level.
current.season.idThe season ID of the current season for a particular league.league.nameThe name of the league.league.codeA short code representing the name of the league.league.idA unique numerical identifier of the league.level.nameThe name of the level.level.codeA short code representing the name of the level.level.idA unique numerical identifier of the level.level.classification.idA unique numerical identifier of the given levels' classification.level.classification.codeA short code representing thegiven levels' classificationie. 'AFLTIER1'league.genderA short code representing The gender of a league. "M" for Men's, "W" for Women's.competition.idThe competition ID for the particular league/level.championship.idThe championship ID for the particular league/level.
Examplesβ
getLeagueInfo(leagueId = 12)
getMatch: Match Detailsβ
Descriptionβ
Get details about a match.
Usageβ
getMatch(matchId, periods = FALSE, ...)
Argumentsβ
matchId: An unique numerical identifier of a match.periods: LogicalTRUE / FALSE. Return period-level information? Defaults to FALSE....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with details about a match.
competition.nameThe full name of the competition.season.idA numerical identifier of a season.type.idA numerical indicator of the match type.type.nameA description of the match type.type.codeA short code describing the match type.round.numberThe round number of the match. Continues to count up during finals.round.phaseNumberThe round number of the match within the phase. Starts again from one for finals.match.idA unique numerical identifier of a match.match.nameThe name of the match. Concatenates home and away squad names.match.codeA short code for the name of the match. Concatenates home and away squad codes.match.startThe start time of a match in UTC time.match.dateThe calendar date of a match in local time.match.timeThe local start time of a match.home.idA unique numerical identifier of the home squad.home.nameThe name of the home squad.home.codeA short code to represent the home squad.away.idA unique numerical identifier of the away squad.away.nameThe name of the away squad.away.codeA short code to represent the away squad.venue.idA unique numerical identifier of the match venue.venue.nameThe name of the match venue.venue.codeA short code to represent the match venue.venue.timezoneThe timezone of the venue.match.status.periodThe current period of the match (or last period of the match if match complete).match.status.period.secsThe elapsed seconds within the current period.match.status.period.displayA display format of the current period & period seconds (Eg."Q3 01:28").countdown.remaining.secsThe number of remaining seconds in the current period, counting down from 1200.countdown.remaining.timeThe remaining time in the current period, formatted as minutes and seconds (Eg."04:24")countdown.remaining.displayA display format of current period & remaining time (Eg."Q3 04:24")match.status.codeA short code to represent the match's current status.match.status.nameThe match's current status.match.status.idA numerical identifier of the match's current status.match.status.type.idA numerical identifier of the match status type.match.status.type.nameThe match's current status type.home.goalsThe number of goals kicked by the home squad.home.behindsThe number of behinds kicked by the home squad.home.pointsThe number of points scored by the home squad.away.goalsThe number of goals kicked by the away squad.away.behindsThe number of behinds kicked by the away squad.away.pointsThe number of points scored by the away squad.winner.idThe squad ID of the winning team.resultA text description of the match result.result.codeA short text description of the match result.coin.toss.winning.squad.idThe squad id of the squad who won the coin toss.coin.toss.direction.decisionThe direction the squad who won the coin toss decided to kick to.attendanceThe crowd attendance for the given match.match.start.scheduledThe scheduled start time for the match in UTC.match.start.actualThe actual start time for the match in UTC.match.end.actualThe actual end time for the match in UTC.match.total.period.secsThe total duration of the match in seconds (Eg.7149)match.total.durationThe total duration of the match in display format (Eg.119:09)statistic.updateThe last UTC time that a statistic was last updated for a match.
Examplesβ
getMatch(216085122)
getMatchPersons: Match Personsβ
Descriptionβ
Get a list of persons involved in a match. Currently limited to the players or field umpires.
Usageβ
getMatchPersons(matchId, officials = FALSE, ...)
Argumentsβ
matchId: An unique numerical identifier of a match.officials: Logical. Return match officials? Defaults to FALSE = Return players....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of persons for a match, with one row per person.
match.idA unique numerical identifier of the match.squad.idA unique numerical identifier of the squad. (Players only)squad.nameThe name of the squad. (Players only)squad.codeA short code to represent the squad. (Players only)person.idA unique numerical identifier of a player.person.nameThe player's full name.person.firstnameThe player's first name.person.surnameThe player's surname.person.displayThe player's display name, represented as first initial and surname.jumperThe jumper number worn on the players's uniform.selected.idA numerical identifier of the player's selected position.selected.nameThe player's selected position.selected.codeA short code representing the player's selected position.position.idA numerical identifier of the player's primary position in that season. (Players only)position.nameThe player's primary position in that season. (Players only)position.codeA short code representing the peron's primary position in that season. (Players only)heightThe player's height in centimetres. (Players only)weightThe player's weight in kilograms. (Players only)DOBThe player's date of birth (YYYY-MM-DD). (Players only)ageThe player's age at the start of the match, to one decimal place. (Players only)
Examplesβ
getMatchPersons(216085122)
getMatchPersons(216085122,officials=TRUE)
getMatchTransactions: Match Transactionsβ
Descriptionβ
Get the list of transactions for a match. Returns a dataframe with fixed column length, irrespective of any fields having recorded values for match or not.
Usageβ
getMatchTransactions(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of transactions for a match.
match.idA unique numerical identifier for a match.trx.idA unique numerical identifier for a given transaction, used for ordering chronologically.stat.codeThe statistic code for a given transaction.stat.descA short description of the statistic code for a transaction.periodThe period of the transaction.period.secsThe elapsed time within the period of a transaction.score.homeThe score of the home squad.score.awayThe score of the away squad.squad.nameThe name of the squad.squad.codeA short code to represent the squad.squad.idA unique numerical identifier for the squad.person.fullnameThe fullname of the player assigned to the transaction (if applicable).person.displayNameThe display name of the player assigned to the transaction (if applicable).person.idA unique numerical identifier for the player assigned to the transaction (if applicable).pressure.squad.nameThe name of the squad the pressure information is assigned to.pressure.squad.idA unique numerical identifier for the squad the pressure information is assigned to.pressure.squad.codeA short code to represent the squad the pressure information is assigned to.pressure.nameThe name of the type of pressure applied (ie. Set Position).pressure.codeA short code to represent the type of pressure applied.pressure.pointsThe points value of the type of pressure applied.pressure.fullname1The fullname of the first pressure player.pressure.displayname1The display name of the first pressure player.pressure.personid1A unique numerical identifier for the first pressure player.pressure.role1The role number of the first pressure player (1).pressure.fullname2The fullname of the second pressure player.pressure.displayname2The display name of the second pressure player.pressure.personid2A unique numerical identifier for the second pressure player.pressure.role2The role number of the second pressure player (2).zone.physicalThe zone in which the transaction takes place, relative to the physical ground.zone.logicalThe zone in which the transaction takes place, relative to the squad in possession.location.xThe x coordinate of the transaction.location.ythe y coordinate of the transaction.location.x.stdThe x coordinate of the transaction transformed to a standard ground dimension (160x141).location.y.stdThe y coordinate of the transaction transformed to a standard ground dimension (160x141).location.rotated.xThe x coordinate of the transaction rotated to give all squads attacking left-to-right.location.rotated.yThe y coordinate of the transaction rotated to give all squads attacking left-to-right.location.rotated.x.stdThe x coordinate of the transaction transformed to a standard ground dimension (160x141) & rotated to give all squads attacking left-to-right.location.rotated.y.stdThe y coordinate of the transaction transformed to a standard ground dimension (160x141) & rotated to give all squads attacking left-to-right.kicking.footOn kicking transactions, the foot of the kicking player.kicking.intentOn kicking transactions, the intent of the kicking player.kicking.distanceOn kicking transactions, a description of the kicks distance.kicking.directionOn kicking transactions, a description of the kicks direction.inside50.directionOn inside 50 transactions, a description of the kicks direction.inside50.intentOn inside 50 transactions, the intent of the kicking player.shot.angleA text description of the angle of the shot.shot.distanceA text description of the distance of the shot.shot.resultThe result of the shot on goal (Does not include Goals).shot.sourceThe source from which the shot on goal resulted (ie. General Play).shot.typeThe type of shot attempted (ie. General Play Snap).freekick.contextOn free kick transactions, the broad context from which the free kick was awarded.freekick.reasonOn free kick transactions, the specific reason the free kick was awarded.kickin.directionOn kick in transactions, a text description of the direction taken from the kick in.time.capture.UTCThe date and time of the event in UTC.time.capture.flagBoolean indicating if the timestamp was captured using time capture or calculated using period start utc and elapsed seconds.
Examplesβ
getMatchTransactions(216085122)
getMetrics: Match Metricsβ
Descriptionβ
Get a dataframe of available metrics for each match
Usageβ
getMetrics(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with all of the rotations for a given match.
match.idA unique numerical identifier of a match.metric.levelA numerical identifier of the metric level.metric.level.idA unique numerical identifier of the metric level.metric.codeA short code representing the metric.metric.nameThe metric name (singular).metric.idA unique numerical identifier of a metric.metric.name.shortAn abbreviated metric name (max 25 characters).metric.name.short.codeAn abbreviated, capitalised code for the metric name.metric.name.pluralThe metric name (plural).metric.name.displayThe display version of the metric name in camel case format.metric.descriptionThe text description of the metric definition.metric.formatThe format in which the metric is recorded (Eg.'Integer','Percentage One Decimal'metric.format.idA numerical identifier of the metric format.metric.format.avgThe average format applied to the metric, if applicable.metric.format.avg.idA numerical identifier of the averages metric format.metric.isTransactionalIndicates whether the metric is recorded at a transactional levelTRUE/FALSE.
Examplesβ
getMetrics(216085122)
getPeriodScores: Period Scoresβ
Descriptionβ
Get a a list of match scores by quarter.
Usageβ
getPeriodScores(matchId, cumulative = FALSE, ...)
Argumentsβ
matchId: A unique numerical identifier of a match.cumulative: Logical. Return scores up to and including that quarter? Defaults to FALSE, which returns scores within the quarter only....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of quarters and scores for each quarter.
match.idA unique numerical identifier of a match.periodThe period of the match.home.nameThe name of the home squad.home.codeA short code to represent the home squad.home.idA unique numerical identifier of the home squad.home.goalsGoals scored by the home squad.home.behindsBehinds scored by the home squad.home.pointsPoints scored by the home squad.home.marginScoreboard margin for the home squad.home.period.resultPeriod result for the home squadWin/Loss/Drawhome.period.result.codePeriod result code for the home squadW/L/Dhome.match.resultMatch result for the home squadW/L/Daway.nameThe name of the away squad.away.codeA short code to represent the away squad.away.idA unique numerical identifier of the away squad.away.goalsGoals scored by the away squad.away.behindsBehinds scored by the away squad.away.pointsPoints scored by the away squad.away.marginScoreboard margin for the away squad.away.period.resultPeriod result for the away squadWin/Loss/Drawaway.period.result.codePeriod result code for the away squadW/L/Daway.match.resultMatch result for the away squadW/L/Dwinning.squad.id.periodThe squad ID of the winning squad for the given period.winning.squad.id.matchThe squad ID of the winning squad for the match.cumulativeTRUE/FALSE based on thecumulativeparameter passed to the function.
Examplesβ
getPeriodScores(216085122)
getPeriodScores(216085122,cumulative=TRUE)
getPlayerStats: Match Player Statsβ
Descriptionβ
Get player stats for a match. Only returns observed metrics.
Usageβ
getPlayerStats(
matchId,
period = NULL,
zone = NULL,
metric = NULL,
team = NULL,
lastXseconds = NULL,
from = NULL,
to = NULL,
...
)
Argumentsβ
matchId: A unique numerical identifier of a match.period: A numerical indicator of a period to filter results within a match. Accepts integer values.zone: A text indicator of a zone on the field to filter results within a match. Accepts string values:"D50","DM","AM","F50","CB".metric: A text string of specific metric code(s) to be returned. This will result in the endpoint only returning these specific metrics. Note this endpoint is case sensitive and only works with metric codes (ie.c("TACKLE", "GOAL")team: A (case-sensitive) text string of the team to return metrics for. Either"home"or"away". Not passing anything to this param will return both teams.lastXseconds: An integer that limits statistics to counting events that occurred in the last X number of seconds. (ie.lastXSeconds = 300will return the last 5 minutes)from: Limits statistics to counting events that occurred on or after this number of seconds (ie.from = 300will return statistics that occured on or after the 300th second into the match)to: Limits statistics to counting events that occurred on or before this number of seconds (ie.to = 300will return statistics that occured up to (and including) the 300th second into the match)...: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of metrics for a match for each player.
squad.idA unique numerical identifier of the squad.squad.nameThe name of the squad.squad.codeA short code to represent the squad.player.idA unique numerical identifier of the player.player.nameThe full name of the player.player.displayThe display name of the player, represented as first initial and surname.codeThe metric code (ALL_CAPS format).nameThe metric name (singular).idThe unique numerical identifier for the given statistic code.pluralThe metric name (plural).valueThe numeric metric value with no formatting applied.displayThe formatted metric value as a text string.
Examplesβ
getPlayerStats(216085122)
getPlayerStats(216085122,period=1,zone='D50',from = 0,to = 300)
getPlayerStatsPOST: Match Player Stats (POST Endpoint)β
Descriptionβ
Get player stats for a match via a payload to the POST endpoint.
Usageβ
getPlayerStatsPOST(matchId, payload, info = FALSE, verbose = FALSE, ...)
Argumentsβ
matchId: A unique numerical identifier of a match.payload: A nested list containing the parcels of data to be returned by the API. See:createPayload()as a method of simplifying this step.metricCodes (list): A list of the metric codes of the desired metrics (ie.list("TACKLE","CHAIN_LAUNCH_CB_GB")) Default Behaviour: If no metric code(s) are specifically selected, will return ALL valid metrics.periods (list): A list of the desired match periods (ie.list(1,2,3,4)) Default Behaviour: If no period(s) are specifically selected, will return data for the MATCH.zones (list): A list of the desired zones (ie.list("AM","D50")) Default Behaviour: If no zones are specifically selected, will return data for ALL zones.context (character): The context in which the data will be returned (Squadβonly parameter) (ie."For","Against","diff") Default Behaviour: If no context is specifically selected, will return data in the 'For' context.id (character): A userβsettable identifier for the given payload, e.g."Q1_F50_Tackles") Default Behaviour: If no id is specifically passed in to a given payload list, the given list(s) will have their index in the payload order returned as an integer starting from 0.lastXseconds (numeric): Limits statistics to counting events that occurred in the last X number of seconds (ie. lastXseconds = 300 will return data from the last 5 minutes) Default Behaviour: If no lastXseconds value is specifically supplied, NO filter on match period seconds will be applied.fromPeriodSeconds (numeric): Limits statistics to counting events from this point in the period/match (ie. fromPeriodSeconds = 300 will return data up to the first 5 minutes onwards) Default Behaviour: If no fromPeriodSeconds value is specifically supplied, NO filter on match period seconds will be applied.toPeriodSeconds (numeric): Limits statistics to counting events to this point in the period/match (ie. toPeriodSeconds = 300 will return data from the first 5 minutes onwards) Default Behaviour: If no toPeriodSeconds value is specifically supplied, NO filter on match period seconds will be applied.info: A logical (TRUE/FALSE) to include the payload information alongside the data for each payload. Defaults toFALSEverbose: A logical (TRUE/FALSE) indicating whether to enable verbose messaging to the console. When set toTRUE, the function will print additional information and progress messages to the console to provide a more detailed view of its execution. Defaults toFALSEfor a quieter output....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of metrics supplied by the payload for each player in a match.
match.idA unique numerical identifier of a match.squad.nameThe name of the squad.squad.codeA short code to represent the squad.squad.idA unique numerical identifier of the squad.player.nameThe full name of the player.player.displayThe display name of the player, represented as first initial and surname.player.idA unique numerical identifier of the player.stat.codeThe metric code (ALL_CAPS format).stat.nameThe metric name (singular).stat.pluralThe metric name (plural).valueThe numeric metric value with no formatting applied.displayThe formatted metric value as a text string.idA unique identifier string able to be supplied by the user for each list in the payload. Defaults to numerical index starting at 0.info.metric.codes(wheninfo = TRUE) The metric code(s) supplied to the specific list in the payload for that row of data.info.periods(wheninfo = TRUE) The period(s) supplied to the specific list in the payload for that row of data.info.zones(wheninfo = TRUE) The zone(s) supplied to the specific list in the payload for that row of data.info.team(wheninfo = TRUE) The team supplied to the specific list in the payload for that row of data.info.context(wheninfo = TRUE) The match context supplied to the specific list in the payload for that row of data.
Examplesβ
## Payload Example:
playerPOSTPayloadExample <- list(
playerMetricRequests = list(
list(
metricCodes = list("KICK", "MARK", "HANDBALL", "GOAL"),
periods = list(),
zones = list(),
team = "home" ,
id = "homeTeam (kick,mark,handball,goal)"
)
)
)
## Function Run:
getPlayerStatsPOST(matchId = 120390401, payload = playerPOSTPayloadExample, info = T, verbose = T)
getPlayerSummaryFile: AFL Player Summary Fileβ
Descriptionβ
Get the AFL Player Summary File formerly available via the support site.
Usageβ
getPlayerSummaryFile(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame in the same format and structure as the AFL Club Transaction Feed file formerly available via the support site.
MATCH_IDA unique numerical identifier of a match.SEASON_IDA numerical identifier of a season.GROUP_ROUND_NOThe round number of the match. Continues to count up during finals.VENUE_NAMEThe name of the match venue.PERSON_IDA unique numerical identifier for the player assigned to the given row.FULLNAMEThe fullname of the player assigned to the given row.SQUAD_NAMEThe name of the squad for the given row.OPP_SQUAD_NAMEThe name of the opposition squad for the given row.SQUAD_MARGINThe final margin of the match in relation to the team listed under SQUAD_NAME.MARGINThe margin at the end of the given period in relation to the team listed under SQUAD_NAME.ZONE_LOGICAL_AFLThe zone in which the values within metrics that follow are belonging to, relative to the squad listed under SQUAD_NAME.
Examplesβ
getPlayerSummaryFile(matchId = 120390401)
getRotations: Match Rotationsβ
Descriptionβ
Get a dataframe of rotations for a match.
Usageβ
getRotations(matchId, currentStints = FALSE, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with all of the rotations for a given match.
match.idA unique numerical identifier of a match.squad.nameThe name of the squad the rotation player belongs to.squad.codeA short code to represent the squad the rotation player belongs to.squad.idA unique numerical identifier of the squad the rotation player belongs to.periodThe period the rotation occured in.secsThe elapsed time within the period the rotation occured in.idThe transaction ID of the rotation, used for ordering chronologically.off.nameThe full name of the player coming off the ground.off.displayThe display name of the player coming off the ground, represented as first initial and surname.off.idA unique numerical identifier of the player coming off the ground.on.nameThe full name of the player coming on the ground. Empty for start-of-match initialisation of the interchange bench.on.displayThe display name of the player coming on the ground, represented as first initial and surname. Empty for start-of-match initialisation of the interchange bench.on.idA unique numerical identifier of the player coming on the ground. Empty for start-of-match initialisation of the interchange bench.off.reasonThe reason for the rotation (ie.'Regular' , 'Injured'.)off.codeA short text description of the reason for the rotation (ie.'REG' , 'INJ'.)squad.name(whencurrentStints = TRUE) The name of the squad a given players rotation stint belongs to.squad.code(whencurrentStints = TRUE) A short code to represent the squad a given players rotation stint belongs to.squad.id(whencurrentStints = TRUE) A unique numerical identifier of the squad a given players rotation stint belongs to.player.fullname(whencurrentStints = TRUE) The full name of the player the rotation stint belongs to.player.display.name(whencurrentStints = TRUE) The display name of the player the rotation stint belongs to, represented as first initial and surname.player.id(whencurrentStints = TRUE) A unique numerical identifier of the player the rotation stint belongs to.current.stint.period(whencurrentStints = TRUE) The period the given rotation stint occurred in.current.stint.period.secs(whencurrentStints = TRUE) The period seconds value that the given rotation stint startedcurrent.stint.elapsed.secs(whencurrentStints = TRUE) The elapsed seconds that the given stint has been going for.current.stint.status(whencurrentStints = TRUE) The status of the given rotation stint (ie.'ON' , 'OFF'.)current.stint.reason(whencurrentStints = TRUE) The reason for the given rotation stint (ie.'Regular' , 'Injured'.)current.stint.reason.code(whencurrentStints = TRUE) A short text description of the reason for the given rotation stint (ie.'REG' , 'INJ'.)
Examplesβ
getRotations(matchId = 120390401)
getRuckContests: Match Ruck Contest Summaryβ
Descriptionβ
Get a summary of ruck contest statistics for a given match.
Usageβ
getRuckContests(matchId, stoppageType = NULL, ...)
Argumentsβ
matchId: A unique numerical identifier of a match.stoppageType: Filter statistics to a specific type(s) of ruck contest, any one of:'centreBounce', 'ballUp', 'throwIn'Can accept multiple arguments in a character vector (ie.stoppageType = c('ballUp', 'throwIn'))...: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a summary of ruck contest statistics for a given match.
match.id: The unique identifier for the match.total.contests: The total number of ruck contests between the home & away ruck combination.home.ruck.squad.code: Squad code for the home team's ruckman.home.ruck.squad.id: Squad ID for the home team's ruckman.home.ruck.fullname: Fullname of the home team's ruckman.home.ruck.display.name: Display name of the home team's ruckman.home.ruck.person.id: Person ID of the home team's ruckman.away.ruck.squad.code: Squad code for the away team's ruckman.away.ruck.squad.id: Squad ID for the away team's ruckman.away.ruck.fullname: Fullname of the away team's ruckman.away.ruck.display.name: Display name of the away team's ruckman.away.ruck.person.id: Person ID of the away team's ruckman.home.ruck.hitouts: Total number of hitouts by the home team's ruckman.home.ruck.hitouts.advantage: Total number of hitouts to advantage by the home team's ruckman.home.ruck.hitouts.sharked: Total number of hitouts sharked from the home team's ruckman.home.ruck.first.possessions: Total number of first possessions gathered by the home team while the given home ruck was in the ruck contest.home.ruck.clearances: Total number of clearances gathered by the home team while the given home ruck was in the ruck contest.home.ruck.goals: Total number of goals gathered by the home team while the given home ruck was in the ruck contest (in home team clearance chains).home.ruck.behinds: Total number of behinds gathered by the home team while the given home ruck was in the ruck contest (in home team clearance chains).home.ruck.points: Total number of points gathered by the home team while the given home ruck was in the ruck contest (in home team clearance chains).away.ruck.hitouts: Total number of hitouts by the away team's ruckman.away.ruck.hitouts.advantage: Total number of hitouts to advantage by the away team's ruckman.away.ruck.hitouts.sharked: Total number of hitouts sharked from the away team's ruckman.away.ruck.first.possessions: Total number of first possessions gathered by the away team while the given away ruck was in the ruck contest.away.ruck.clearances: Total number of clearances gathered by the away team while the given away ruck was in the ruck contest.away.ruck.goals: Total number of goals gathered by the away team while the given away ruck was in the ruck contest (in away team clearance chains).away.ruck.behinds: Total number of behinds gathered by the away team while the given away ruck was in the ruck contest (in away team clearance chains).away.ruck.points: Total number of points gathered by the away team while the given away ruck was in the ruck contest (in away team clearance chains).
Examplesβ
getRuckContests(120390401)
getRuckContests(120390401, stoppageType=c('ballUp', 'throwIn'))
getSeasons: Seasons Infoβ
Descriptionβ
Get information about all available seasons for a given league/level.
Usageβ
getSeasons(leagueId = 1, levelId = 1, seasonId, ...)
Argumentsβ
leagueId: A unique numerical identifier of a league. Defaults to AFL Men's Premiership.levelId: A unique numerical identifier of a level. Defaults to Seniors (1).seasonId: A numerical identifier of a season. If missing, defaults to the current season of the League Level defined by 'leagueId' and 'levelId'....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of metrics for a match for each player.
competition.nameThe name of the competition.competition.codeA short code describing the competition.competition.idA unique numerical identifier of the competition.season.idA numerical identifier of a season.season.start.dateThe start date of the season.season.end.dateThe end date of the season.league.idA unique numerical identifier of the league.league.nameThe name of the league.league.codeA short code representing the name of the league.league.genderA short code representing The gender of a league. "M" for Men's, "W" for Women's.matches.completeThe number of matches in the season that have been completed.matches.incompleteThe number of matches as-yet incomplete for the season.first.match.startThe date-time of the first match of the season.last.completed.round.numberThe round number of the last completed round of the next scheduled round of the season.last.completed.round.startThe start date-time of the last completed round of the season.last.completed.round.endThe end date-time of the last completed round of the season.next.scheduled.round.numberThe round number of the next scheduled round of the season.next.scheduled.round.startThe start date-time of the next scheduled round of the season.next.scheduled.round.endThe end date-time of the next scheduled round of the season.
Examplesβ
getSeasons()
getSeasons(leagueId = 12)
getShots: Match Shotsβ
Descriptionβ
Get a list of shots at goal for a match. Also includes rushed behinds.
Usageβ
getShots(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of shots at goal for a match, with one row per shot.
match.idA unique numerical identifier of a match.idThe transaction ID of the shot, used for ordering chronologically.periodThe period of the shot.secsThe elapsed time within the period of the shot.squad.idA unique numerical identifier of the squad.squad.nameThe name of the squad.squad.codeA short code to represent the squad.player.idA unique numerical identifier of the player taking the shot.player.nameThe full name of the player taking the shot.player.displayThe display name of the player taking the shot, represented as first initial and surname.originHow the player was able to generate a shot at goal.typeThe type of shot attempted.angleA text description of the angle of the shot.distanceA text description of the distance of the shot.xDistance of the shot in metres from the centre of the ground (measuring horizontally from goal to goal), with the goals being at positive (venue_length / 2).yDistance of the shot in metres from the centre of the ground (measuring vertically from wing to wing), with the goals being at zero and the boundary line at halfway being at (venue_width / 2). Positive y is bottom of screen when running to the right.x.stdThe x coordinate of the shot transformed to a standard ground dimension (160x141).y.stdThe y coordinate of the shot transformed to a standard ground dimension (160x141).accuracy.expThe expected accuracy of the shot.resultThe result of the shot. G / B / R / M.points.expThe expected points of the shot.pointsThe number of points obtained from the shot.
Examplesβ
getShots(216085122)
getSquadLists: Squad Person Listsβ
Descriptionβ
Get a list of persons involved in all squads in a season. Currently limited to the playing list.
Usageβ
getSquadLists(seasonId, leagueId = 1, levelId = 1, ...)
Argumentsβ
seasonId: A numerical identifier of a season. If missing, defaults to the current season of the League Level defined by 'leagueId' and 'levelId'.leagueId: A unique numerical identifier of a league. Defaults to AFL Men's Premiership.levelId: A unique numerical identifier of a level. Defaults to Seniors....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of persons for all squads, with one row per person.
season.idA numerical identifier of a season.squad.idA unique numerical identifier of the squad.squad.nameThe name of the squad.idA unique numerical identifier of a person.firstnameThe person's first name.surnameThe person's surname.nameThe person's full name.displayThe person's display name, represented as first initial and surname.positionThe person's primary position within a season. The position where a player has spent most time.DOBThe person's date of birth (YYYY-MM-DD).age.seasonThe person's age in years at the start of the first game of the season, to one decimal place.age.yearThe person's age at December 31 of the year in which the season ends, rounded down to a whole year.heightThe person's height in centimetres.weightThe person's weight in kilograms.
Examplesβ
getSquadLists(2022)
getSquadPersons: Squad Person Listβ
Descriptionβ
Get a list of persons involved in a squad in a season. Currently limited to the playing list.
Usageβ
getSquadPersons(squad, seasonId, leagueId = 1, levelId = 1, ...)
Argumentsβ
squad: An identifier of the squad. Accepts a numerical squad ID or a text squad name.seasonId: A numerical identifier of a season. If missing, defaults to the current season of the League Level defined by 'leagueId' and 'levelId'.leagueId: A unique numerical identifier of a league. Defaults to AFL Men's Premiership.levelId: A unique numerical identifier of a level. Defaults to Seniors....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of persons for a squad, with one row per person.
season.idA numerical identifier of a season.squad.nameThe name of the squad.squad.codeA short code to represent the name of the squad.squad.idA unique numerical identifier of the squad.fullnameThe full name of the person.displayThe person's display name, represented as first initial and surname.firstnameThe person's first name.surnameThe person's surname.idA unique numerical identifier of a person.jumper.numberThe jumper number worn on the players's uniform.positionThe person's primary position within a season. The position where a player has spent most time.DOBThe person's date of birth (YYYY-MM-DD).age.seasonThe person's age in years at the start of the first game of the season, to one decimal place.age.yearThe person's age at December 31 of the year in which the season ends, rounded down to a whole year.age.todayThe person's age as of the current date, to one decimal place.heightThe person's height in centimetres.weightThe person's weight in kilograms.position.longThe full text description of a players primary position within a season. (Eg.'General Defender')positionThe person's primary position within a season in short form text. (Eg.'Gen Def')position.codeA short code to represent the players primary position within a season. (Eg.'GD')position.idA unique numerical identifier to represent the players primary position within a season.matches.seasonThe person's number of matches played for the given squad in the given season.id.
Examplesβ
getSquadPersons(10,2022)
getSquadPersons('Carlton')
getSquads: Squad Listβ
Descriptionβ
Get a list of squads participating in a season.
Usageβ
getSquads(seasonId, leagueId = 1, levelId = 1, squadId, ...)
Argumentsβ
seasonId: A numerical identifier of a season. If missing, defaults to the current season of the League Level defined by 'leagueId' and 'levelId'.leagueId: A unique numerical identifier of a league. Defaults to AFL Men's Premiership.levelId: A unique numerical identifier of a level. Defaults to Seniors....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of squads, with one row per squad.
season.idA numerical identifier of a season.squad.nameThe name of the squad.squad.codeA short code to represent the squad.squad.idA unique numerical identifier of the squad.state.name(whensquadIdis provided) The name of the state that the given squad is based.state.code(whensquadIdis provided) A short code representing the state that the given squad is based.state.id(whensquadIdis provided) A unique numerical identifier representing the state that the given squad is based.
Examplesβ
getSquads(2022)
getSquads()
getSquadStats: Match Squad Statsβ
Descriptionβ
Get squad stats for a match. Only returns observed metrics.
Usageβ
getSquadStats(
matchId,
period = NULL,
zone = NULL,
context = NULL,
metric = NULL,
team = NULL,
lastXseconds = NULL,
from = NULL,
to = NULL,
...
)
Argumentsβ
matchId: A unique numerical identifier of a match.period: A numerical indicator of a period to filter results within a match. Accepts integer values.zone: A text indicator of a zone on the field to filter results within a match. Accepts string values:"D50","DM","AM","F50","CB".context: A text indicator of the context for squad statistics. Accepts "For" "Against" or "Diff".metric: A text string of specific metric code(s) to be returned. This will result in the endpoint only returning these specific metrics. Note this endpoint is case sensitive and only works with metric codes (ie.c("TACKLE", "GOAL")team: A (case-sensitive) text string of the team to return metrics for. Either"home"or"away". Not passing anything to this param will return both teams.lastXseconds: An integer that limits statistics to counting events that occurred in the last X number of seconds. (ie.lastXSeconds = 300will return the last 5 minutes)from: Limits statistics to counting events that occurred on or after this number of seconds (ie.from = 300will return statistics that occured on or after the 300th second into the match)to: Limits statistics to counting events that occurred on or before this number of seconds (ie.to = 300will return statistics that occured up to (and including) the 300th second into the match)...: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of metrics for a match for each squad.
match.idA unique numerical identifier of a match.squad.idA unique numerical identifier of the squad.squad.nameThe name of the squad.squad.codeA short code to represent the squad.codeThe metric code (ALL_CAPS format).nameThe metric name (singular).idThe unique numerical identifier for the given statistic code.pluralThe metric name (plural).valueThe numeric metric value with no formatting applied.displayThe formatted metric value as a text string.
Examplesβ
getSquadStats(216085122)
getSquadStats(216085122,period=1,zone='D50',from = 0, to = 300)
getSquadStatsPOST: Match Squad Stats (POST Endpoint)β
Descriptionβ
Get squad stats for a match via a payload to the POST endpoint.
Usageβ
getSquadStatsPOST(matchId, payload, info = FALSE, verbose = FALSE, ...)
Argumentsβ
matchId: A unique numerical identifier of a match.payload: A nested list containing the parcels of data to be returned by the API. See:createPayload()as a method of simplifying this step.metricCodes (list): A list of the metric codes of the desired metrics (ie.list("TACKLE","CHAIN_LAUNCH_CB_GB")) Default Behaviour: If no metric code(s) are specifically selected, will return ALL valid metrics.periods (list): A list of the desired match periods (ie.list(1,2,3,4)) Default Behaviour: If no period(s) are specifically selected, will return data for the MATCH.zones (list): A list of the desired zones (ie.list("AM","D50")) Default Behaviour: If no zones are specifically selected, will return data for ALL zones.team (character): A code for which squad to return data for (Squad-Only Parameter) (ie."home"or"away"Default Behaviour: If no team is selected, will return data for BOTH teamscontext (character): The context in which the data will be returned (Squadβonly parameter) (ie."For","Against","diff") Default Behaviour: If no context is specifically selected, will return data in the 'For' context.id (character): A userβsettable identifier for the given payload, e.g."Q1_F50_Tackles") Default Behaviour: If no id is specifically passed in to a given payload list, the given list(s) will have their index in the payload order returned as an integer starting from 0.lastXseconds (numeric): Limits statistics to counting events that occurred in the last X number of seconds (ie. lastXseconds = 300 will return data from the last 5 minutes) Default Behaviour: If no lastXseconds value is specifically supplied, NO filter on match period seconds will be applied.fromPeriodSeconds (numeric): Limits statistics to counting events from this point in the period/match (ie. fromPeriodSeconds = 300 will return data up to the first 5 minutes onwards) Default Behaviour: If no fromPeriodSeconds value is specifically supplied, NO filter on match period seconds will be applied.toPeriodSeconds (numeric): Limits statistics to counting events to this point in the period/match (ie. toPeriodSeconds = 300 will return data from the first 5 minutes onwards) Default Behaviour: If no toPeriodSeconds value is specifically supplied, NO filter on match period seconds will be applied.info: A logical (TRUE/FALSE) to include the payload information alongside the data for each payload. Defaults toFALSEverbose: A logical (TRUE/FALSE) indicating whether to enable verbose messaging to the console. When set toTRUE, the function will print additional information and progress messages to the console to provide a more detailed view of its execution. Defaults toFALSEfor a quieter output....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of metrics supplied by the payload for each player in a match.
match.idA unique numerical identifier of a match.squad.nameThe name of the squad.squad.codeA short code to represent the squad.squad.idA unique numerical identifier of the squad.stat.codeThe metric code (ALL_CAPS format).stat.nameThe metric name (singular).stat.pluralThe metric name (plural).valueThe numeric metric value with no formatting applied.displayThe formatted metric value as a text string.idA unique identifier string able to be supplied by the user for each list in the payload. Defaults to numerical index starting at 0.info.metric.codes(wheninfo = TRUE) The metric code(s) supplied to the specific list in the payload for that row of data.info.periods(wheninfo = TRUE) The period(s) supplied to the specific list in the payload for that row of data.info.zones(wheninfo = TRUE) The zone(s) supplied to the specific list in the payload for that row of data.info.team(wheninfo = TRUE) The team supplied to the specific list in the payload for that row of data.info.context(wheninfo = TRUE) The match context supplied to the specific list in the payload for that row of data.
Examplesβ
## Payload Example:
squadPOSTPayloadExample <- list(
squadMetricRequests = list(
list(
metricCodes = list("TACKLE"),
periods = list(1),
zones = list("F50"),
context = "For",
id = "Q1_F50_Tackles"
)
)
)
## Function Run:
getSquadStatsPOST(matchId = 120390401, payload = squadPOSTPayloadExample, info = T, verbose = T)
getSquadSummaryFile: AFL Squad Summary Fileβ
Descriptionβ
Get the AFL Squad Summary File formerly available via the support site.
Usageβ
getSquadSummaryFile(matchId, ...)
Argumentsβ
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame in the same format and structure as the AFL Squad Summary File formerly available via the support site.
MATCH_IDA unique numerical identifier of a match.SEASON_IDA numerical identifier of a season.GROUP_ROUND_NOThe round number of the match. Continues to count up during finals.VENUE_NAMEThe name of the match venue.SQUAD_NAMEThe name of the squad for the given row.OPP_SQUAD_NAMEThe name of the opposition squad for the given row.SQUAD_MARGINThe final margin of the match in relation to the team listed under SQUAD_NAME.MARGINThe margin at the end of the given period in relation to the team listed under SQUAD_NAME.ZONE_LOGICAL_AFLThe zone in which the values within metrics that follow are belonging to, relative to the squad listed under SQUAD_NAME.
Examplesβ
getSquadSummaryFile(matchId = 120390401)
getStatisticFlow: Statistic Flowβ
Descriptionβ
Get time coded transactions for given metric(s) occurring in a match
Usageβ
getStatisticFlow(
matchId,
metric,
period = NULL,
zone = NULL,
team = NULL,
limit = NULL,
orderBy = NULL,
...
)
Argumentsβ
matchId: A unique numerical identifier of a match.metric: A text string of specific metric code(s) to be returned. This will result in the endpoint only returning these specific metrics. Note this endpoint is case sensitive and only works with metric codes (ie.c("TACKLE", "GOAL")period: A numerical indicator of a period to filter results within a match. Accepts integer values.zone: A text indicator of a zone on the field to filter results within a match. Accepts string values:"D50","DM","AM","F50","CB".team: A (case-sensitive) text string of the team to return metrics for. Either"home"or"away". Not passing anything to this param will return both teams.limit: The number of transactions per page to return. The limit and default value is 5000 transactions per page.orderBy: Order transactions by ascending or descending based on transaction id. Default value is"asc"....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with a list of metrics for a match for each player.
trx.idA unique numerical identifier for a given transaction, used for ordering chronologically.periodThe period of the transaction.period.secsThe elapsed time within the period of a transaction.zone.logicalThe zone in which the transaction takes place, relative to the squad in possession.fullnameThe full name of the player.person.idA unique numerical identifier of the player.squad.codeA short code to represent the squad.squad.idA unique numerical identifier of the squad.metric.codeThe metric code (ALL_CAPS format).valueThe numeric metric value with no formatting applied.
Examplesβ
getStatisticFlow(216085122)
getStatisticFlow(216085122,metric="TACKLE",period=1,zone='D50')
getStoppages: Match Stoppagesβ
Descriptionβ
Get a dataframe of stoppages for a match.
Usageβ
getStoppages(matchId, stoppageAttendees = FALSE, ...)
Argumentsβ
matchId: A unique numerical identifier of a match.stoppageAttendees: A logical value indicating whether to include the attendees of the stoppage. Default isFALSE....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with all of the stoppages for a given match.
match.idA unique numerical identifier for a match.type.nameThe name of the stoppage type (ie. 'Centre Bounce').type.codeA short code representing the stoppage type.trx.idA unique numerical identifier for a transaction.periodThe period in which the transaction occurred.period.secondsThe elapsed time (in seconds) within the period of the transaction.stoppage.location.xThe x-coordinate of the stoppage on the field.stoppage.location.yThe y-coordinate of the stoppage on the field.stoppage.location.standard.xThe x-coordinate of the stoppage transformed to standard dimensions.stoppage.location.standard.yThe y-coordinate of the stoppage transformed to standard dimensions.hitout.idThe transaction id for the hit-out at the stoppage.hitout.nameThe name of the hit-out type.hitout.codeA short code representing the hit-out type.hitout.period.secondsThe elapsed time (in seconds) within the period of the hit-out.hitout.player.displaynameThe display name of the player credited with the hit-out.hitout.player.fullnameThe full name of the player credited with the hit-out.hitout.player.idA unique numerical identifier for the player credited with the hit-out.hitout.player.squad.idA unique numerical identifier for the squad of the player credited with the hit-out.first.possession.idThe transaction id for the first possession after the stoppage.first.possession.nameThe name of the first possession type.first.possession.codeA short code representing the first possession type.first.possession.period.secondsThe elapsed time (in seconds) within the period of the first possession.first.possession.zoneThe zone where the first possession occurred.first.possession.player.displaynameThe display name of the player gaining the first possession.first.possession.player.fullnameThe full name of the player gaining the first possession.first.possession.player.idA unique numerical identifier for the player gaining the first possession.first.possession.player.squad.idA unique numerical identifier for the squad of the player gaining the first possession.clearance.idA unique numerical identifier for the clearance.clearance.nameThe name of the clearance type.clearance.codeA short code representing the clearance type.clearance.period.secondsThe elapsed time (in seconds) within the period of the clearance.clearance.zoneThe zone where the clearance occurred.clearance.player.displaynameThe display name of the player performing the clearance.clearance.player.fullnameThe full name of the player performing the clearance.clearance.player.idA unique numerical identifier for the player performing the clearance.clearance.player.squad.idA unique numerical identifier for the squad of the player performing the clearance.exit.idA unique numerical identifier for the stoppage exit.exit.nameThe name of the stoppage exit type.exit.codeA short code representing the stoppage exit type.exit.period.secondsThe elapsed time (in seconds) within the period of the stoppage exit.exit.zoneThe zone where the stoppage exit occurred.exit.typeThe type of stoppage exit (e.g., kick, handball).exit.pressureThe level of defensive pressure applied during the stoppage exit.exit.player.displaynameThe display name of the player performing the stoppage exit.exit.player.fullnameThe full name of the player performing the stoppage exit.exit.player.idA unique numerical identifier for the player performing the stoppage exit.exit.player.squad.idA unique numerical identifier for the squad of the player performing the stoppage exit.exit.kicking.footThe foot used by the player for the stoppage exit kick.exit.kicking.intentThe intent of the player for the stoppage exit kick.exit.kicking.distanceThe distance of the stoppage exit kick.exit.kicking.directionThe direction of the stoppage exit kick.exit.location.xThe x-coordinate of the stoppage exit on the field.exit.location.yThe y-coordinate of the stoppage exit on the field.exit.location.x.stdThe x-coordinate of the stoppage exit transformed to standard dimensions.exit.location.y.stdThe y-coordinate of the stoppage exit transformed to standard dimensions.stoppage.attendance.nameThe name of the stoppage being attended (ie. 'Ball Up Ruck Contest')stoppage.attendance.codeA short code representing the type of stoppage being attended.stoppage.attendance.idThe transaction id that the stoppage attendance is associated to.stoppage.attendance.period.secondsThe elapsed time (in seconds) within the period of the particular stoppage attendance.score.squad.idThe squad.id of the squad responsible for the score.score.typeThe type of score from the clearance.score.pointsThe points awarded for the score.- The below fields will only be present when
stoppageAttendees = TRUE
- The below fields will only be present when
stoppage.attendance.home.fullname1whenstoppageAttendees = TRUE: The full name of the first player attending the stoppage for the home squad.stoppage.attendance.home.displayname1whenstoppageAttendees = TRUE: The display name of the first player attending the stoppage for the home squad.stoppage.attendance.home.personId1whenstoppageAttendees = TRUE: A unique numerical identifier for the first player attending the stoppage for the home squad.stoppage.attendance.home.fullname2whenstoppageAttendees = TRUE: The full name of the second player attending the stoppage for the home squad.stoppage.attendance.home.displayname2whenstoppageAttendees = TRUE: The display name of the second player attending the stoppage for the home squad.stoppage.attendance.home.personId2whenstoppageAttendees = TRUE: A unique numerical identifier for the second player attending the stoppage for the home squad.stoppage.attendance.home.fullname3whenstoppageAttendees = TRUE: The full name of the third player attending the stoppage for the home squad.stoppage.attendance.home.displayname3whenstoppageAttendees = TRUE: The display name of the third player attending the stoppage for the home squad.stoppage.attendance.home.personId3whenstoppageAttendees = TRUE: A unique numerical identifier for the third player attending the stoppage for the home squad.stoppage.attendance.home.fullname4whenstoppageAttendees = TRUE: The full name of the fourth player attending the stoppage for the home squad.stoppage.attendance.home.displayname4whenstoppageAttendees = TRUE: The display name of the fourth player attending the stoppage for the home squad.stoppage.attendance.home.personId4whenstoppageAttendees = TRUE: A unique numerical identifier for the fourth player attending the stoppage for the home squad.stoppage.attendance.away.fullname1whenstoppageAttendees = TRUE: The full name of the first player attending the stoppage for the away squad.stoppage.attendance.away.displayname1whenstoppageAttendees = TRUE: The display name of the first player attending the stoppage for the away squad.stoppage.attendance.away.personId1whenstoppageAttendees = TRUE: A unique numerical identifier for the first player attending the stoppage for the away squad.stoppage.attendance.away.fullname2whenstoppageAttendees = TRUE: The full name of the second player attending the stoppage for the away squad.stoppage.attendance.away.displayname2whenstoppageAttendees = TRUE: The display name of the second player attending the stoppage for the away squad.stoppage.attendance.away.personId2whenstoppageAttendees = TRUE: A unique numerical identifier for the second player attending the stoppage for the away squad.stoppage.attendance.away.fullname3whenstoppageAttendees = TRUE: The full name of the third player attending the stoppage for the away squad.stoppage.attendance.away.displayname3whenstoppageAttendees = TRUE: The display name of the third player attending the stoppage for the away squad.stoppage.attendance.away.personId3whenstoppageAttendees = TRUE: A unique numerical identifier for the third player attending the stoppage for the away squad.stoppage.attendance.away.fullname4whenstoppageAttendees = TRUE: The full name of the fourth player attending the stoppage for the away squad.stoppage.attendance.away.displayname4whenstoppageAttendees = TRUE: The display name of the fourth player attending the stoppage for the away squad.stoppage.attendance.away.personId4whenstoppageAttendees = TRUE: A unique numerical identifier for the fourth player attending the stoppage for the away squad.
Examplesβ
getStoppages(matchId = 120390401)
getStoppages(matchId = 120390401, stoppageAttendees = TRUE)
getVenue: Match Venueβ
Descriptionβ
Get details about the venue for a match.
Usageβ
getVenue(matchId, ...)
Argumentsβ
matchId: An unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Valueβ
A data frame with details about the match venue.
match.idA unique numerical identifier of a match.idA unique numerical identifier of the match venue.nameThe name of the match venue.codeA short code to represent the match venue.country.idA unique numerical identifier of the country of the venue.country.nameThe country of the venue.country.codeA short code representing the country of the venue.state.idA numerical identifier of a country's state.state.nameThe venue's state.state.codeA short code representing the venue's state.timezoneThe timezone of the venue.lengthThe length of the venue in metres.widthThe width of the venue in metres.home.nameName of the home squad in the given matchhome.codeA short code representing the home squad in the given matchhome.idA unique identifier for the home squad in the given matchhome.interstate.travelATRUE/FALSEflag signifying if the home squad travelled interstate for this match.away.nameName of the away squad in the given matchaway.codeA short code representing the away squad in the given matchaway.idA unique identifier for the away squad in the given matchaway.interstate.travelATRUE/FALSEflag signifying if the away squad travelled interstate for this match.
Examplesβ
getVenue(216085122)
to_minsec: Minute:Second displayβ
Descriptionβ
Convert an integer of seconds elapsed to a text string with minutes and seconds.
Usageβ
to_minsec(x, leadingZero = FALSE)
Argumentsβ
x: Seconds, as an integer.leadingZero: Logical. Add a leading zero to minute values less than 10?
Valueβ
A text string in the form "MI:SS" (Eg. "9:54" if leadingZero = FALSE "09:54" if leadingZero = TRUE)
Examplesβ
to_minsec(594)