# NBA Data Scraper (`crawlerbros/nba-data-scraper`) Actor

Scrape NBA statistics and data, teams, players, game schedules, and standings for the National Basketball Association via TheSportsDB. Free public API, no registration required.

- **URL**: https://apify.com/crawlerbros/nba-data-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## NBA Data Scraper

Scrape comprehensive NBA (National Basketball Association) data including teams, players, game schedules, and standings. Powered by TheSportsDB — a free, open sports data API requiring no registration or API key.

### What This Actor Does

NBA Data Scraper gives you structured NBA data in seconds:

- **All 30 NBA teams** with arena info, founding year, colors, logos, and team descriptions
- **Player rosters** for any team — position, height, weight, college, nationality
- **Game schedules** for any season — home/away teams, scores, dates, venues
- **League standings** (when available) — wins, losses, points
- **Player search** — find any player by name across the league

### Output Data

Each record contains fields depending on the mode:

#### Teams
| Field | Description |
|-------|-------------|
| `teamId` | TheSportsDB unique team identifier |
| `teamName` | Full team name (e.g. "Los Angeles Lakers") |
| `shortName` | Abbreviated team name (e.g. "LAL") |
| `conference` | NBA conference/division info |
| `arena` | Home arena name |
| `arenaCapacity` | Arena seating capacity |
| `arenaLocation` | Arena city and state |
| `foundedYear` | Year the team was established |
| `description` | Team history and overview |
| `badgeUrl` | Team badge/crest image URL |
| `logoUrl` | Team logo image URL |
| `website` | Official team website |
| `primaryColor` | Primary team color |

#### Players
| Field | Description |
|-------|-------------|
| `playerId` | Unique player identifier |
| `playerName` | Full player name |
| `team` | Current team |
| `position` | Playing position (PG, SG, SF, PF, C) |
| `nationality` | Player nationality |
| `height` | Player height |
| `weight` | Player weight |
| `birthDate` | Date of birth |
| `college` | College attended |
| `status` | Active/Retired status |
| `thumbUrl` | Player thumbnail image |

#### Events / Schedule
| Field | Description |
|-------|-------------|
| `eventId` | Unique game identifier |
| `homeTeam` | Home team name |
| `awayTeam` | Away team name |
| `homeScore` | Home team score |
| `awayScore` | Away team score |
| `date` | Game date (YYYY-MM-DD) |
| `time` | Game time |
| `venue` | Arena/venue name |
| `season` | Season identifier |
| `status` | Game status |

### Input Configuration

| Parameter | Type | Description |
|-----------|------|-------------|
| `mode` | select | Data type to fetch (teams/players/schedule/standings/teamDetails/searchPlayers) |
| `teamId` | string | TheSportsDB team ID (e.g. "134880") |
| `teamName` | string | Team name for lookup (e.g. "Los Angeles Lakers") |
| `season` | string | Season year (e.g. "2023-2024" or "2024-25") |
| `playerName` | string | Player name for search |
| `maxItems` | integer | Maximum records to return (1–1000, default 50) |

### Example Uses

#### Get all NBA teams
```json
{
  "mode": "teams",
  "maxItems": 30
}
````

#### Get Los Angeles Lakers roster

```json
{
  "mode": "players",
  "teamName": "Los Angeles Lakers",
  "maxItems": 20
}
```

#### Get 2023-2024 season schedule

```json
{
  "mode": "schedule",
  "season": "2023-2024",
  "maxItems": 200
}
```

#### Search for a player

```json
{
  "mode": "searchPlayers",
  "playerName": "LeBron James"
}
```

### Use Cases

- **Fantasy basketball research** — Get player stats, rosters, and team info
- **Sports analytics** — Build datasets for NBA statistics analysis
- **Game prediction models** — Historical game results and schedules
- **Team comparison** — Arena data, founding history, conference info
- **Sports media** — Automate NBA content with accurate team and player data
- **Betting analysis** — Historical scores and game outcomes

### FAQ

**Q: Is an API key required?**
A: No. This scraper uses TheSportsDB's free public API which requires no registration.

**Q: How current is the data?**
A: TheSportsDB is updated regularly by community contributors. Player rosters may lag by a few weeks during active roster moves.

**Q: How many teams are in the NBA?**
A: There are 30 NBA teams — 15 in the Eastern Conference and 15 in the Western Conference.

**Q: What season format should I use?**
A: Use "2023-2024" for the 2023-24 season. The TheSportsDB API accepts both "2023-2024" and "2024-25" formats.

**Q: Are standings available?**
A: Standings access depends on TheSportsDB API tier. If unavailable, the actor returns team records instead.

**Q: Can I get historical game data?**
A: Yes, use mode=schedule with any past season (e.g. "2020-2021", "2021-2022", "2022-2023", "2023-2024").

**Q: Can I filter games for a specific team?**
A: Yes, use mode=schedule with a teamId or teamName to filter results to a single team's games.

# Actor input Schema

## `mode` (type: `string`):

What data to fetch from the NBA dataset.

## `teamId` (type: `string`):

TheSportsDB team ID (e.g. 134880 for Atlanta Hawks). Used in modes: players, schedule (filter), teamDetails.

## `teamName` (type: `string`):

NBA team name for lookup (e.g. 'Los Angeles Lakers'). Alternative to teamId for modes: players, teamDetails.

## `season` (type: `string`):

Season identifier for schedule and standings (e.g. '2023-2024' or '2024-25'). Used in modes: schedule, standings.

## `playerName` (type: `string`):

Player name to search for (mode=searchPlayers). E.g. 'LeBron James'.

## `maxItems` (type: `integer`):

Maximum number of records to return. Applies across all modes.

## Actor input object example

```json
{
  "mode": "teams",
  "season": "2023-2024",
  "maxItems": 50
}
```

# Actor output Schema

## `nbaData` (type: `string`):

Dataset containing scraped NBA data including teams, players, schedules, and standings.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "teams",
    "season": "2023-2024",
    "maxItems": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/nba-data-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "teams",
    "season": "2023-2024",
    "maxItems": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/nba-data-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "teams",
  "season": "2023-2024",
  "maxItems": 50
}' |
apify call crawlerbros/nba-data-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=crawlerbros/nba-data-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "NBA Data Scraper",
        "description": "Scrape NBA statistics and data, teams, players, game schedules, and standings for the National Basketball Association via TheSportsDB. Free public API, no registration required.",
        "version": "1.0",
        "x-build-id": "Qeo5zNsSqeNhNxr0n"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/crawlerbros~nba-data-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-crawlerbros-nba-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/crawlerbros~nba-data-scraper/runs": {
            "post": {
                "operationId": "runs-sync-crawlerbros-nba-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/crawlerbros~nba-data-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-crawlerbros-nba-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "mode"
                ],
                "properties": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "teams",
                            "players",
                            "schedule",
                            "standings",
                            "teamDetails",
                            "searchPlayers"
                        ],
                        "type": "string",
                        "description": "What data to fetch from the NBA dataset.",
                        "default": "teams"
                    },
                    "teamId": {
                        "title": "Team ID",
                        "type": "string",
                        "description": "TheSportsDB team ID (e.g. 134880 for Atlanta Hawks). Used in modes: players, schedule (filter), teamDetails."
                    },
                    "teamName": {
                        "title": "Team Name",
                        "type": "string",
                        "description": "NBA team name for lookup (e.g. 'Los Angeles Lakers'). Alternative to teamId for modes: players, teamDetails."
                    },
                    "season": {
                        "title": "Season",
                        "type": "string",
                        "description": "Season identifier for schedule and standings (e.g. '2023-2024' or '2024-25'). Used in modes: schedule, standings.",
                        "default": "2023-2024"
                    },
                    "playerName": {
                        "title": "Player Name",
                        "type": "string",
                        "description": "Player name to search for (mode=searchPlayers). E.g. 'LeBron James'."
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Maximum number of records to return. Applies across all modes.",
                        "default": 50
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
