PHP Classes

NBA PHP API Balldontlie Service: Get NBA games and players with Balldontlie API

Recommend this page to a friend!
  Info   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-08-16 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 10 This week: 1All time: 11,102 This week: 108Up
Version License PHP version Categories
balldontlie-service 1.0The PHP License5PHP 5, Games, Web services
Description 

Author

slvler


Contributor
This package is specific mainly for applications used in United States United States .

This package can get NBA games and players with Balldontlie API.

It can send HTTP requests to the Balldontlie API Web server to request information about several details about the NBA (National Basketball Association of United States).

Currently, it can:

- Get details of a given player

- Get details about a given team

- Get details about a game

- Get several statistics from the NBA

Picture of Hicri
  Performance   Level  
Name: Hicri <contact>
Classes: 18 packages by
Country: Turkey Turkey
Innovation award
Innovation award
Nominee: 2x

Details

slvler - balldontlie Service

tests Latest Stable Version Latest Unstable Version License

This package provides a convenient wrapper to the Balldontlie API for Laravel applications.

Requirements

  • PHP 8.0+
  • Laravel 9.x

Installation

To install this package tou can use composer:

    composer require slvler/balldontlie-laravel

Usage

Find player

Balldontlie::players(237);

it returns an json with player:

{
  "data":[
    {
      "id":237,
      "first_name":"LeBron",
      "last_name":"James",
      "position":"F",
      "height_feet": 6,
      "height_inches": 8,
      "weight_pounds": 250,
      "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
  }
}   

Find team

Balldontlie::teams(14);

it returns an json with team:

{
  "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
  }
}

Find games

Balldontlie::games(1);

it returns an json with games:

{
  "data": [
    {
      "id":1,
      "date":"2018-10-16T00:00:00.000Z",
      "home_team_score":105,
      "visitor_team_score":87,
      "season":2018,
      "period": 4,
      "status": "Final",
      "time": " ",
      "postseason": false,
      "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
  }
}

Find stats

Balldontlie::stats();

it returns an json with stats:

{
  "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
  }
}

Testing

    composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

Contributing

You're very welcome to contribute. Please see CONTRIBUTING for details.

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imageconfig (1 file)
Files folder imagesrc (4 files, 1 directory)
Files folder imagetests (2 directories)
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file tests.yml Data Auxiliary data

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file balldontlie.php Aux. Auxiliary script

  Files folder image Files  /  src  
File Role Description
Files folder imageFacades (1 file)
  Plain text file Balldontlie.php Class Class source
  Plain text file BalldontlieApiWrapper.php Class Class source
  Plain text file BalldontlieServiceProvider.php Class Class source
  Plain text file HttpResponse.php Class Class source

  Files folder image Files  /  src  /  Facades  
File Role Description
  Plain text file Balldontlie.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageFeature (1 file)
Files folder imageUnit (1 file)

  Files folder image Files  /  tests  /  Feature  
File Role Description
  Plain text file BalldontlieTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  
File Role Description
  Plain text file TestCase.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:10
This week:1
All time:11,102
This week:108Up