-
Notifications
You must be signed in to change notification settings - Fork 0
Home
-
Access the GraphiQL Interface:
- Open your web browser and go to https://nbaapi.com/graphql/.
- This interface allows you to write and execute GraphQL queries against the NBA database.
-
Basic Query Structure:
-
A GraphQL query consists of a
query
keyword followed by the specific data request enclosed in curly braces{}
. -
Example:
query { playerTotals(name: "LeBron James") { playerName position season team games id } }
-
-
Querying Player Totals:
-
To fetch player totals for a specific player:
query { playerTotals(name: "LeBron James") { playerName position season team games id } }
-
This query returns the player name, position, season, team, games played, and database ID for every entry matching "LeBron James".
-
-
Querying Players by Position and Ordering:
-
To fetch players by position and order them by a specific stat:
query { playerTotals(position: "C", ordering: "-total_rb") { playerName totalRb team season } }
-
This returns players in the Center position, ordered by total rebounds in descending order.
-
-
Advanced Player Stats:
-
To fetch advanced stats for players from a specific team and season:
query { playerAdvanced(team: "HOU", season: 2019, position: "PG", ordering: "-win_shares") { playerName position team season winShares } }
-
This returns Point Guards from the Houston Rockets in the 2019 season, ordered by win shares in descending order.
-
-
Querying Specific Player's Advanced Stats:
-
For detailed advanced stats for a specific player:
query { playerAdvanced(name: "Kobe Bryant") { playerName age assistPercent blockPercent defensiveWs offensiveWs winShares per vorp } }
-
This returns all available advanced stats for Kobe Bryant.
-
-
Using Filters and Ordering:
-
Filters: You can filter data by
name
,season
,team
,position
,playerID
, andid
. -
Ordering: Use the
ordering
parameter to sort results. Prefix the category with a-
for descending order. -
Example:
query { playerTotals(team: "LAL", ordering: "-points") { playerName points } }
-
-
Explore the Schema:
- Use the GraphiQL interface's built-in documentation explorer to understand the available types, queries, and fields.
- This helps in constructing more complex and precise queries.
By following these steps, you can effectively use the NBA GraphQL API to retrieve various player statistics and perform data analysis.