Free NBA

免费
通过 API Guy | 已更新 9 months ago | Sports
人气

9.8 / 10

延迟

859ms

服务等级

100%

关注者:136
资源:
产品网站
API 创建者:
avatar
API Guy
theapiguy
给 API 打分:
登录并给 API 打分

README

Use our free API to access NBA related data.

Players

Get All Players

This endpoint retrieves all players from all seasons.

HTTP Request

GET /api/v1/players

Query Parameters

  • page - The Page number, used for pagination
  • per_page - The number of results returned per call, used for pagination
  • search - Used to filter players based on their name. For example, ?search=davis will return players that have ‘davis’ in their first or last name.

Example Response

{
  "data":[
    {
      "id":237,
      "first_name":"LeBron",
      "last_name":"James",
      "position":"F",
      "team":{
        "id":14,
        "abbreviation":"LAL",
        "city":"Los Angeles",
        "conference":"West",
        "division":"Pacific",
        "full_name":"Los Angeles Lakers",
        "name":"Lakers"
      }
    }
    ...
 ],
 "meta": {
    "total_pages": 50,
    "current_page": 1,
    "next_page": 2,
    "per_page": 25,
    "total_count": 9999
  }
}

Get a Specific Player

This endpoint retrieves a specific player.

HTTP Request

GET /players/<ID>

URL Parameters

  • ID - The ID of the player to retrieve

curl /players/237
The above command returns JSON structured like this:

{
  {
    "id":237,
    "first_name":"LeBron",
    "last_name":"James",
    "position":"F",
    "team":{
      "id":14,
      "abbreviation":"LAL",
      "city":"Los Angeles",
      "conference":"West",
      "division":"Pacific",
      "full_name":"Los Angeles Lakers",
      "name":"Lakers"
    }
  }
}

Teams

Get All Teams

'curl “/teams”'
The above command returns JSON structured like this:

{
  "data": [
    {
      "id":14,
      "abbreviation":"LAL",
      "city":"Los Angeles",
      "conference":"West",
      "division":"Pacific",
      "full_name":"Los Angeles Lakers",
      "name":"Lakers"
    },
    ...
  ],
  "meta": {
    "total_pages": 1,
    "current_page": 1,
    "next_page": null,
    "per_page": 30,
    "total_count": 30
  }
}

This endpoint retrieves all teams for the current season.

HTTP Request

GET teams

Query Parameters

  • page - The page number, used for pagination.
  • per_page - The number of results returned per call, used for pagination.

Get a Specific Team

curl "/teams/14"
The above command returns JSON structured like this:

{
  "id":14,
  "abbreviation":"LAL",
  "city":"Los Angeles",
  "conference":"West",
  "division":"Pacific",
  "full_name":"Los Angeles Lakers",
  "name":"Lakers"
}

This endpoint retrieves a specific team.

HTTP Request

GET /teams/<ID>

URL Parameters

  • ID - The ID of the team to retrieve

Games

Get All Games

curl "/games"
The above command returns JSON structured like this:

{
  "data": [
    {
      "id":1,
      "date":"2018-10-16T00:00:00.000Z",
      "home_team_score":105,
      "visitor_team_score":87,
      "season":2018,
      "home_team":{
        "id":2,
        "abbreviation":"BOS",
        "city":"Boston",
        "conference":"East",
        "division":"Atlantic",
        "full_name":"Boston Celtics",
        "name":"Celtics"
      },
      "visitor_team":{
        "id":23,
        "abbreviation":"PHI",
        "city":"Philadelphia",
        "conference":"East",
        "division":"Atlantic",
        "full_name":"Philadelphia 76ers",
        "name":"76ers"
      },
    },
    ...
  ],
  "meta": {
    "total_pages": 1877,
    "current_page": 1,
    "next_page": 2,
    "per_page": 25,
    "total_count": 46911
  }
}

This endpoint retrieves all games.

Seasons are represented by the year they began. For example, 2018 represents season 2018-2019.

HTTP Request

GET /games

Query Parameters

You can combine query parameters. For example: ?seasons[]=2018&team_ids[]=1 will returns games for team_id 1 for the 2018-2019 season.

  • page - The page number, used for pagination.
  • per_page - The number of results returned per call, used for pagination.
  • dates - An array of dates formatted in ‘YYYY-MM-DD’
  • seasons - An array of seasons
  • team_ids - An array of team_ids

Get a Specific Game

curl "/games/1"
The above command returns JSON structured like this:

{
  {
    "id":1,
    "date":"2018-10-16T00:00:00.000Z",
    "home_team_score":105,
    "visitor_team_score":87,
    "season":2018,
    "home_team":{
      "id":2,
      "abbreviation":"BOS",
      "city":"Boston",
      "conference":"East",
      "division":"Atlantic",
      "full_name":"Boston Celtics",
      "name":"Celtics"
    },
    "visitor_team":{
      "id":23,
      "abbreviation":"PHI",
      "city":"Philadelphia",
      "conference":"East",
      "division":"Atlantic",
      "full_name":"Philadelphia 76ers",
      "name":"76ers"
    },
  }
}

This endpoint retrieves a specific game.

HTTP Request

GET /games/<ID>

URL Parameters

  • ID - The ID of the game to retrieve

Stats

Get All Stats

curl "/stats"
The above command returns JSON structured like this:

{
  "data": [
    {
      "id":29,
      "ast":2,
      "blk":2,
      "dreb":8,
      "fg3_pct":0.25,
      "fg3a":4,
      "fg3m":1,
      "fg_pct":0.429,
      "fga":21,
      "fgm":9,
      "ft_pct":0.8,
      "fta":5,
      "ftm":4,
      "game":{
        "id":1,
        "date":"2018-10-16T00:00:00.000Z",
        "home_team_id":2,
        "home_team_score":105,
        "season":2018,
        "visitor_team_id":23,
        "visitor_team_score":87
      },
      "min":"36:49",
      "oreb":2,
      "pf":3,
      "player":{
        "id":145,
        "first_name":"Joel",
        "last_name":"Embiid",
        "position":"F-C",
        "team_id":23
      },
      "pts":23,
      "reb":10,
      "stl":1,
      "team":{
        "id":23,
        "abbreviation":"PHI",
        "city":"Philadelphia",
        "conference":"East",
        "division":"Atlantic",
        "full_name":"Philadelphia 76ers",
        "name":"76ers"
      },
      "turnover":5
    },
    ...
  ],
  "meta": {
    "total_pages": 2042,
    "current_page": 1,
    "next_page": 2,
    "per_page": 25,
    "total_count": 51045
  }
}

This endpoint retrieves all stats.

HTTP Request

GET /stats

Query Parameters

You can combine query parameters. For example: ?seasons[]=2018&seasons[]=2015&player_ids[]=1&player_ids[]=2 will returns stats for player_ids 1 and 2 for the 2015-2016 and 2018-2019 season.

  • page - The page number, used for pagination.
  • per_page - The number of results returned per call, used for pagination.
  • dates - An array of dates formatted in ‘YYYY-MM-DD’
  • seasons - An array of seasons
  • player_ids - An array of player_ids
  • game_ids - An array of game_ids

Errors

  • 400 Bad Request – Your request is invalid.
  • 404 Not Found – The specified resource could not be found.
  • 406 Not Acceptable – You requested a format that isn’t json.
  • 429 Too Many Requests – Stop bombarding us.
  • 500 Internal Server Error – We had a problem with our server. Try again later.
  • 503 Service Unavailable – We’re temporarily offline for maintenance. Please try again later.
打分:5 - 投票:1