AFL API R Package Documentation
DESCRIPTION​
Package: cdAFLAPI
Type: Package
Version: 1.4.11
Depends: httr, 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 = ""
)
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",
verbose = F
)
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: Helper to create payloads for getPlayerStatsPOST() and getSquadStatsPOST() functions.​
Description​
Create a payload 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)
getBench: Match Bench​
Description​
Get the current bench status of all players in a match.
Usage​
getBench(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 all players for the match and their current bench status.
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.idA unique numerical identifier of the player.nameThe full name of the player.displayThe display name of the player, represented as first initial and surname.statusThe player's current status.elapsedSeconds elapsed within the current period since the player's last interchange move.
Examples​
getBench(216085122)
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, 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 the fixture for a given season, with one row per match.
competition.codeA short code describing the competition.season.idA numerical identifier of a season.phase.codeA short code describing the phase of the season.type.idA numerical indicator of the match type.type.nameA description of 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.round.codeA short code representing the name of the round.match.idA unique numerical identifier of a match.match.orderThe order of a match within a round, sorted by start date and time.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.status.idA numerical identifier of the match's current status.status.nameThe match's current status.status.type.idA numerical identifier of the match status type.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.
Examples​
getFixture(2022)
getFixture()
getLadder: Ladder​
Description​
Get the ladder for a given season.
Usage​
getLadder(seasonId, roundNumber, 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)
getLeague: League Details​
Description​
Get details about a league.
Usage​
getLeague(leagueId = 1, ...)
Arguments​
leagueId: A unique numerical identifier of a league. Defaults to AFL Men's Premiership....: Arguments to be passed to internal functions, such asenvirorversion.
Value​
A data frame with details about a league and level.
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.
Examples​
getLeague(1)
getLeague()
getLeagueId: League ID​
Description​
Get the ID of a known league.
Usage​
getLeagueId(leagueCode = "AFL", ...)
Arguments​
leagueCode: A short code for a league. Defaults to AFL Men's Premiership....: Arguments to be passed to internal functions, such asenvirorversion.
Value​
A numerical value for league ID.
Examples​
getLeagueId('AFL')
getLeagueId()
getLeagueLevel: League Level Details​
Description​
Get details about a league and level.
Usage​
getLeagueLevel(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 data frame with details about a league and level.
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.level.idA unique numerical identifier of the level.level.nameThe name of the level.level.codeA short code representing the name of the level.currentSeason.idThe current season ID.
Examples​
getLeagueLevel(1,1)
getLeagueLevel()
getLeagueLevelId: League Level ID​
Description​
Get the ID of a known level for a league.
Usage​
getLeagueLevelId(leagueCode = "AFL", levelCode = "SEN", ...)
Arguments​
leagueCode: A short code for a league. Defaults to AFL Men's Premiership.levelCode: A short code for a level. Defaults to Seniors....: Arguments to be passed to internal functions, such asenvirorversion.
Value​
A data frame with a league ID and level ID.
league.idA unique numerical identifier of the league.level.idA unique numerical identifier of the level.
Examples​
getLeagueLevelId('AFL','SEN')
getLeagueLevelId()
getMatch: Match Details​
Description​
Get details about a match.
Usage​
getMatch(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 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.statistic.updateThe last UTC time that a statistic was last updated for a match.
Examples​
getMatch(216085122)
getMatchPeriods: Match Periods​
Description​
Get details about the periods of a match.
Usage​
getMatchPeriods(matchId, ...)
Arguments​
matchId: A unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Value​
A data frame with details about each match period. Only contains periods that have started.
match.idA unique numerical identifier of a match.periodThe period of the match.secsThe elapsed time in seconds for live periods, or the period length for completed periods.utcPeriodStartThe start time of the period in UTC time.utcPeriodEndThe end time of the period in UTC time.
Examples​
getMatchPeriods(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 person.person.nameThe person's full name.person.firstnameThe person's first name.person.surnameThe person's surname.person.displayThe person's display name, represented as first initial and surname.jumperThe jumper number worn on the players's uniform.selected.idA numerical identifier of the person's selected position.selected.nameThe person's selected position.selected.codeA short code representing the peron's selected position.position.idA numerical identifier of the person's primary position in that season. (Players only)position.nameThe person's primary position in that season. (Players only)position.codeA short code representing the peron's primary position in that season. (Players only)heightThe person's height in centimetres. (Players only)weightThe person's weight in kilograms. (Players only)DOBThe person's date of birth (YYYY-MM-DD). (Players only)ageThe person'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.
Examples​
getMatchTransactions(216085122)
getMetrics: Match Metrics​
Description​
Get a list of valid metrics for a match.
Usage​
getMetrics(matchId, ...)
Arguments​
matchId: An unique numerical identifier of a match....: Arguments to be passed to internal functions, such asenvirorversion.
Value​
A data frame with a list of metrics for a match.
match.idA unique numerical identifier of a match.idA unique numerical identifier of a metric.nameThe metric name (singular).pluralThe metric name (plural).codeThe metric code (ALL_CAPS format).shortAn abbreviated metric name (max 25 characters).level.idA numerical identifier of the metric level.level.nameThe metric level (Squad, Player, or Both).format.idA numerical identifier of the metric format.format.idA numerical identifier of the metric format.descriptionThe text description of the metric definition.
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.idThe transaction ID of the interchange move, used for ordering chronologically.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.periodThe period of the match.home.goalsGoals scored by the home squad.home.behindsBehinds scored by the home squad.home.pointsPoints scored by the home squad.home.resultPeriod result for the home squad. W/L/D.home.marginScoreboard margin for the home squad.away.goalsGoals scored by the away squad.away.behindsBehinds scored by the away squad.away.pointsPoints scored by the away squad.away.resultPeriod result for the away squad. W/L/D.away.marginScoreboard margin for the away squad.winning.squad.idThe ID of the winning squad.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,
zone,
metric,
team,
lastXseconds,
from,
to,
...
)
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".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.
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.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.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​
getSquadStatsPOST(matchId = 120390401, payload = squadPayload, 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 list of rotations for a match.
Usage​
getRotations(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 rotations for the match, with one row per interchange move.
match.idA unique numerical identifier of a match.idThe transaction ID of the interchange move, used for ordering chronologically.squad.idA unique numerical identifier of the squad.squad.nameThe name of the squad.squad.codeA short code to represent the squad.periodThe period of the interchange move.secsThe elapsed time within the period of the interchange move.off.idA unique numerical identifier of the player coming off the ground.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.reasonThe reason for the interchange move.off.codeA short text description of the reason for the interchange move.on.idA unique numerical identifier of the player coming on the ground. Empty for start-of-match initialisation of the interchange bench.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.
Examples​
getRotations(216085122)
getSeason: Season Details​
Description​
Get details about a given season.
Usage​
getSeason(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 details about the given season.
season.idA numerical identifier of a season.competition.idA unique numerical identifier of a competition, combining League, Level and Season.competition.codeA short code describing the competition.competition.nameThe full name of the competition.startDateThe date of the first match of the season 'YYYY-MM-DD'.startYearThe year of the first match of the season.endDateThe date of the final scheduled game of the season 'YYYY-MM-DD'.endYearThe year of the final scheduled game of the season.completeA count of the complete matches in the season.incompleteA count of incomplete matches remaining in the season.nextRoundThe round number of the next round to start.nextRoundStartThe datetime of the first match of the next round to start, in UTC time.lastRoundThe round number of the last round to finish.lastRoundEndThe datetime of the end of the last match of the last round to finish, in UTC time.firstMatchStartThe datetime of the first match of the season.
Examples​
getSeason(2022)
getSeason()
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)
getSquad: Squad Details​
Description​
Get details about a squad in a season.
Usage​
getSquad(squadId, seasonId, leagueId = 1, levelId = 1, ...)
Arguments​
squadId: A unique numerical identifier of a squad.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 details about a squads.
season.idA numerical identifier of a season.idA unique numerical identifier of the squad.nameThe name of the squad.codeA short code to represent the squad.state.idA numerical identifier of a country's state.state.nameThe squad's home state.state.codeA short code representing the squad's home state.
Examples​
getSquad(10,2022)
getSquad(20)
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.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​
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, ...)
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.idA unique numerical identifier of the squad.nameThe name of the squad.codeA short code to represent the squad.
Examples​
getSquads(2022)
getSquads()
getSquadStats: Match Squad Stats​
Description​
Get squad stats for a match. Only returns observed metrics.
Usage​
getSquadStats(
matchId,
period,
zone,
context,
metric,
team,
lastXseconds,
from,
to,
...
)
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".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 = F, ...)
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.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​
getSquadStatsPOST(matchId = 120390401, payload = squadPayload, 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)
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.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)
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.
Examples​
getVenue(216085122)
to_minsec: to_minsec​
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 @param leadingZero is FALSE, "09:54" if @param leadingZero is TRUE.
Examples​
to_minsec(594)