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 asenvir
orversion
.
Value​
A data frame in the same format and structure as the AFL Club Transaction Feed file formerly available via the support site.
MATCH_ID
A unique numerical identifier of a match.MATCH_DATE
The calendar date of a match in local time.MATCH_TIME
The local start time of a match.SEASON_ID
A numerical identifier of a season.GROUP_ROUND_NO
The round number of the match. Continues to count up during finals.VENUE_NAME
The name of the match venue.HOME_SQUAD
The name of the home squad.HOME_SCORE
The score of the home squad.AWAY_SQUAD
The name of the away squad.AWAY_SCORE
The score of the away squad.MATCH_TRX_ID
A unique numerical identifier for a given transaction, used for ordering chronologically.SEQUENCE
Unique identifier of events within a single transaction. Used for multi-player transactions.PERIOD
The period (quarter) of the match.PERIOD_SECS
The elapsed time in seconds for live periods, or the period length for completed periods.STATISTIC_CODE
The statistic code for a given transaction.PERSON_ID
A unique numerical identifier for the player assigned to the transaction (if applicable).FULLNAME
The fullname of the player assigned to the transaction (if applicable).SQUAD_NAME
The name of the squad assigned to the transaction.OPP_SQUAD
The opposing squad to the one assigned to the transaction.AR_ID
Away Ruck PERSON_ID (if applicable).AR
Away Ruck FULLNAME (if applicable).H1_ID
Home Midfielder 1 PERSON_ID (if applicable).H1
Home Midfielder 1 FULLNAME (if applicable).H2_ID
Home Midfielder 2 PERSON_ID (if applicable).H2
Home Midfielder 2 FULLNAME (if applicable).H3_ID
Home Midfielder 3 PERSON_ID (if applicable).H3
Home Midfielder 3 FULLNAME (if applicable).A1_ID
Away Midfielder 1 PERSON_ID (if applicable).A1
Away Midfielder 1 FULLNAME (if applicable).A2_ID
Away Midfielder 2 PERSON_ID (if applicable).A2
Away Midfielder 2 FULLNAME (if applicable).A3_ID
Away Midfielder 3 FULLNAME (if applicable).A3
Away Midfielder 3 FULLNAME (if applicable).ZONE_LOGICAL_AFL
The zone in which the transaction takes place, relative to the squad in possession.ZONE_PHYSICAL_AFL
The zone in which the transaction takes place, relative to the physical ground.TRUEX
The x coordinate of the transaction.TRUEY
The y coordinate of the transaction.VENUE_LENGTH
The length of the venue in metres.VENUE_WIDTH
The width of the venue in metres.STDX
The x coordinate of the transaction transformed to a standard ground dimension (160x141).STDY
The y coordinate of the transaction transformed to a standard ground dimension (160x141).XY_FLIP
INITIAL_TRX_ID
The transaction ID of the start of the chain.FINAL_TRX_ID
The transaction ID of the end of the chain.CHAIN_SQUAD
The name of the squad in possession during the chain.INITIAL_STATE
The starting state of the chain.FINAL_STATE
The final state of the chain.ZONE_LOGICAL_INITIAL
The zone in which the first transaction of the chain takes place, relative to the squad in possession.FINAL_ZONE_LOGICAL
The zone in which the final transaction of the chain takes place, relative to the squad in possession.LAUNCH_PERSON_ID
A unique numerical identifier of the player who launched the chain.LAUNCH_PLAYER
The full name of the player who launched the chain.GUILTY_PERSON_ID
Turnover player PERSON_ID (if applicable).GUILTY_PLAYER
Turnover player FULLNAME (if applicable).PARAM1
Additional captured parameters on transactions, showing the Shot Source, Free Kick Reason, Inside 50 Side or Kick In DirectionPARAM2
Additional captured parameters on transactions, showing the Shot Type, Free Kick Context or Inside 50 TypePARAM3
Additional captured parameters on transactions, showing the Shot AnglePARAM4
Additional captured parameters on transactions, showing the Shot DistanceKICK_FOOT
On kicking transactions, the foot of the kicking player.KICK_INTENT
On kicking transactions, the intent of the kicking player.KICK_DISTANCE
On kicking transactions, a description of the kicks distance.KICK_DIRECTION
On kicking transactions, a description of the kicks direction.PRESSURE_LEVEL
The name of the type of pressure applied (ie. Set Position).PRESSURE_PLAYER_ID
A unique numerical identifier for the first pressure player.PRESSURE_PLAYER
The fullname of the first pressure player.PRESSURE_PLAYER2_ID
A unique numerical identifier for the second pressure player.PRESSURE_PLAYER2
The fullname of the second pressure player.PRESSURE_POINTS
The 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 asenvir
orversion
.
Value​
A data frame with a list of all players for the match and their current bench status.
match.id
A unique numerical identifier of a match.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.squad.code
A short code to represent the squad.id
A unique numerical identifier of the player.name
The full name of the player.display
The display name of the player, represented as first initial and surname.status
The player's current status.elapsed
Seconds 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 asenvir
orversion
.
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.id
A unique numerical identifier of a match.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad in possession during the chain.squad.code
A short code to represent the squad in possession during the chain.period
The period of the possession chain.start.id
The transaction ID of the start of the chain.start.secs
The elapsed time within the period at the start of the chain.start.name
The starting state of the chain.start.code
A short code representing the starting state of the chain.start.type
The start type of the chain.start.type.code
A short code representing the starting type of the chain.start.zone
The starting zone of the chain, relative to the squad in possession.start.zone.physical
The starting zone of the chain, relative to the physical ground.start.x
The x-coordinate of the start of chain location.start.y
The y-coordinate of the start of chain location.launch.id
A unique numerical identifier of the player who launched the chain.launch.name
The full name of the player who launched the chain.launch.display
The display name of the player who launched the chain, represented as first initial and surname.end.id
The transaction ID of the end of the chain.end.secs
The elapsed time within the period at the end of the chain.end.name
The final state of the chain.end.code
A short code representing the final state of the chain.end.type
The end type of the chain.end.type.code
A short code representing the end type of the chain.end.zone
The final zone of the chain, relative to the squad in possession.end.zone.physical
The final zone of the chain, relative to the physical ground.end.x
The x-coordinate of the end of chain location.end.y
The y-coordinate of the end of chain location.score.id
The transaction ID of the scoring shot, if a score was generated during the chain.score.result
A single letter representing the result scoring of the scoring shot, if a score was generated during the chain.score.result.name
The full name of the result scoring shot, if a score was generated during the chain.score.points
The points generated by the scoring shot, if a score was generated during the chain.score.player.id
A unique numerical identifier of the player who scored within the chain.score.player.name
The full name of the player who scored within the chain.score.player.display
The display name of the player who scored within the chain, represented as first initial and surname.turnover.player.id
A unique numerical identifier of the player who turned the ball over at the end of the chain.turnover.player.name
The full name of the player who turned the ball overa at the end of the chain.turnover.player.display
The display name of the player who turned the ball overa at the end of the chain, represented as first initial and surname.turnover.type
The type of turnover that was commited. Kick, handball or non-disposal.turnover.state
The match state of the turnover that was commited. Clearing stoppage or General Play.turnover.creation
The creation method of the turnover that was commited. Forced/Unforced Giveaway or Opposition Takeaway.clearance.id
The transaction ID of the clearance that was won within the chain.inside50.id
The transaction ID of the first inside 50 that was generated by the squad in possession within the chain.rebound50.id
The transaction ID of the first rebound 50 that was generated by the squad in possession within the chain.stoppage.id
The first transaction ID of the chain in a stoppage chain.next.id
The transaction ID of the start of the next possession chain.prevoius.id
The transaction ID of the start of the previous possession chain.chain.metres.gained
Metres gained by a team within possession chains, combining measures towards attacking goal and away from defensive goal.chain.metres.gained.reply
Chain Metres conceded to the opposition in the next chain after a turnover.chain.metres.gained.net
Net 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 asenvir
orversion
.
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 asenvir
orversion
.
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.id
A unique numerical identifier of a match.entry.trx.id
The transaction ID of the entry, used for ordering chronologically.entry.period
The period of the entry.entry.period.secs
The elapsed time within the period of the entry.entry.player.id
A unique numerical identifier of the player responsible for the entry.entry.player.fullname
The fullname of the player responsible for the entry.entry.player.display.name
The display name of the player responsible for the entry.entry.squad.id
A numerical identifier of the squad player responsible for the entry belongs to.entry.squad.name
The name of the squad the player responsible for the entry belongs to.entry.squad.code
A short code to represent the squad the player responsible for the entry belongs to.entry.type
The type of inside 50 entry.entry.source.name
The game situation relative to the origin of a team's possession that results in an entry.entry.source.type
Inside 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.ground
For inside 50 entries that are kicks, was the entry from a ground kick (true/false).entry.kick.foot
For inside 50 entries that are kicks, which foot did the kicking player use.entry.kick.intent
For inside 50 entries that are kicks, the intent of the kicker.entry.kick.distance
For inside 50 entries that are kicks, the distance of the kick.entry.kick.direction
For inside 50 entries that are kicks, the direction of the kickentry.kick.launch.distance.to.goal
For inside 50 entries that are kicks, the straight line distance to goal from the launch point of the kick.entry.kick.result.distance.to.goal
For inside 50 entries that are kicks, the straight line distance to goal from the result point of the kick.entry.kick.pressure.name
For inside 50 entries that are kicks, the name of the type of pressure applied to the kicker.entry.kick.pressure.code
For inside 50 entries that are kicks, a short code to describe the type of pressure applied to the kicker.entry.kick.pressure.points
For inside 50 entries that are kicks, the number of points associated with the pressure type applied to the kicker.entry.kick.launch.location.x
The x coordinate of the inside 50 launch location.entry.kick.launch.location.y
The y coordinate of the inside 50 launch location.entry.kick.launch.location.x.std
The x coordinate of the inside 50 launch location transformed to a standard ground dimension (160x141).entry.kick.launch.location.y.std
The y coordinate of the inside 50 launch location transformed to a standard ground dimension (160x141).entry.kick.launch.location.rotated.x
The x coordinate of the inside 50 launch location rotated to give all squads attacking left-to-right.entry.kick.launch.location.rotated.y
The y coordinate of the inside 50 launch location rotated to give all squads attacking left-to-right.entry.kick.launch.location.rotated.x.std
The 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.std
The 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.x
The x coordinate of the inside 50 result location.entry.kick.result.location.y
The y coordinate of the inside 50 result location.entry.kick.result.location.x.std
The x coordinate of the inside 50 result location transformed to a standard ground dimension (160x141).entry.kick.result.location.y.std
The y coordinate of the inside 50 result location transformed to a standard ground dimension (160x141).entry.kick.result.location.rotated.x
The x coordinate of the inside 50 result location rotated to give all squads attacking left-to-right.entry.kick.result.location.rotated.y
The y coordinate of the inside 50 result location rotated to give all squads attacking left-to-right.entry.kick.result.location.rotated.x.std
The 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.std
The 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 asenvir
orversion
.
Value​
A data frame with the fixture for a given season, with one row per match.
competition.code
A short code describing the competition.season.id
A numerical identifier of a season.phase.code
A short code describing the phase of the season.type.id
A numerical indicator of the match type.type.name
A description of the match type.round.number
The round number of the match. Continues to count up during finals.round.phaseNumber
The round number of the match within the phase. Starts again from one for finals.round.code
A short code representing the name of the round.match.id
A unique numerical identifier of a match.match.order
The order of a match within a round, sorted by start date and time.match.start
The start time of a match in UTC time.match.date
The calendar date of a match in local time.match.time
The local start time of a match.home.id
A unique numerical identifier of the home squad.home.name
The name of the home squad.home.code
A short code to represent the home squad.away.id
A unique numerical identifier of the away squad.away.name
The name of the away squad.away.code
A short code to represent the away squad.venue.id
A unique numerical identifier of the match venue.venue.name
The name of the match venue.venue.code
A short code to represent the match venue.status.id
A numerical identifier of the match's current status.status.name
The match's current status.status.type.id
A numerical identifier of the match status type.status.type.name
The match's current status type.home.goals
The number of goals kicked by the home squad.home.behinds
The number of behinds kicked by the home squad.home.points
The number of points scored by the home squad.away.goals
The number of goals kicked by the away squad.away.behinds
The number of behinds kicked by the away squad.away.points
The 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 asenvir
orversion
.
Value​
A data frame with the requested ladder, with one row per squad.
season.id
A numerical identifier of a season.round.number
The round number of the match. Continues to count up during finals.position
The squads ladder position.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.squad.code
A short code to represent the squad.ladder.points
The number of ladder points accumulated by the squad.ladder.percentage
The squad's ladder percentage, calculated by points scored divided by points conceded.played
The number of matches played by the squad.win
The number of matches the squad has won.win.pct
The percentage of completed matches the squad has won.draw
The number of matches the squad has drawn.loss
The number of matches the squad has lost.total.for
The total number of points scored by the squad.total.against
The total number of points conceded by the squad.total.margin
The total points differential for the squad.average.for
The average number of points scored by the squad per match.average.against
The average number of points conceded by the squad per match.average.margin
The 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 asenvir
orversion
.
Value​
A data frame with a list of the five leading players for selected metrics.
match.id
A unique numerical identifier of a match.code
The metric code (ALL_CAPS format).name
The metric name (singular).plural
The metric name (plural).id
A unique numerical identifier of a metric.player.id
A unique numerical identifier of the player.player.name
The full name of the player.player.display
The display name of the player, represented as first initial and surname.player.jumper.number
The jumper number worn on the players's uniform.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.squad.code
A short code to represent the squad.value
The numeric metric value with no formatting applied.display
The formatted metric value as a text string.rank
Dense rank within metric, with ties presented as ties.method='min'.order
Order 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 asenvir
orversion
.
Value​
A data frame with details about a league and level.
league.id
A unique numerical identifier of the league.league.name
The name of the league.league.code
A short code representing the name of the league.league.gender
A 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 asenvir
orversion
.
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 asenvir
orversion
.
Value​
A data frame with details about a league and level.
league.id
A unique numerical identifier of the league.league.name
The name of the league.league.code
A short code representing the name of the league.league.gender
A short code representing The gender of a league. "M" for Men's, "W" for Women's.level.id
A unique numerical identifier of the level.level.name
The name of the level.level.code
A short code representing the name of the level.currentSeason.id
The 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 asenvir
orversion
.
Value​
A data frame with a league ID and level ID.
league.id
A unique numerical identifier of the league.level.id
A 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 asenvir
orversion
.
Value​
A data frame with details about a match.
competition.name
The full name of the competition.season.id
A numerical identifier of a season.type.id
A numerical indicator of the match type.type.name
A description of the match type.type.code
A short code describing the match type.round.number
The round number of the match. Continues to count up during finals.round.phaseNumber
The round number of the match within the phase. Starts again from one for finals.match.id
A unique numerical identifier of a match.match.name
The name of the match. Concatenates home and away squad names.match.code
A short code for the name of the match. Concatenates home and away squad codes.match.start
The start time of a match in UTC time.match.date
The calendar date of a match in local time.match.time
The local start time of a match.home.id
A unique numerical identifier of the home squad.home.name
The name of the home squad.home.code
A short code to represent the home squad.away.id
A unique numerical identifier of the away squad.away.name
The name of the away squad.away.code
A short code to represent the away squad.venue.id
A unique numerical identifier of the match venue.venue.name
The name of the match venue.venue.code
A short code to represent the match venue.venue.timezone
The timezone of the venue.match.status.period
The current period of the match (or last period of the match if match complete).match.status.period.secs
The elapsed seconds within the current period.match.status.period.display
A display format of the current period & period seconds (Eg."Q3 01:28"
).countdown.remaining.secs
The number of remaining seconds in the current period, counting down from 1200.countdown.remaining.time
The remaining time in the current period, formatted as minutes and seconds (Eg."04:24"
)countdown.remaining.display
A display format of current period & remaining time (Eg."Q3 04:24"
)match.status.code
A short code to represent the match's current status.match.status.name
The match's current status.match.status.id
A numerical identifier of the match's current status.match.status.type.id
A numerical identifier of the match status type.match.status.type.name
The match's current status type.home.goals
The number of goals kicked by the home squad.home.behinds
The number of behinds kicked by the home squad.home.points
The number of points scored by the home squad.away.goals
The number of goals kicked by the away squad.away.behinds
The number of behinds kicked by the away squad.away.points
The number of points scored by the away squad.winner.id
The squad ID of the winning team.result
A text description of the match result.result.code
A short text description of the match result.coin.toss.winning.squad.id
The squad id of the squad who won the coin toss.coin.toss.direction.decision
The direction the squad who won the coin toss decided to kick to.attendance
The crowd attendance for the given match.statistic.update
The 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 asenvir
orversion
.
Value​
A data frame with details about each match period. Only contains periods that have started.
match.id
A unique numerical identifier of a match.period
The period of the match.secs
The elapsed time in seconds for live periods, or the period length for completed periods.utcPeriodStart
The start time of the period in UTC time.utcPeriodEnd
The 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 asenvir
orversion
.
Value​
A data frame with a list of persons for a match, with one row per person.
match.id
A unique numerical identifier of the match.squad.id
A unique numerical identifier of the squad. (Players only)squad.name
The name of the squad. (Players only)squad.code
A short code to represent the squad. (Players only)person.id
A unique numerical identifier of a person.person.name
The person's full name.person.firstname
The person's first name.person.surname
The person's surname.person.display
The person's display name, represented as first initial and surname.jumper
The jumper number worn on the players's uniform.selected.id
A numerical identifier of the person's selected position.selected.name
The person's selected position.selected.code
A short code representing the peron's selected position.position.id
A numerical identifier of the person's primary position in that season. (Players only)position.name
The person's primary position in that season. (Players only)position.code
A short code representing the peron's primary position in that season. (Players only)height
The person's height in centimetres. (Players only)weight
The person's weight in kilograms. (Players only)DOB
The person's date of birth (YYYY-MM-DD). (Players only)age
The 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 asenvir
orversion
.
Value​
A data frame with a list of transactions for a match.
match.id
A unique numerical identifier for a match.trx.id
A unique numerical identifier for a given transaction, used for ordering chronologically.stat.code
The statistic code for a given transaction.stat.desc
A short description of the statistic code for a transaction.period
The period of the transaction.period.secs
The elapsed time within the period of a transaction.score.home
The score of the home squad.score.away
The score of the away squad.squad.name
The name of the squad.squad.code
A short code to represent the squad.squad.id
A unique numerical identifier for the squad.person.fullname
The fullname of the player assigned to the transaction (if applicable).person.displayName
The display name of the player assigned to the transaction (if applicable).person.id
A unique numerical identifier for the player assigned to the transaction (if applicable).pressure.squad.name
The name of the squad the pressure information is assigned to.pressure.squad.id
A unique numerical identifier for the squad the pressure information is assigned to.pressure.squad.code
A short code to represent the squad the pressure information is assigned to.pressure.name
The name of the type of pressure applied (ie. Set Position).pressure.code
A short code to represent the type of pressure applied.pressure.points
The points value of the type of pressure applied.pressure.fullname1
The fullname of the first pressure player.pressure.displayname1
The display name of the first pressure player.pressure.personid1
A unique numerical identifier for the first pressure player.pressure.role1
The role number of the first pressure player (1).pressure.fullname2
The fullname of the second pressure player.pressure.displayname2
The display name of the second pressure player.pressure.personid2
A unique numerical identifier for the second pressure player.pressure.role2
The role number of the second pressure player (2).zone.physical
The zone in which the transaction takes place, relative to the physical ground.zone.logical
The zone in which the transaction takes place, relative to the squad in possession.location.x
The x coordinate of the transaction.location.y
the y coordinate of the transaction.location.x.std
The x coordinate of the transaction transformed to a standard ground dimension (160x141).location.y.std
The y coordinate of the transaction transformed to a standard ground dimension (160x141).location.rotated.x
The x coordinate of the transaction rotated to give all squads attacking left-to-right.location.rotated.y
The y coordinate of the transaction rotated to give all squads attacking left-to-right.location.rotated.x.std
The x coordinate of the transaction transformed to a standard ground dimension (160x141) & rotated to give all squads attacking left-to-right.location.rotated.y.std
The y coordinate of the transaction transformed to a standard ground dimension (160x141) & rotated to give all squads attacking left-to-right.kicking.foot
On kicking transactions, the foot of the kicking player.kicking.intent
On kicking transactions, the intent of the kicking player.kicking.distance
On kicking transactions, a description of the kicks distance.kicking.direction
On kicking transactions, a description of the kicks direction.inside50.direction
On inside 50 transactions, a description of the kicks direction.inside50.intent
On inside 50 transactions, the intent of the kicking player.shot.angle
A text description of the angle of the shot.shot.distance
A text description of the distance of the shot.shot.result
The result of the shot on goal (Does not include Goals).shot.source
The source from which the shot on goal resulted (ie. General Play).shot.type
The type of shot attempted (ie. General Play Snap).freekick.context
On free kick transactions, the broad context from which the free kick was awarded.freekick.reason
On free kick transactions, the specific reason the free kick was awarded.kickin.direction
On 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 asenvir
orversion
.
Value​
A data frame with a list of metrics for a match.
match.id
A unique numerical identifier of a match.id
A unique numerical identifier of a metric.name
The metric name (singular).plural
The metric name (plural).code
The metric code (ALL_CAPS format).short
An abbreviated metric name (max 25 characters).level.id
A numerical identifier of the metric level.level.name
The metric level (Squad, Player, or Both).format.id
A numerical identifier of the metric format.format.id
A numerical identifier of the metric format.description
The 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 asenvir
orversion
.
Value​
A data frame with a list of quarters and scores for each quarter.
match.id
A unique numerical identifier of a match.id
The transaction ID of the interchange move, used for ordering chronologically.home.id
A unique numerical identifier of the home squad.home.name
The name of the home squad.home.code
A short code to represent the home squad.away.id
A unique numerical identifier of the away squad.away.name
The name of the away squad.away.code
A short code to represent the away squad.period
The period of the match.home.goals
Goals scored by the home squad.home.behinds
Behinds scored by the home squad.home.points
Points scored by the home squad.home.result
Period result for the home squad. W/L/D.home.margin
Scoreboard margin for the home squad.away.goals
Goals scored by the away squad.away.behinds
Behinds scored by the away squad.away.points
Points scored by the away squad.away.result
Period result for the away squad. W/L/D.away.margin
Scoreboard margin for the away squad.winning.squad.id
The ID of the winning squad.cumulative
TRUE/FALSE based on thecumulative
parameter 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 = 300
will return the last 5 minutes)from
: Limits statistics to counting events that occurred on or after this number of seconds (ie.from = 300
will 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 = 300
will return statistics that occured up to (and including) the 300th second into the match)...
: Arguments to be passed to internal functions, such asenvir
orversion
.
Value​
A data frame with a list of metrics for a match for each player.
match.id
A unique numerical identifier of a match.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.squad.code
A short code to represent the squad.player.id
A unique numerical identifier of the player.player.name
The full name of the player.player.display
The display name of the player, represented as first initial and surname.code
The metric code (ALL_CAPS format).name
The metric name (singular).id
The unique numerical identifier for the given statistic code.plural
The metric name (plural).value
The numeric metric value with no formatting applied.display
The 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 toFALSE
verbose
: 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 toFALSE
for a quieter output....
: Arguments to be passed to internal functions, such asenvir
orversion
.
Value​
A data frame with a list of metrics supplied by the payload for each player in a match.
match.id
A unique numerical identifier of a match.squad.name
The name of the squad.squad.code
A short code to represent the squad.squad.id
A unique numerical identifier of the squad.player.name
The full name of the player.player.display
The display name of the player, represented as first initial and surname.player.id
A unique numerical identifier of the player.stat.code
The metric code (ALL_CAPS format).stat.name
The metric name (singular).stat.plural
The metric name (plural).value
The numeric metric value with no formatting applied.display
The formatted metric value as a text string.id
A 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 asenvir
orversion
.
Value​
A data frame in the same format and structure as the AFL Club Transaction Feed file formerly available via the support site.
MATCH_ID
A unique numerical identifier of a match.SEASON_ID
A numerical identifier of a season.GROUP_ROUND_NO
The round number of the match. Continues to count up during finals.VENUE_NAME
The name of the match venue.PERSON_ID
A unique numerical identifier for the player assigned to the given row.FULLNAME
The fullname of the player assigned to the given row.SQUAD_NAME
The name of the squad for the given row.OPP_SQUAD_NAME
The name of the opposition squad for the given row.SQUAD_MARGIN
The final margin of the match in relation to the team listed under SQUAD_NAME.MARGIN
The margin at the end of the given period in relation to the team listed under SQUAD_NAME.ZONE_LOGICAL_AFL
The 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 asenvir
orversion
.
Value​
A data frame with a list of rotations for the match, with one row per interchange move.
match.id
A unique numerical identifier of a match.id
The transaction ID of the interchange move, used for ordering chronologically.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.squad.code
A short code to represent the squad.period
The period of the interchange move.secs
The elapsed time within the period of the interchange move.off.id
A unique numerical identifier of the player coming off the ground.off.name
The full name of the player coming off the ground.off.display
The display name of the player coming off the ground, represented as first initial and surname.off.reason
The reason for the interchange move.off.code
A short text description of the reason for the interchange move.on.id
A unique numerical identifier of the player coming on the ground. Empty for start-of-match initialisation of the interchange bench.on.name
The full name of the player coming on the ground. Empty for start-of-match initialisation of the interchange bench.on.display
The 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 asenvir
orversion
.
Value​
A data frame with details about the given season.
season.id
A numerical identifier of a season.competition.id
A unique numerical identifier of a competition, combining League, Level and Season.competition.code
A short code describing the competition.competition.name
The full name of the competition.startDate
The date of the first match of the season 'YYYY-MM-DD'.startYear
The year of the first match of the season.endDate
The date of the final scheduled game of the season 'YYYY-MM-DD'.endYear
The year of the final scheduled game of the season.complete
A count of the complete matches in the season.incomplete
A count of incomplete matches remaining in the season.nextRound
The round number of the next round to start.nextRoundStart
The datetime of the first match of the next round to start, in UTC time.lastRound
The round number of the last round to finish.lastRoundEnd
The datetime of the end of the last match of the last round to finish, in UTC time.firstMatchStart
The 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 asenvir
orversion
.
Value​
A data frame with a list of shots at goal for a match, with one row per shot.
match.id
A unique numerical identifier of a match.id
The transaction ID of the shot, used for ordering chronologically.period
The period of the shot.secs
The elapsed time within the period of the shot.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.squad.code
A short code to represent the squad.player.id
A unique numerical identifier of the player taking the shot.player.name
The full name of the player taking the shot.player.display
The display name of the player taking the shot, represented as first initial and surname.origin
How the player was able to generate a shot at goal.type
The type of shot attempted.angle
A text description of the angle of the shot.distance
A text description of the distance of the shot.x
Distance 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).y
Distance 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.std
The x coordinate of the shot transformed to a standard ground dimension (160x141).y.std
The y coordinate of the shot transformed to a standard ground dimension (160x141).accuracy.exp
The expected accuracy of the shot.result
The result of the shot. G / B / R / M.points.exp
The expected points of the shot.points
The 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 asenvir
orversion
.
Value​
A data frame with details about a squads.
season.id
A numerical identifier of a season.id
A unique numerical identifier of the squad.name
The name of the squad.code
A short code to represent the squad.state.id
A numerical identifier of a country's state.state.name
The squad's home state.state.code
A 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 asenvir
orversion
.
Value​
A data frame with a list of persons for all squads, with one row per person.
season.id
A numerical identifier of a season.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.id
A unique numerical identifier of a person.firstname
The person's first name.surname
The person's surname.name
The person's full name.display
The person's display name, represented as first initial and surname.position
The person's primary position within a season. The position where a player has spent most time.DOB
The person's date of birth (YYYY-MM-DD).age.season
The person's age in years at the start of the first game of the season, to one decimal place.age.year
The person's age at December 31 of the year in which the season ends, rounded down to a whole year.height
The person's height in centimetres.weight
The 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 asenvir
orversion
.
Value​
A data frame with a list of persons for a squad, with one row per person.
season.id
A numerical identifier of a season.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.id
A unique numerical identifier of a person.firstname
The person's first name.surname
The person's surname.name
The person's full name.display
The person's display name, represented as first initial and surname.position
The person's primary position within a season. The position where a player has spent most time.DOB
The person's date of birth (YYYY-MM-DD).age.season
The person's age in years at the start of the first game of the season, to one decimal place.age.year
The person's age at December 31 of the year in which the season ends, rounded down to a whole year.height
The person's height in centimetres.weight
The 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 asenvir
orversion
.
Value​
A data frame with a list of squads, with one row per squad.
season.id
A numerical identifier of a season.id
A unique numerical identifier of the squad.name
The name of the squad.code
A 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 = 300
will return the last 5 minutes)from
: Limits statistics to counting events that occurred on or after this number of seconds (ie.from = 300
will 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 = 300
will return statistics that occured up to (and including) the 300th second into the match)...
: Arguments to be passed to internal functions, such asenvir
orversion
.
Value​
A data frame with a list of metrics for a match for each squad.
match.id
A unique numerical identifier of a match.squad.id
A unique numerical identifier of the squad.squad.name
The name of the squad.squad.code
A short code to represent the squad.code
The metric code (ALL_CAPS format).name
The metric name (singular).id
The unique numerical identifier for the given statistic code.plural
The metric name (plural).value
The numeric metric value with no formatting applied.display
The 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 toFALSE
verbose
: 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 toFALSE
for a quieter output....
: Arguments to be passed to internal functions, such asenvir
orversion
.
Value​
A data frame with a list of metrics supplied by the payload for each player in a match.
match.id
A unique numerical identifier of a match.squad.name
The name of the squad.squad.code
A short code to represent the squad.squad.id
A unique numerical identifier of the squad.stat.code
The metric code (ALL_CAPS format).stat.name
The metric name (singular).stat.plural
The metric name (plural).value
The numeric metric value with no formatting applied.display
The formatted metric value as a text string.id
A 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 asenvir
orversion
.
Value​
A data frame in the same format and structure as the AFL Squad Summary File formerly available via the support site.
MATCH_ID
A unique numerical identifier of a match.SEASON_ID
A numerical identifier of a season.GROUP_ROUND_NO
The round number of the match. Continues to count up during finals.VENUE_NAME
The name of the match venue.SQUAD_NAME
The name of the squad for the given row.OPP_SQUAD_NAME
The name of the opposition squad for the given row.SQUAD_MARGIN
The final margin of the match in relation to the team listed under SQUAD_NAME.MARGIN
The margin at the end of the given period in relation to the team listed under SQUAD_NAME.ZONE_LOGICAL_AFL
The 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 asenvir
orversion
.
Value​
A data frame with all of the stoppages for a given match.
match.id
A unique numerical identifier for a match.type.name
The name of the stoppage type (ie. 'Centre Bounce').type.code
A short code representing the stoppage type.trx.id
A unique numerical identifier for a transaction.period
The period in which the transaction occurred.period.seconds
The elapsed time (in seconds) within the period of the transaction.stoppage.location.x
The x-coordinate of the stoppage on the field.stoppage.location.y
The y-coordinate of the stoppage on the field.stoppage.location.standard.x
The x-coordinate of the stoppage transformed to standard dimensions.stoppage.location.standard.y
The y-coordinate of the stoppage transformed to standard dimensions.hitout.id
The transaction id for the hit-out at the stoppage.hitout.name
The name of the hit-out type.hitout.code
A short code representing the hit-out type.hitout.period.seconds
The elapsed time (in seconds) within the period of the hit-out.hitout.player.displayname
The display name of the player credited with the hit-out.hitout.player.fullname
The full name of the player credited with the hit-out.hitout.player.id
A unique numerical identifier for the player credited with the hit-out.hitout.player.squad.id
A unique numerical identifier for the squad of the player credited with the hit-out.first.possession.id
The transaction id for the first possession after the stoppage.first.possession.name
The name of the first possession type.first.possession.code
A short code representing the first possession type.first.possession.period.seconds
The elapsed time (in seconds) within the period of the first possession.first.possession.zone
The zone where the first possession occurred.first.possession.player.displayname
The display name of the player gaining the first possession.first.possession.player.fullname
The full name of the player gaining the first possession.first.possession.player.id
A unique numerical identifier for the player gaining the first possession.first.possession.player.squad.id
A unique numerical identifier for the squad of the player gaining the first possession.clearance.id
A unique numerical identifier for the clearance.clearance.name
The name of the clearance type.clearance.code
A short code representing the clearance type.clearance.period.seconds
The elapsed time (in seconds) within the period of the clearance.clearance.zone
The zone where the clearance occurred.clearance.player.displayname
The display name of the player performing the clearance.clearance.player.fullname
The full name of the player performing the clearance.clearance.player.id
A unique numerical identifier for the player performing the clearance.clearance.player.squad.id
A unique numerical identifier for the squad of the player performing the clearance.exit.id
A unique numerical identifier for the stoppage exit.exit.name
The name of the stoppage exit type.exit.code
A short code representing the stoppage exit type.exit.period.seconds
The elapsed time (in seconds) within the period of the stoppage exit.exit.zone
The zone where the stoppage exit occurred.exit.type
The type of stoppage exit (e.g., kick, handball).exit.pressure
The level of defensive pressure applied during the stoppage exit.exit.player.displayname
The display name of the player performing the stoppage exit.exit.player.fullname
The full name of the player performing the stoppage exit.exit.player.id
A unique numerical identifier for the player performing the stoppage exit.exit.player.squad.id
A unique numerical identifier for the squad of the player performing the stoppage exit.exit.kicking.foot
The foot used by the player for the stoppage exit kick.exit.kicking.intent
The intent of the player for the stoppage exit kick.exit.kicking.distance
The distance of the stoppage exit kick.exit.kicking.direction
The direction of the stoppage exit kick.exit.location.x
The x-coordinate of the stoppage exit on the field.exit.location.y
The y-coordinate of the stoppage exit on the field.exit.location.x.std
The x-coordinate of the stoppage exit transformed to standard dimensions.exit.location.y.std
The y-coordinate of the stoppage exit transformed to standard dimensions.stoppage.attendance.name
The name of the stoppage being attended (ie. 'Ball Up Ruck Contest')stoppage.attendance.code
A short code representing the type of stoppage being attended.stoppage.attendance.id
The transaction id that the stoppage attendance is associated to.stoppage.attendance.period.seconds
The elapsed time (in seconds) within the period of the particular stoppage attendance.stoppage.attendance.home.fullname1
whenstoppageAttendees = TRUE
: The full name of the first player attending the stoppage for the home squad.stoppage.attendance.home.displayname1
whenstoppageAttendees = TRUE
: The display name of the first player attending the stoppage for the home squad.stoppage.attendance.home.personId1
whenstoppageAttendees = TRUE
: A unique numerical identifier for the first player attending the stoppage for the home squad.stoppage.attendance.home.fullname2
whenstoppageAttendees = TRUE
: The full name of the second player attending the stoppage for the home squad.stoppage.attendance.home.displayname2
whenstoppageAttendees = TRUE
: The display name of the second player attending the stoppage for the home squad.stoppage.attendance.home.personId2
whenstoppageAttendees = TRUE
: A unique numerical identifier for the second player attending the stoppage for the home squad.stoppage.attendance.home.fullname3
whenstoppageAttendees = TRUE
: The full name of the third player attending the stoppage for the home squad.stoppage.attendance.home.displayname3
whenstoppageAttendees = TRUE
: The display name of the third player attending the stoppage for the home squad.stoppage.attendance.home.personId3
whenstoppageAttendees = TRUE
: A unique numerical identifier for the third player attending the stoppage for the home squad.stoppage.attendance.home.fullname4
whenstoppageAttendees = TRUE
: The full name of the fourth player attending the stoppage for the home squad.stoppage.attendance.home.displayname4
whenstoppageAttendees = TRUE
: The display name of the fourth player attending the stoppage for the home squad.stoppage.attendance.home.personId4
whenstoppageAttendees = TRUE
: A unique numerical identifier for the fourth player attending the stoppage for the home squad.stoppage.attendance.away.fullname1
whenstoppageAttendees = TRUE
: The full name of the first player attending the stoppage for the away squad.stoppage.attendance.away.displayname1
whenstoppageAttendees = TRUE
: The display name of the first player attending the stoppage for the away squad.stoppage.attendance.away.personId1
whenstoppageAttendees = TRUE
: A unique numerical identifier for the first player attending the stoppage for the away squad.stoppage.attendance.away.fullname2
whenstoppageAttendees = TRUE
: The full name of the second player attending the stoppage for the away squad.stoppage.attendance.away.displayname2
whenstoppageAttendees = TRUE
: The display name of the second player attending the stoppage for the away squad.stoppage.attendance.away.personId2
whenstoppageAttendees = TRUE
: A unique numerical identifier for the second player attending the stoppage for the away squad.stoppage.attendance.away.fullname3
whenstoppageAttendees = TRUE
: The full name of the third player attending the stoppage for the away squad.stoppage.attendance.away.displayname3
whenstoppageAttendees = TRUE
: The display name of the third player attending the stoppage for the away squad.stoppage.attendance.away.personId3
whenstoppageAttendees = TRUE
: A unique numerical identifier for the third player attending the stoppage for the away squad.stoppage.attendance.away.fullname4
whenstoppageAttendees = TRUE
: The full name of the fourth player attending the stoppage for the away squad.stoppage.attendance.away.displayname4
whenstoppageAttendees = TRUE
: The display name of the fourth player attending the stoppage for the away squad.stoppage.attendance.away.personId4
whenstoppageAttendees = 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 asenvir
orversion
.
Value​
A data frame with details about the match venue.
match.id
A unique numerical identifier of a match.id
A unique numerical identifier of the match venue.name
The name of the match venue.code
A short code to represent the match venue.country.id
A unique numerical identifier of the country of the venue.country.name
The country of the venue.country.code
A short code representing the country of the venue.state.id
A numerical identifier of a country's state.state.name
The venue's state.state.code
A short code representing the venue's state.timezone
The timezone of the venue.length
The length of the venue in metres.width
The 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)