NBA.Stats.PlayerVsPlayer (nba_api_ex v0.1.0)

View Source

Provides functions to interact with the NBA stats API for PlayerVsPlayer.

See get/2 for parameter and usage details.

Summary

Functions

get(params \\ [LastNGames: 0, MeasureType: "Base", Month: 0, OpponentTeamID: 0, PaceAdjust: "Y", PerMode: "PerGame", Period: 0, PlayerID: nil, PlusMinus: "Y", Rank: "Y", Season: nil, SeasonType: "Regular Season", VsPlayerID: nil, VsDivision: nil, VsConference: nil, SeasonSegment: nil, Outcome: nil, Location: nil, LeagueID: "00", GameSegment: nil, DateTo: nil, DateFrom: nil], opts \\ [])

(since 0.1.0)

Fetches PlayerVsPlayer data.

Parameters

  • params: A keyword list of parameters to filter the data.

    • LastNGames: (Required) Number of last games to include.

      • Type(s): Integer
      • Example: LastNGames: 5
      • Default: 0
    • MeasureType: (Required) The type of measure. Accepts one of "Base", "Advanced", "Misc", "Four Factors", "Scoring", "Opponent", "Usage", "Defense".

      • Type(s): String
      • Example: MeasureType: "Base"
      • Default: "Base"
      • Valueset: "Base", "Advanced", "Misc", "Four Factors", "Scoring", "Opponent", "Usage", "Defense"
      • Pattern: ^(Base)|(Advanced)|(Misc)|(Four Factors)|(Scoring)|(Opponent)|(Usage)|(Defense)$
    • Month: (Required) The month (1-12, 0 for all).

      • Type(s): Integer
      • Example: Month: 0
      • Default: 0
    • OpponentTeamID: (Required) The opponent team ID.

      • Type(s): Integer | String

      • Example: OpponentTeamID: 1610612737
      • Default: 0
    • PaceAdjust: (Required) Whether to adjust for pace. Accepts "Y" or "N".

      • Type(s): String
      • Example: PaceAdjust: "N"
      • Default: "N"
      • Valueset: "Y", "N"
      • Pattern: ^(Y)|(N)$
    • PerMode: (Required) The data aggregation mode. Accepts one of "Totals", "PerGame", "MinutesPer", "Per48", "Per40", "Per36", "PerMinute", "PerPossession", "PerPlay", "Per100Possessions", "Per100Plays".

      • Type(s): String
      • Example: PerMode: "PerGame"
      • Default: "PerGame"
      • Valueset: "Totals", "PerGame", "MinutesPer", "Per48", "Per40", "Per36", "PerMinute", "PerPossession", "PerPlay", "Per100Possessions", "Per100Plays"
      • Pattern: ^(Totals)|(PerGame)|(MinutesPer)|(Per48)|(Per40)|(Per36)|(PerMinute)|(PerPossession)|(PerPlay)|(Per100Possessions)|(Per100Plays)$
    • Period: (Required) The period (0 for all).

      • Type(s): Integer
      • Example: Period: 0
      • Default: 0
    • PlayerID: (Required) The player ID.

    • PlusMinus: (Required) Whether to include plus/minus. Accepts "Y" or "N".

      • Type(s): String
      • Example: PlusMinus: "N"
      • Default: "N"
      • Valueset: "Y", "N"
      • Pattern: ^(Y)|(N)$
    • Rank: (Required) Whether to include rank. Accepts "Y" or "N".

      • Type(s): String
      • Example: Rank: "N"
      • Default: "N"
      • Valueset: "Y", "N"
      • Pattern: ^(Y)|(N)$
    • Season: (Required) The season.

      • Type(s): String
      • Example: Season: "2024-25"
      • Default: nil
    • SeasonType: (Required) The season type. Accepts one of "Regular Season", "Pre Season", "Playoffs".

      • Type(s): String
      • Example: SeasonType: "Regular Season"
      • Default: "Regular Season"
      • Valueset: "Regular Season", "Pre Season", "Playoffs"
      • Pattern: ^(Regular Season)|(Pre Season)|(Playoffs)$
    • VsPlayerID: (Required) The opposing player ID.

    • VsDivision: The opposing division. Accepts nil or one of "Atlantic", "Central", "Northwest", "Pacific", "Southeast", "Southwest", "East", "West".

      • Type(s): String | nil

      • Example: VsDivision: "Pacific"
      • Default: nil
      • Pattern: ^((Atlantic)|(Central)|(Northwest)|(Pacific)|(Southeast)|(Southwest)|(East)|(West))?$
    • VsConference: The opposing conference. Accepts nil or "East", "West".

      • Type(s): String | nil

      • Example: VsConference: "West"
      • Default: nil
      • Pattern: ^((East)|(West))?$
    • SeasonSegment: The season segment. Accepts nil or "Post All-Star", "Pre All-Star".

      • Type(s): String | nil

      • Example: SeasonSegment: "Pre All-Star"
      • Default: nil
      • Pattern: ^((Post All-Star)|(Pre All-Star))?$
    • Outcome: The game outcome. Accepts nil or "W", "L".

      • Type(s): String | nil

      • Example: Outcome: "W"
      • Default: nil
      • Pattern: ^((W)|(L))?$
    • Location: The game location. Accepts nil or "Home", "Road".

      • Type(s): String | nil

      • Example: Location: "Home"
      • Default: nil
      • Pattern: ^((Home)|(Road))?$
    • LeagueID: The league ID. Defaults to "00" (NBA). Not required.

      • Type(s): String
      • Example: LeagueID: "00"
      • Default: "00"
    • GameSegment: The game segment. Accepts nil or "First Half", "Overtime", "Second Half".

      • Type(s): String | nil

      • Example: GameSegment: "First Half"
      • Default: nil
      • Pattern: ^((First Half)|(Overtime)|(Second Half))?$
    • DateTo: The end date (YYYY-MM-DD). Accepts nil or a date string.

      • Type(s): String | nil

      • Example: DateTo: "2025-03-01"
      • Default: nil
    • DateFrom: The start date (YYYY-MM-DD). Accepts nil or a date string.

      • Type(s): String | nil

      • Example: DateFrom: "2025-01-01"
      • Default: nil
  • opts: A keyword list of additional options for the request, such as headers or timeout settings.

Returns

  • {:ok, data}: On success, returns the data from the API.
  • {:error, reason}: On failure, returns an error tuple with the reason.

Example

iex> NBA.Stats.PlayerVsPlayer.get(Season: "2024-25", PlayerID: 201939, VsPlayerID: 2544)
{:ok, %{"PlayerVsPlayer" => [%{...}, ...]}}

get!(params \\ [], opts \\ [])

(since 0.1.0)