Download the PHP package corbpie/nbalive without Composer
On this page you can find all versions of the php package corbpie/nbalive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package nbalive
NBA API Wrapper
A PHP 8.3+ library for accessing NBA API endpoints — live games, box scores, play-by-play, standings, player stats, and more. Responses are normalized into readable arrays (and typed DTOs where available) so you get clean data without parsing raw API payloads yourself.
[]()
[]()
[]()
Table of contents / index
- Installing
- Requirements
- How it works
- Fetching data
- Error handling
- Debugging
- Custom HTTP client
- Response caching
- Typed DTOs
- Helpers
- Testing & development
- Today's games
- Game time seconds formatted
- Box score
- Play by play
- Play by play V3
- Play by play V2
- Play by play V1
- Play by play clips
- Rotations
- Game summary
- Tradition box score
- Scoring box score
- Defensive box score
- Hustle box score
- Game matchups
- Usage box score
- 4 factors box score
- Advanced box score
- Tracking box score
- Team lineups
- Team shots dash
- Standings
- League game log
- Team year over year
- Team roster
- Team info
- Team game logs
- Team franchise players
- Schedule
- Player on off
- Player year over year
- Player shooting
- Player
- Player awards
- Player career
- Playoff brackets
- Playoff picture
- Playoff series
- Team
- Teams years
- League leaders
- League player match ups
- League player shot locations
- League player shots
- Video events
- Player game logs
- Player compare
- Player next games
- Player vs player
- Player index
- Shot chart
- Draft history
- Draft combine
- Franchise history
- Franchise leaders
- All-time leaders
- Team historical leaders
- Team dashboard
- Win probability
- Player clutch stats
- Team clutch stats
- League hustle stats
- League game finder
- Player fantasy profile
- Team game streak finder
- Player estimated metrics
Installing
Install with Composer:
Requirements
- PHP 8.3+
ext-curlext-jsonpsr/simple-cache(installed automatically; bring your own cache implementation for response caching)
How it works
Every NBA endpoint is a class under the Corbpie\NBALive namespace. Each class:
- Extends
NBABaseand implementsFetchableEndpoint - Exposes a
fetch()method that calls the NBA API and populates public properties - Normalizes raw API responses into easy-to-use arrays (and typed DTOs where available)
Two API sources are used:
| Source | Used for | Example |
|---|---|---|
cdn.nba.com |
Live data (box scores, play-by-play, scoreboard) | NBABoxScore, NBAToday |
stats.nba.com |
Historical stats, standings, player data | NBAStandings, NBAPlayerCareer |
Fetching data
All endpoints use a consistent fetch() pattern. Constructors still auto-fetch for backward compatibility when you pass parameters, but the recommended approach is to configure properties and call fetch() explicitly.
Explicit fetch (recommended):
Constructor auto-fetch (still supported):
Lazy fetch with game ID endpoints:
Error handling
API failures throw NBAApiException. Transport errors (timeouts, cURL failures) and invalid JSON are also surfaced as exceptions.
Debugging
After any API call, debug metadata is available on the endpoint instance:
Custom HTTP client
Inject a custom HTTP client for testing, custom timeouts, or swapping the transport layer. All endpoint constructors accept an optional NbaHttpClientInterface as the last argument.
Available HTTP classes:
| Class | Purpose |
|---|---|
CurlNbaHttpClient |
Default cURL transport (10s connect / 30s total timeout) |
CachingNbaHttpClient |
PSR-16 caching decorator (see below) |
NbaHttpResponse |
Immutable response DTO returned by the client |
For unit tests, mock the client:
Response caching
Wrap any HTTP client with CachingNbaHttpClient to cache successful responses. Pass any PSR-16 CacheInterface implementation (Redis, filesystem, in-memory, etc.).
Suggested TTLs:
| Data type | Suggested TTL |
|---|---|
| Standings, rosters | 5–15 minutes |
| Live box scores, play-by-play | 5–15 seconds |
| Historical stats, career data | 1–24 hours |
Typed DTOs
Selected endpoints expose readonly DTO objects alongside the legacy array properties. DTOs provide typed access; toArray() returns the same shape as the array properties for backward compatibility.
| Endpoint | DTO property | Array property | DTO class |
|---|---|---|---|
NBATeamGameLogs |
$gameLogs |
$games |
TeamGameLog |
NBAStandings |
$standingEntries |
$standings |
TeamStanding |
NBALeagueGameFinder |
$gameEntries |
$games |
LeagueGameEntry |
Explicit fetch()
All endpoints now expose a fetch() method. Constructors still auto-fetch for backward compatibility when parameters are provided, but you can also configure properties and call fetch() manually:
Helpers
Season and utility constants on NBABase:
Testing & development
CI runs on GitHub Actions against PHP 8.3 and 8.4.
Todays games and live
Game time seconds formatted (Helper function)
Outputs
Boxscore
NBA API Live CDN box score version.
Team example:
Play by play
Play by play V3
Play by play V2
Play by play V1
Play by play clips
Traditional box score
Defensive box score
Box score matchups
Scoring box score
Misc box score
Usage box score
4 factors box score
Advanced box score
Tracking box score
Team lineups
Team Dash pts shots
Game rotations
Outputs
Team year over year
Standings
League game log
Team info
Team game logs
Team franchise players
Schedule
Output
Hustle box score
Team array output
Game summary
Output for $sum->away
Team roster
League leaders
Player year over year
Player on off
Output for $on_off->player_only
Player shooting
Player data
Details:
Player awards
Player career
Playoff brackets
Playoff picture
Playoff series
Team
Teams years
Outputs
League player match ups
League player shot locations
League player shots
Video events
Player game logs
Player compare
Player next games
Player vs player
Player index
Shot chart
Draft history
Draft combine
Franchise history
Franchise leaders
All-time leaders
Team historical leaders
Team dashboard
Win probability
Player clutch stats
Team clutch stats
League hustle stats
League game finder
Player fantasy profile
Team game streak finder
Player estimated metrics
All versions of nbalive with dependencies
ext-curl Version *