# ESPN News Scraper (`w3crawler/espn-news-scraper`) Actor

Read public ESPN news feeds across 16 leagues and return normalized article records or fail-closed access diagnostics.

- **URL**: https://apify.com/w3crawler/espn-news-scraper.md
- **Developed by:** [w3crawler](https://apify.com/w3crawler) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 news

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

## ESPN News

ESPN News reads public ESPN league news feeds and writes normalized article records to an Apify dataset. It uses direct HTTPS requests to ESPN's public site API and, when requested, one bounded request to each accessible non-premium ESPN article page. It does not bypass logins, paywalls, CAPTCHAs, geographic restrictions, device checks, WAFs, or other access controls.

The default public feed is the [ESPN NBA news API](https://site.api.espn.com/apis/site/v2/sports/basketball/nba/news). The Actor supports 16 public league codes: `nba`, `nfl`, `mlb`, `nhl`, `mls`, `wnba`, `ncaam`, `ncaaw`, `ncaaf`, `epl`, `laliga`, `ucl`, `bundesliga`, `seriea`, `ligue1`, and `ligamx`.

### Input

- `leagues` (required array): one or more supported league codes.
- `teams` (optional array): public team abbreviations or ESPN numeric IDs. At most 25 are accepted.
- `fetchFullBody` (optional boolean): include cleaned visible body text only when a public, non-premium article page is accessible.
- `maxItems` (optional integer): maximum article records across all requested feeds, from 1 to 10,000. Each feed request is capped at 100 articles.
- `fixtureFile` (optional string): local QA-only JSON fixture path inside the Actor directory. Omit it for public-source runs.

Unknown fields, invalid league codes, malformed filters, and out-of-range limits are rejected. No proxy, login, email, private endpoint, or browser-bypass input is accepted.

### Dataset contract

Normal rows contain business article data and source provenance only:

```json
{
  "recordType": "espn-news-article",
  "sourceName": "ESPN public site API",
  "sourceKind": "public-espn-api",
  "sourceUrl": "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/news?limit=10",
  "articleId": "49854792",
  "league": "nba",
  "sport": "basketball",
  "articleType": "article",
  "headline": "Public article headline",
  "description": "Public article summary when supplied",
  "published": "2026-09-07T10:45:59.000Z",
  "url": "https://www.espn.com/nba/story/_/id/49854792/example",
  "premium": false,
  "scrapedAt": "2026-09-08T00:00:00.000Z"
}
```

Optional business fields include `lastModified`, `byline`, `allowComments`, selected `images`, `categories`, `keywords`, `videoCount`, public team fields, `inputTeam`, and `bodyText`.

Every diagnostic row is exactly four fields:

```json
{
  "url": "https://site.api.espn.com/apis/site/v2/sports/basketball/nba/news?limit=1",
  "error": "The public source rate-limited the request; no records were collected. (HTTP 429)",
  "errorCode": "RATE_LIMITED",
  "scrapedAt": "2026-09-08T00:00:00.000Z"
}
```

Diagnostics are fail-closed evidence of an unavailable or restricted source, not article records. No diagnostic wrapper, HTTP status, retry count, execution status, or request metadata is written into a business row. A run that collected earlier article rows before a later source failure is marked `PARTIAL` in the run summary.

### Run artifacts

`OUTPUT_SUMMARY` and its compatibility alias `OUTPUT` contain run-level counts and status. `SOURCE_METADATA` records the public source boundary and whether the run used a local fixture. These operational details stay in the key-value store rather than in dataset business rows.

Statuses are `SUCCESS`, `PARTIAL`, `DIAGNOSTIC`, or `ERROR`. Counts include article rows, exact diagnostic rows, duplicate articles removed, attempted feeds, and body pages collected.

### Local verification

```text
npm ci
npm test
npm run lint
npm run schema
npm run validate
```

For deterministic QA, run the Actor from a disposable copy with input such as:

```json
{
  "leagues": ["nba"],
  "teams": ["FBK"],
  "fetchFullBody": true,
  "maxItems": 2,
  "fixtureFile": "fixtures/news.json"
}
```

The fixture is not live evidence. A public run must use the ESPN feed and report its observed source URL. If ESPN returns an access-control response, the Actor emits the exact diagnostic shape and does not invent replacement content.

### Cost and responsible use

Metadata-only runs use one sequential public feed request per league/filter. Body mode adds one bounded article-page request per selected article. Start with a small limit and respect ESPN's terms, robots/access signals, applicable law, and the rights of people represented in public content.

# Actor input Schema

## `leagues` (type: `array`):

Public ESPN league feeds to read. Supported codes are nba, nfl, mlb, nhl, mls, wnba, ncaam, ncaaw, ncaaf, epl, laliga, ucl, bundesliga, seriea, ligue1, and ligamx.

## `teams` (type: `array`):

Optional team abbreviations or public ESPN numeric team IDs. Team-filtered feeds are read in addition to the league-wide feed, with at most 25 filters accepted per run.

## `fetchFullBody` (type: `boolean`):

When enabled, make one bounded public request to each non-premium ESPN article page and include cleaned visible text when available. Paywalls, login prompts, CAPTCHAs, and other access controls fail closed with a diagnostic.

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

Maximum number of public article records to return across all requested feeds. The Actor bounds this value to 1–10,000 and requests at most 100 articles per feed.

## `fixtureFile` (type: `string`):

Optional path to a local JSON fixture used only for deterministic verification. Leave empty for public ESPN requests; the fixture is resolved inside the Actor directory.

## Actor input object example

```json
{
  "leagues": [
    "nba"
  ],
  "fetchFullBody": false,
  "maxItems": 100
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing normalized public ESPN article records and diagnostics.

## `runSummary` (type: `string`):

JSON summary stored under the exact OUTPUT key in the default key-value store.

# 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 = {
    "leagues": [
        "nba"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("w3crawler/espn-news-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 = { "leagues": ["nba"] }

# Run the Actor and wait for it to finish
run = client.actor("w3crawler/espn-news-scraper").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 '{
  "leagues": [
    "nba"
  ]
}' |
apify call w3crawler/espn-news-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,w3crawler/espn-news-scraper"
        }
    }
}
```

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/ajli010FVbr0Easpe/builds/YhwahZmaS6a8MC7wk/openapi.json
