# NBA Team Rankings & Trends API (`data_hub/nba-team-rankings-trends-api`) Actor

NBA team stats API with 147 metrics covering scoring, efficiency, quarter-by-quarter performance, home/away splits, recent form, and historical trends. Built for sports analytics, betting research, fantasy apps, dashboards, AI agents, and data pipelines.

- **URL**: https://apify.com/data_hub/nba-team-rankings-trends-api.md
- **Developed by:** [Data Hub](https://apify.com/data_hub) (community)
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 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.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## 🏀 NBA Team Rankings & Historical Statistics API

Collect structured NBA team statistics from [TeamRankings](https://www.teamrankings.com/nba/) without maintaining your own scraper.

[NBA Team Rankings & Trends API](https://apify.com/data_hub/nba-team-rankings-trends-api) is an Apify Actor from Data Hub. It reads TeamRankings NBA stat pages for the dates you choose and returns one dataset row per team, statistic, and date. A single day can cover one metric, such as points per game, or the built-in list of **147** stat tables.

Use it as an NBA statistics API for dashboards, research, fantasy tools, and data pipelines. A normal run writes an Apify dataset. Standby mode also exposes HTTP endpoints, so an application can request the same rows without starting a separate scraper.

This Actor is not affiliated with the NBA or with TeamRankings. It does not predict game results.

### What you can do with it

TeamRankings already publishes the tables. This Actor turns those pages into rows you can export, schedule, or call from code.

- Pick a start date and an end date. Both days are included.
- Choose one or more stat tables, or choose `all` for the 147 default tables.
- Download several pages at once. `threadCount` accepts 1 to 20 workers.
- Store every team row in the run dataset, then export it from Apify.
- Call `GET /stats` or `POST /stats` while the Actor is in Standby mode.

Each row includes the season value, the last 3 games, the last game, home, away, and the previous season, using whatever columns that TeamRankings table shows.

### Key features

- **147 NBA stat tables.** Scoring, shooting, rebounding, defense, opponent stats, quarters, halves, and win percentage are in the default list.
- **Historical dates.** Any `YYYY-MM-DD` range the source can serve. The Actor does not invent dates the site does not publish.
- **Choose your tables.** Pass slugs such as `points-per-game` or `offensive-efficiency`.
- **Parallel downloads.** Worker threads fetch different stat pages at the same time.
- **One row per team, stat, and date.** The dataset stays flat and easy to filter.
- **Recent form on every row.** `last_3` and `last_1` come from the page's recent-game columns.
- **Home and away on every row.** Those splits are columns, not separate tables.
- **Quarter, half, and overtime tables.** Included where the default slug list has them.
- **Apify dataset and API.** Normal runs push rows to the default dataset.
- **Standby HTTP API.** `GET /`, `GET /stats`, and `POST /stats` are implemented.

### Who this Actor is for

- **Sports data analysts** who need repeatable NBA team performance snapshots instead of copying tables by hand.
- **Basketball researchers** comparing a date's season line with the previous season, home, away, and recent games.
- **Fantasy basketball developers** who want season and recent scoring, shooting, rebounding, and opponent stats as JSON.
- **Sports analytics teams** building internal NBA datasets from a stable input and output shape.
- **Data engineers** loading exported rows into a warehouse or a pipeline.
- **Dashboard developers** charting one stat over a date range, or many stats for one day.
- **AI application developers** passing structured team rows into their own tools. This Actor does not expose an MCP server.

The rows are source statistics. They are not win probabilities or betting picks.

### Available NBA statistics

`statTables` is required. Select one or more slugs from the dropdown, or select `all` for the 147 slugs in the default list. Each slug is one TeamRankings page: `https://www.teamrankings.com/nba/stat/{slug}?date=YYYY-MM-DD`.

A value that is not in that list is rejected before any download. If the page has no team rows, a normal run fails and a Standby request returns HTTP 422.

Home, away, last 3 games, last game, season, and previous season are **columns on each row**. They are not extra slugs.

#### Scoring

`points-per-game`, `average-scoring-margin`, `points-in-paint-per-game`, `fastbreak-points-per-game`, `fastbreak-efficiency`, `average-biggest-lead`, `points-from-2-pointers`, `points-from-3-pointers`, `percent-of-points-from-2-pointers`, `percent-of-points-from-3-pointers`, `percent-of-points-from-free-throws`

#### Shooting and efficiency

`offensive-efficiency`, `defensive-efficiency`, `floor-percentage`, `shooting-pct`, `effective-field-goal-pct`, `true-shooting-percentage`, `three-point-pct`, `two-point-pct`, `free-throw-pct`, `three-point-rate`, `two-point-rate`, `free-throw-rate`, `field-goals-made-per-game`, `field-goals-attempted-per-game`, `three-pointers-made-per-game`, `three-pointers-attempted-per-game`, `free-throws-made-per-game`, `free-throws-attempted-per-game`, `fta-per-fga`, `ftm-per-100-possessions`, `non-blocked-2-pt-pct`

#### Quarters, halves, and overtime

`1st-quarter-points-per-game`, `2nd-quarter-points-per-game`, `3rd-quarter-points-per-game`, `4th-quarter-points-per-game`, `1st-half-points-per-game`, `2nd-half-points-per-game`, `overtime-points-per-game`, plus the matching `average-*-margin` slugs and `average-margin-thru-3-quarters`.

#### Rebounds, defense, playmaking, and fouls

`offensive-rebounds-per-game`, `defensive-rebounds-per-game`, `total-rebounds-per-game`, `offensive-rebounding-pct`, `defensive-rebounding-pct`, `blocks-per-game`, `steals-per-game`, `block-pct`, `steal-pct`, `assists-per-game`, `turnovers-per-game`, `assist--per--turnover-ratio`, `turnover-pct`, `personal-fouls-per-game`, `technical-fouls-per-game`

#### Pace and results

`games-played`, `possessions-per-game`, `extra-chances-per-game`, `effective-possession-ratio`, `win-pct-all-games`, `win-pct-close-games`

#### Combined box-score lines

`points-plus-rebounds-plus-assists-per-game`, `points-plus-rebounds-per-game`, `points-plus-assists-per-game`, `rebounds-plus-assists-per-game`, `steals-plus-blocks-per-game`

#### Opponent versions

67 default slugs start with `opponent-`, including opponent scoring, shooting, rebounding, fouls, quarters, halves, and win percentage. Copy the slug exactly. Two of them do not follow the usual hyphen pattern:

- `opponent-steals-perpossession`
- `opponent-points-plus-rebounds-plus-assists-per-gam`

`assist--per--turnover-ratio` and `opponent-assist--per--turnover-ratio` use double hyphens.

### Quick start

1. Open [NBA Team Rankings & Trends API](https://apify.com/data_hub/nba-team-rankings-trends-api) in Apify Console.
2. Set **Start date** and **End date** to the same day for a small test, for example `2026-10-13`.
3. Under **Stat tables**, select `offensive-efficiency`. Select `all` only when you want all 147 tables.
4. Set **Worker threads** to `8`, or any whole number from 1 to 20.
5. Start the Actor and wait until the run succeeds.
6. Open the run's **Output** or dataset tab. One successful page for that date returned 30 team rows.
7. Export the dataset from Apify Console. The download menu includes JSON and CSV, plus the other formats Apify currently offers, such as Excel and XML.

A normal run reads the input once, writes the dataset, and exits. Standby is a separate mode, described below.

### Input parameters

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `startDate` | string | yes | none | First day, `YYYY-MM-DD`. A longer ISO timestamp is accepted; only the first 10 characters are used. |
| `endDate` | string | yes | none | Last day, `YYYY-MM-DD`, included in the range. The run fails if this day is before `startDate`. |
| `statTables` | array of strings | yes | none | Dropdown of `all` and the 147 slugs. `all` runs every default table. Several specific slugs can be selected. Blank or omitted is rejected. |
| `threadCount` | integer | no | 8 in the input form | Pages downloaded at the same time. Minimum 1, maximum 20. |

The input form's default for `threadCount` is **8**. If a raw API or Standby request omits `threadCount` entirely, the code uses **7**. Sending `"threadCount": 8` matches the form default.

```json
{
  "startDate": "2026-10-13",
  "endDate": "2026-10-13",
  "statTables": ["offensive-efficiency"],
  "threadCount": 8
}
```

That input is valid. A local request for `offensive-efficiency` on `2026-10-13` returned 30 rows.

The Actor asks for one page per stat per day. Fifteen days and all 147 tables means 2,205 page requests. Use a short range while testing.

### Output data structure

A normal run stores one dataset item for each team row on each requested page. Standby returns the same objects in a JSON array and, in the current code, does not write them to the dataset.

Numeric cells become numbers. Whole numbers stay integers. Other numbers stay decimals. A cell that is not numeric stays text. An empty cell becomes `null`.

| Field | Meaning |
| --- | --- |
| `date` | Requested stat date, `YYYY-MM-DD`. |
| `team` | Team name as printed by TeamRankings, such as `Denver` or `Okla City`. |
| `records_table` | Stat slug for this row. |
| `season` | Season label selected on the page, such as `2025-2026`. |
| `start_year_season` | Value in the current-season column. |
| `last_3` | Value in the last-3-games column. |
| `last_1` | Value in the last-game column. |
| `home` | Home split from that table. |
| `away` | Away split from that table. |
| `before_start_year_season` | Previous-season column. |
| `id` | `{slug}_{date}_{team}_Basketball`. |
| `team_link` | Absolute team URL from the page. |
| `league` | Always `nba`. |
| `sport` | Always `BasketBall`. |
| `last_update` | Date the row was scraped, not the stat date. |

Row order follows whichever page finishes first. Do not rely on team or stat order.

#### Older dataset rows

Current rows use `start_year_season` and `before_start_year_season`, and numeric cells are numbers. Dataset items saved by an earlier build used the spellings `start_year_sesson` and `before_start_year_sesson`, with the values stored as text such as `"1.177"`. Use the field names on the item you received.

### JSON output example

This item was parsed from the TeamRankings offensive-efficiency page for 13 October 2026. `last_update` is the day the row was scraped.

```json
{
  "id": "offensive-efficiency_2026-10-13_Denver_Basketball",
  "date": "2026-10-13",
  "season": "2025-2026",
  "team": "Denver",
  "team_link": "https://www.teamrankings.com/nba/team/denver-nuggets",
  "start_year_season": 1.177,
  "last_3": 1.067,
  "last_1": 1.041,
  "home": 1.176,
  "away": 1.178,
  "before_start_year_season": 1.148,
  "records_table": "offensive-efficiency",
  "league": "nba",
  "last_update": "2026-10-18",
  "sport": "BasketBall"
}
```

### API integration

Create an Apify API token in Console and keep it on your side. The examples use `YOUR_APIFY_TOKEN` as a placeholder.

#### Run the Actor with the Apify API

```bash
curl -X POST "https://api.apify.com/v2/acts/data_hub~nba-team-rankings-trends-api/runs" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startDate": "2026-10-13",
    "endDate": "2026-10-13",
    "statTables": ["offensive-efficiency"],
    "threadCount": 8
  }'
```

The run response includes `defaultDatasetId`. When the run succeeds, read the rows:

```bash
curl "https://api.apify.com/v2/datasets/DATASET_ID/items?format=json" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN"
```

Replace `DATASET_ID` with `defaultDatasetId` from the run. `format` also accepts the dataset formats Apify documents, including `csv`.

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("data_hub/nba-team-rankings-trends-api").call(
    run_input={
        "startDate": "2026-10-13",
        "endDate": "2026-10-13",
        "statTables": ["offensive-efficiency"],
        "threadCount": 8,
    }
)
items = client.dataset(run["defaultDatasetId"]).list_items().items
print(len(items), items[0]["team"], items[0]["start_year_season"])
```

`apify-client` is the Apify Python client. It is not installed by the Actor image.

#### Standby HTTP endpoints

Standby is enabled for this Actor. The hostname published for it is:

`https://data-hub--nba-team-rankings-trends-api.apify.actor`

Send your token in the `Authorization: Bearer` header. A `token` query parameter also works, but the header is safer because URLs are often logged. Tokenless access is not enabled.

| Method | Path | Success | Errors |
| --- | --- | --- | --- |
| `GET` | `/` | Plain text `ok` for Apify's readiness probe. JSON `{"status":"ok","statsPath":"/stats"}` otherwise. | |
| `GET` | `/stats` | JSON array of team rows. | `400` for a bad date, slug, or thread count. `422` when the pages contain no rows. `500` when a download fails. `404` for any other path. |
| `POST` | `/stats` | Same array. Send the input as JSON. Query parameters override the body. | Same status codes as `GET /stats`. |

```bash
curl "https://data-hub--nba-team-rankings-trends-api.apify.actor/stats?startDate=2026-10-13&endDate=2026-10-13&statTables=offensive-efficiency&threadCount=8" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN"
```

Repeat `statTables` for more than one slug, or send a JSON body:

```bash
curl -X POST "https://data-hub--nba-team-rankings-trends-api.apify.actor/stats" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startDate": "2026-10-13",
    "endDate": "2026-10-13",
    "statTables": ["points-per-game", "offensive-efficiency"],
    "threadCount": 8
  }'
```

Apify waits up to 5 minutes for the first byte of a Standby response. Choosing a run can take part of that time when a new run has to start. The Actor then retries each failed page 3 times, with a 30-second timeout per attempt.

Only one scrape runs inside a Standby process at a time. A second request waits for the first. The Actor's Standby settings, as published on 18 October 2026, allow up to 4 concurrent requests per run and stop a run after 300 idle seconds. Those platform settings can be changed in Console.

A normal Console start still works. It does not stay running as a web server.

### Pricing

The Actor uses Apify pay-per-event pricing. These are the event prices on the newest pricing record retrieved from the Actor on 18 October 2026. Confirm them on the Actor's pricing tab before a large run. They are not a permanent quote.

| Event | Configured price | When it applies |
| --- | --- | --- |
| Result | $0.003 | One default-dataset item. |
| Actor start | $0.10 | Once per gigabyte of allocated memory, with a minimum of one event. |

The default run memory is 1,024 MB, so a default start is one Actor-start event, or **$0.10**, plus result events. Raising memory can raise the start charge because the event is defined per GB.

Apify also bills platform usage for the memory and time the run consumes. That amount depends on your Apify plan and is not included in the table above.

Illustrative result math, using the verified 30-team page as the row count:

| Run | Dataset rows | Result events | Actor start at 1 GB | Event subtotal |
| --- | --- | --- | --- | --- |
| 1 day, 1 table | 30 | 30 × $0.003 | $0.10 | $0.19 |
| 1 day, all 147 tables, if every table has 30 teams | 4,410 | 4,410 × $0.003 | $0.10 | $13.33 |

Some tables may not return 30 teams. Add platform usage on top. A multi-day full extract multiplies the page count by the number of days.

Standby runs are billed as runs: platform usage continues until the run exits or sits idle past the idle timeout, and an Actor-start event can apply when that run starts. The Standby handler returns JSON directly and does not push those rows to the dataset, so those HTTP rows are not dataset result events in the current code.

There is no free unlimited plan in this Actor.

### Practical use cases

- **Team dashboards.** Request `points-per-game` for a date range and chart season, last 3, home, and away.
- **Historical snapshots.** Store one day per run and keep `date` as the snapshot key.
- **Fantasy research.** Pull shooting, rebounding, assists, and the matching `opponent-` tables for the same date.
- **Offense against defense.** Compare `offensive-efficiency` with `defensive-efficiency` for the same teams.
- **Recent form against the season.** On one row, compare `start_year_season` with `last_3` and `last_1`.
- **PostgreSQL.** Export CSV or JSON from the dataset and load it with your own `COPY` or insert job. This Actor does not connect to a database.
- **Python applications.** Call the Actor with `apify-client`, or call `GET /stats` from Standby.
- **Scheduled pipelines.** Create an Apify Schedule for a normal run, for example one stat list each morning. Scheduling is an Apify platform feature. It is not a separate setting in the Actor input.

### Data source and limitations

All statistics come from public TeamRankings NBA pages. Data Hub and this Actor are not endorsed by, or affiliated with, the NBA or TeamRankings. Team names, season labels, and numbers are reproduced from that site.

- A date or slug with no table produces no rows. A normal run then fails. Standby returns HTTP 422.
- A page that still fails after 3 attempts fails the whole run, or returns HTTP 500 in Standby. Partial pages already downloaded are not saved when that happens.
- Cells can be `null` when TeamRankings leaves them blank.
- The site controls freshness. `last_update` is only the scrape date.
- Team names follow the source, including short names such as `Okla City`.
- Large ranges increase runtime, the chance of a failed page, and the result-event cost.
- The default run timeout published for this Actor is 900 seconds, with 1,024 MB of memory.
- Standby does not accept more than one scrape at a time inside one process.
- This Actor does not cover player stats, injuries, odds, or game predictions.

### Frequently asked questions

#### Does this Actor support historical NBA statistics?

Yes, for dates you pass as `YYYY-MM-DD`, when TeamRankings still serves that page. The Actor does not keep its own historical archive.

#### Can I select specific statistics?

Yes. Select one or more slugs in `statTables`. Select `all` for the 147 default tables.

#### How many categories are available?

The dropdown lists 147 slugs plus `all`. A slug that is not in that list is rejected.

#### Can I export results to CSV or JSON?

Yes, from the dataset of a normal run. Apify Console can download JSON, CSV, Excel, XML, and the other dataset formats it currently provides. Standby responses are JSON only.

#### Can I use the Actor through an API?

Yes. Start a run with the Apify API, or call the Standby hostname with a Bearer token.

#### Can I schedule daily data extraction?

Yes. Use an Apify Schedule on a normal run. The Actor input has no schedule field of its own.

#### How much does one run cost?

At the prices retrieved on 18 October 2026, budget $0.003 per dataset row and $0.10 per Actor start at the default 1 GB, plus Apify platform usage. Check the pricing tab, because those event prices are configuration and can change.

#### What happens if data is unavailable?

The Actor retries a failed download 3 times. If the pages load but contain no team rows, the normal run fails with an error and Standby returns 422. Nothing is silently filled in.

#### Can I integrate the data into dashboards?

Yes. Filter the dataset on `date`, `team`, and `records_table`, or call `/stats` and read the JSON array. The Actor does not host a dashboard.

### Try it

Open [NBA Team Rankings & Trends API](https://apify.com/data_hub/nba-team-rankings-trends-api), run one day and one stat table, and inspect the dataset before you launch a full 147-table extract.

From there you can export the rows, call the Apify API, or use the Standby `/stats` endpoint in your own application. If something does not match this page, report it on the Actor's **Issues** tab.

# Actor input Schema

## `startDate` (type: `string`):

First day to scrape, in YYYY-MM-DD format.

## `endDate` (type: `string`):

Last day to scrape, in YYYY-MM-DD format. This day is included.

## `statTables` (type: `array`):

Select one or more stat tables, or all to scrape the full set of 147 tables. Several specific slugs can be selected. Copy these two slugs exactly: opponent-steals-perpossession and opponent-points-plus-rebounds-plus-assists-per-gam. A blank value is rejected.

## `threadCount` (type: `integer`):

How many stat pages to download at the same time.

## Actor input object example

```json
{
  "threadCount": 8
}
```

# Actor output Schema

## `results` (type: `string`):

Team statistic rows in the default dataset. Each item has date, team, records_table, season, start_year_season, last_3, last_1, home, away, and before_start_year_season.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("data_hub/nba-team-rankings-trends-api").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("data_hub/nba-team-rankings-trends-api").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call data_hub/nba-team-rankings-trends-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data_hub/nba-team-rankings-trends-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/WOwYesr24a815bZSb/builds/CrbJkjxg5lHqGSXMs/openapi.json
