# MBTA Boston Live Transit Scraper (`parseforge/mbta-transit-scraper`) Actor

Scrape live data from the MBTA (Massachusetts Bay Transportation Authority): routes, stops, vehicle positions, predictions, and service alerts across subway, commuter rail, bus, and ferry. Filter by mode, route, or stop.

- **URL**: https://apify.com/parseforge/mbta-transit-scraper.md
- **Developed by:** [ParseForge](https://apify.com/parseforge) (community)
- **Categories:** Business, Automation, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $28.87 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
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

![ParseForge Banner](https://github.com/ParseForge/apify-assets/blob/ad35ccc13ddd068b9d6cba33f323962e39aed5b2/banner.jpg?raw=true)

## 🚇 MBTA Live Transit Scraper

> 🚀 **Export Boston's live transit feed in seconds.** Routes, stops, real-time vehicle positions, next-arrival predictions, and service alerts across the entire MBTA network. No sign-up, no manual GTFS wrangling.

> 🕒 **Last updated:** 2026-05-15 · **📊 Up to 60 fields** per record · **🚇 5 transit modes** · **🚉 200+ routes · 8,000+ stops** · **🟢 Live every minute**

The **MBTA Live Transit Scraper** exports the official Massachusetts Bay Transportation Authority live feed and returns up to **60 transit fields per record**, depending on whether you fetch routes, stops, vehicles, predictions, or alerts. The MBTA feed is the canonical reference for Boston public transit and powers Google Maps, Transit App, the official MBTA app, and dozens of academic mobility studies.

The catalogue covers the **Red, Orange, Blue, Green, and Mattapan rapid-transit lines, the Silver Line BRT, every commuter-rail line, hundreds of bus routes, and harbor ferry service** across more than 8,000 stops. This Actor makes the live feed downloadable as CSV, Excel, JSON, or XML in under a minute. Filtering by route, stop, transit mode, and direction runs server-side.

| 🎯 Target Audience | 💡 Primary Use Cases |
|---|---|
| Boston transit-app developers, mobility researchers, urban-planning teams, real-estate platforms, journalism teams, GTFS data engineers | Real-time vehicle dashboards, arrival-prediction widgets, accessibility audits, alerts pipelines, transit-equity research, GTFS validation |

---

### 📋 What the MBTA Live Transit Scraper does

Five data modes in a single Actor:

- 🛤️ **Routes.** All 200+ routes across heavy rail, light rail, commuter rail, bus, and ferry, with colors, headsigns, and route types.
- 🚉 **Stops.** 8,000+ stops including platform names, lat/lon, wheelchair-boarding flags, and physical address.
- 🚍 **Vehicles.** Live positions for every vehicle in revenue service, with bearing, speed, occupancy, and current stop.
- 🕒 **Predictions.** Next-arrival predictions per stop with arrival/departure times, headsign, schedule relationship, and uncertainty.
- ⚠️ **Alerts.** Active disruptions, planned closures, severity, cause, effect, and the affected route/stop entities.

Filter every mode by route IDs, stop IDs, transit mode (heavy rail, light rail, commuter rail, bus, ferry), and direction.

> 💡 **Why it matters:** MBTA serves more than 1 million weekday riders. Real-time transit data powers commuter apps, accessibility studies, and journalism on service equity. Building your own pipeline means parsing GTFS-Realtime protobufs, joining static GTFS, and handling alerts. This Actor skips all of that.

---

### 🎬 Full Demo

_🚧 Coming soon: a 3-minute walkthrough showing live Red Line vehicle positions exported to Sheets._

---

### ⚙️ Input

<table>
<thead>
<tr><th>Input</th><th>Type</th><th>Default</th><th>Behavior</th></tr>
</thead>
<tbody>
<tr><td><code>maxItems</code></td><td>integer</td><td><code>10</code></td><td>Records to return. Free plan caps at 10, paid plan at 1,000,000.</td></tr>
<tr><td><code>mode</code></td><td>string</td><td><code>"routes"</code></td><td>One of <code>routes</code>, <code>stops</code>, <code>vehicles</code>, <code>predictions</code>, <code>alerts</code>.</td></tr>
<tr><td><code>routeFilter</code></td><td>string</td><td><code>""</code></td><td>Comma-separated route IDs (e.g. <code>"Red,Orange,Green-B,1,77"</code>).</td></tr>
<tr><td><code>stopFilter</code></td><td>string</td><td><code>""</code></td><td>Comma-separated stop IDs (e.g. <code>"place-pktrm,70061"</code>) for predictions and alerts.</td></tr>
<tr><td><code>transitMode</code></td><td>string</td><td><code>"all"</code></td><td>Restrict to <code>light-rail</code>, <code>heavy-rail</code>, <code>commuter-rail</code>, <code>bus</code>, or <code>ferry</code>.</td></tr>
<tr><td><code>directionId</code></td><td>string</td><td><code>"any"</code></td><td>Travel direction filter for predictions and vehicles.</td></tr>
</tbody>
</table>

**Example: live Red Line vehicle positions.**

```json
{
    "maxItems": 50,
    "mode": "vehicles",
    "routeFilter": "Red"
}
````

**Example: next arrivals at Park Street station.**

```json
{
    "maxItems": 20,
    "mode": "predictions",
    "stopFilter": "place-pktrm"
}
```

> ⚠️ **Good to Know:** vehicle positions update roughly every 15 seconds; alerts can change at any time. The live MBTA feed treats heavy rail (1) as subway lines like Red/Orange/Blue and light rail (0) as Green Line and the Mattapan trolley.

***

### 📊 Output

Each record contains up to **60 fields** depending on the mode you choose. Download as CSV, Excel, JSON, or XML.

#### 🧾 Schema (representative subset by mode)

| Field | Type | Where it appears | Example |
|---|---|---|---|
| 🆔 `id` | string | all | `"Red"`, `"place-pktrm"`, `"y1741"` |
| 📂 `type` | string | all | `"route"`, `"stop"`, `"vehicle"`, `"prediction"`, `"alert"` |
| 🏷️ `shortName` | string | routes | `"Red Line"` |
| 📌 `longName` | string | routes | `"Red Line"` |
| 🎨 `color` | string | routes | `"DA291C"` |
| 🔢 `routeType` | number | routes, stops | `1` |
| 🏷️ `routeTypeLabel` | string | routes | `"Heavy Rail"` |
| 📌 `name` | string | stops | `"Park Street"` |
| 📍 `latitude` | number | stops, vehicles | `42.356395` |
| 📍 `longitude` | number | stops, vehicles | `-71.062424` |
| ♿ `wheelchairBoarding` | number | stops | `1` |
| 🆔 `vehicleId` | string | vehicles | `"y1741"` |
| 🧭 `bearing` | number | vehicles | `120` |
| 📈 `speed` | number | vehicles | `12.4` |
| 🚦 `currentStatus` | string | vehicles | `"IN_TRANSIT_TO"` |
| 👥 `occupancyStatus` | string | vehicles | `"FEW_SEATS_AVAILABLE"` |
| 🕒 `arrivalTime` | string | predictions | `"2026-05-15T14:32:00-04:00"` |
| 📌 `tripHeadsign` | string | predictions | `"Alewife"` |
| 📌 `header` | string | alerts | `"Red Line shuttle service"` |
| 🔴 `severity` | number | alerts | `7` |
| 📝 `effect` | string | alerts | `"SHUTTLE"` |
| 📅 `activePeriod` | array | alerts | `[{ "start": "...", "end": "..." }]` |
| 🕒 `snapshotTime` | ISO 8601 | all | `"2026-05-15T18:32:11.000Z"` |

#### 📦 Sample records

<details>
<summary><strong>🛤️ Route record: Red Line</strong></summary>

```json
{
    "id": "Red",
    "type": "route",
    "shortName": "",
    "longName": "Red Line",
    "description": "Rapid Transit",
    "color": "DA291C",
    "textColor": "FFFFFF",
    "fareClass": "Rapid Transit",
    "routeType": 1,
    "routeTypeLabel": "Heavy Rail",
    "directionNames": ["South", "North"],
    "directionDestinations": ["Ashmont/Braintree", "Alewife"],
    "listed": true,
    "sortOrder": 10010,
    "snapshotTime": "2026-05-15T18:32:11.000Z"
}
```

</details>

<details>
<summary><strong>🚉 Stop record: Park Street</strong></summary>

```json
{
    "id": "place-pktrm",
    "type": "stop",
    "name": "Park Street",
    "latitude": 42.356395,
    "longitude": -71.062424,
    "address": "Tremont St and Winter St, Boston, MA 02108",
    "municipality": "Boston",
    "wheelchairBoarding": 1,
    "vehicleType": null,
    "vehicleTypeLabel": null,
    "locationType": 1,
    "snapshotTime": "2026-05-15T18:32:11.000Z"
}
```

</details>

<details>
<summary><strong>🚍 Vehicle record: live Red Line train</strong></summary>

```json
{
    "id": "y1741",
    "type": "vehicle",
    "label": "1741",
    "routeId": "Red",
    "tripId": "62358394",
    "vehicleId": "y1741",
    "latitude": 42.350123,
    "longitude": -71.061234,
    "bearing": 120,
    "speed": 12.4,
    "directionId": 0,
    "currentStatus": "IN_TRANSIT_TO",
    "currentStopSequence": 7,
    "occupancyStatus": "FEW_SEATS_AVAILABLE",
    "revenue": "REVENUE",
    "updatedAt": "2026-05-15T18:31:55-04:00",
    "snapshotTime": "2026-05-15T18:32:11.000Z"
}
```

</details>

<details>
<summary><strong>⚠️ Alert record: Red Line shuttle</strong></summary>

```json
{
    "id": "549521",
    "type": "alert",
    "header": "Red Line shuttle service between JFK/UMass and Ashmont",
    "shortHeader": "Red Line shuttle",
    "severity": 7,
    "cause": "MAINTENANCE",
    "effect": "SHUTTLE",
    "serviceEffect": "Bus shuttle replacing Red Line",
    "lifecycle": "ONGOING",
    "timeframe": "Through Sunday",
    "url": "https://www.mbta.com/alerts/549521",
    "activePeriod": [{ "start": "2026-05-15T04:30:00-04:00", "end": "2026-05-17T23:59:00-04:00" }],
    "informedEntities": [{ "routeType": 1, "route": "Red", "directionId": null }],
    "createdAt": "2026-05-13T08:12:14-04:00",
    "snapshotTime": "2026-05-15T18:32:11.000Z"
}
```

</details>

***

### ✨ Why choose this Actor

| | Capability |
|---|---|
| 🚇 | **Five transit modes.** Heavy rail, light rail, commuter rail, bus, and ferry across Greater Boston. |
| 📡 | **Live every run.** Vehicle positions, predictions, and alerts reflect the latest MBTA snapshot. |
| 🎯 | **Five data modes.** Routes, stops, vehicles, predictions, alerts, all from the same Actor. |
| 🔍 | **Server-side filters.** Route IDs, stop IDs, transit mode, and direction combine freely. |
| ⚡ | **Fast.** 200 vehicles or 200 predictions in under 10 seconds. |
| ♿ | **Accessibility-ready.** Wheelchair-boarding flags on every stop. |
| 🚫 | **No sign-up.** Works against the public MBTA live transit feed. |

> 📊 The MBTA feed is the data layer behind every commuter app, accessibility audit, and journalistic investigation into Boston transit equity.

***

### 📈 How it compares to alternatives

| Approach | Cost | Coverage | Refresh | Filters | Setup |
|---|---|---|---|---|---|
| **⭐ MBTA Live Transit Scraper** *(this Actor)* | $5 free credit, then pay-per-use | **All MBTA modes** | **Live per run** | route, stop, mode, direction | ⚡ 2 min |
| Static GTFS downloads | Free | Schedules only | Weekly | None | 🐢 Manual |
| GTFS-Realtime protobuf parsers | Free | Vehicles + predictions | Live | None | ⏳ Hours |
| Commercial transit APIs | $99+/month | Multi-city | Live | Many | ⏳ Integration |

Pick this Actor when you want filtered, structured MBTA data without parsing protobufs or maintaining a GTFS pipeline.

***

### 🚀 How to use

1. 📝 **Sign up.** [Create a free account with $5 credit](https://console.apify.com/sign-up?fpr=vmoqkp) (takes 2 minutes).
2. 🌐 **Open the Actor.** Go to the MBTA Live Transit Scraper page on the Apify Store.
3. 🎯 **Set input.** Pick a mode (routes, stops, vehicles, predictions, alerts), add filters as needed.
4. 🚀 **Run it.** Click **Start** and let the Actor pull the live feed.
5. 📥 **Download.** Grab your results in the **Dataset** tab as CSV, Excel, JSON, or XML.

> ⏱️ Total time from signup to downloaded transit feed: **3-5 minutes.** No coding required.

***

### 💼 Business use cases

<table>
<tr>
<td width="50%" valign="top">

#### 🚇 Transit Apps & Commuter Tools

- Build next-arrival widgets for stations and stops
- Show live vehicle positions on an interactive map
- Push service alerts to commuters via Slack or email
- Surface accessible-route options based on stop wheelchair flags

</td>
<td width="50%" valign="top">

#### 🏙️ Urban Planning & Mobility Research

- Audit MBTA service equity across neighborhoods
- Track on-time performance by route and stop
- Compare bus-corridor coverage to demographic layers
- Build transit-accessibility scores for housing analysis

</td>
</tr>
<tr>
<td width="50%" valign="top">

#### 🏠 Real Estate & PropTech

- Score listings by walking time to MBTA stops
- Highlight transit-accessibility on listing pages
- Power "near transit" filters in rental search
- Inform commercial-site selection with transit data

</td>
<td width="50%" valign="top">

#### 📰 Journalism & Civic Tech

- Investigate service-disruption patterns by route
- Quantify Green Line slow-zone impact
- Power city-council dashboards on transit equity
- Track compliance with accessibility commitments

</td>
</tr>
</table>

***

### 🔌 Automating MBTA Live Transit Scraper

Control the scraper programmatically for scheduled runs and pipeline integrations:

- 🟢 **Node.js.** Install the `apify-client` NPM package.
- 🐍 **Python.** Use the `apify-client` PyPI package.
- 📚 See the [Apify documentation](https://docs.apify.com/api/v2) for full details.

The [Apify Schedules feature](https://docs.apify.com/platform/schedules) lets you trigger this Actor every minute, every hour, or daily. Real-time vehicle tracking pairs well with sub-minute refresh.

***

### 🌟 Beyond business use cases

Live transit data powers more than commercial workflows. The same structured records support research, education, civic projects, and personal initiatives.

<table>
<tr>
<td width="50%">

#### 🎓 Research and academia

- Mobility studies on MBTA service equity
- Replicate published transit-accessibility papers
- Teach geospatial analysis with real transit feeds
- Train ML models that predict arrival uncertainty

</td>
<td width="50%">

#### 🎨 Personal and creative

- Build a personal commute dashboard for your daily route
- Visualize Red Line train movements as data art
- Power a Slack bot that alerts you to delays
- Create a hobbyist transit-history archive

</td>
</tr>
<tr>
<td width="50%">

#### 🤝 Non-profit and civic

- Score MBTA accessibility for disability-rights advocacy
- Audit service equity across Boston neighborhoods
- Provide free transit data to community newsrooms
- Support civic dashboards on disruption frequency

</td>
<td width="50%">

#### 🧪 Experimentation

- Train a delay-prediction model on hourly snapshots
- Validate transit-app UX with real-time data
- Prototype an accessibility-routing assistant
- Test smart-city dashboards with live MBTA feeds

</td>
</tr>
</table>

***

### 🤖 Ask an AI assistant about this scraper

Open a ready-to-send prompt about this ParseForge actor in the AI of your choice:

- 💬 [**ChatGPT**](https://chat.openai.com/?q=How%20do%20I%20use%20the%20MBTA%20Live%20Transit%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🧠 [**Claude**](https://claude.ai/new?q=How%20do%20I%20use%20the%20MBTA%20Live%20Transit%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🔍 [**Perplexity**](https://perplexity.ai/search?q=How%20do%20I%20use%20the%20MBTA%20Live%20Transit%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🅒 [**Copilot**](https://copilot.microsoft.com/?q=How%20do%20I%20use%20the%20MBTA%20Live%20Transit%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)

***

### ❓ Frequently Asked Questions

#### 🧩 How does it work?

Pick one of five data modes, optionally narrow by route, stop, transit mode, or direction, and run. The Actor pulls the official MBTA live feed and writes one clean record per route, stop, vehicle, prediction, or alert.

#### 📏 How accurate is the data?

Data mirrors the official MBTA feed exactly. Vehicle positions update roughly every 15 seconds. Alerts can change at any time. Schedule relationships and cancellations are preserved.

#### 🔁 How fresh are the predictions and vehicles?

Live. Each Actor run snapshots the current state, so back-to-back runs return updated vehicle positions, predictions, and alerts.

#### 🚉 Which transit modes are covered?

All MBTA modes: heavy rail (Red, Orange, Blue), light rail (Green Line, Mattapan), commuter rail, bus, and harbor ferry.

#### 🆔 What route IDs do I use for the filter?

Use MBTA route IDs such as <code>Red</code>, <code>Orange</code>, <code>Blue</code>, <code>Green-B</code>, <code>Green-C</code>, <code>Green-D</code>, <code>Green-E</code>, <code>Mattapan</code>, <code>CR-Worcester</code>, or any bus route number like <code>1</code>, <code>57</code>, <code>77</code>.

#### ⏰ Can I schedule regular runs?

Yes. Use Apify Schedules to refresh vehicles and predictions every minute, or alerts every 15 minutes.

#### ⚖️ Is this data legal to use?

Yes. The MBTA publishes its live transit feed under permissive open-data terms. Attribution is encouraged.

#### 💼 Can I use this data commercially?

Yes. The MBTA welcomes commercial use of its live data for transit apps, journalism, and analytics. Verify the latest terms in their data usage policy.

#### 💳 Do I need a paid Apify plan to use this Actor?

No. The free Apify plan is enough for testing and small runs (10 records per run). A paid plan lifts the limit and unlocks scheduling.

#### ♿ Are accessibility flags included?

Yes. Stop records include <code>wheelchairBoarding</code> values (0 = no info, 1 = accessible, 2 = not accessible). Alerts include accessibility-related effects when applicable.

#### 🆘 What if I need help?

Our support team is here to help. Contact us through the Apify platform or use the Tally form linked below.

***

### 🔌 Integrate with any app

MBTA Live Transit Scraper connects to any cloud service via [Apify integrations](https://apify.com/integrations):

- [**Make**](https://docs.apify.com/platform/integrations/make) - Automate multi-step workflows
- [**Zapier**](https://docs.apify.com/platform/integrations/zapier) - Connect with 5,000+ apps
- [**Slack**](https://docs.apify.com/platform/integrations/slack) - Push alerts and predictions to channels
- [**Airbyte**](https://docs.apify.com/platform/integrations/airbyte) - Pipe transit data into your warehouse
- [**GitHub**](https://docs.apify.com/platform/integrations/github) - Trigger runs from commits and releases
- [**Google Drive**](https://docs.apify.com/platform/integrations/drive) - Export datasets straight to Sheets

You can also use webhooks to trigger downstream actions when a run finishes. Push live alerts into your customer-support stack, or stream vehicle snapshots into a real-time dashboard.

***

### 🔗 Recommended Actors

- [**🚦 TfL London Live Status Scraper**](https://apify.com/parseforge/tfl-london-status-scraper) - Live London transport status and disruptions
- [**🗺️ OSRM Routing Scraper**](https://apify.com/parseforge/osrm-routing-scraper) - Driving, cycling, and walking routes anywhere
- [**🗺️ Nominatim OSM Scraper**](https://apify.com/parseforge/nominatim-osm-scraper) - Geocode addresses via OpenStreetMap
- [**✈️ OurAirports Scraper**](https://apify.com/parseforge/ourairports-scraper) - Global airport master data
- [**🌍 Overpass OSM Scraper**](https://apify.com/parseforge/overpass-osm-scraper) - Query arbitrary OpenStreetMap features

> 💡 **Pro Tip:** browse the complete [ParseForge collection](https://apify.com/parseforge) for more transit and geospatial scrapers.

***

**🆘 Need Help?** [**Open our contact form**](https://tally.so/r/BzdKgA) to request a new scraper, propose a custom data project, or report an issue.

***

> **⚠️ Disclaimer:** this Actor is an independent tool and is not affiliated with, endorsed by, or sponsored by the Massachusetts Bay Transportation Authority or any of its affiliates. All trademarks mentioned are the property of their respective owners. Only publicly available open transit data is collected.

# Actor input Schema

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

Choose what to scrape. Predictions and Schedules require routeFilter or stopFilter. Trips and Shapes require routeFilter. Times are returned in the local Boston (America/New\_York) timezone.

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

Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000

## `sectionCaptionFilters` (type: `string`):

Narrow results by route, stop, or transit mode.

## `routeFilter` (type: `string`):

Comma-separated route IDs (e.g. 'Red,Orange,Green-B,1,77'). Used by predictions, vehicles, alerts, and stops.

## `stopFilter` (type: `string`):

Comma-separated stop IDs (e.g. 'place-pktrm,70061'). Used by predictions and alerts.

## `transitMode` (type: `string`):

Filter by transit mode (route\_type). Heavy rail = subway, light rail = trolley, bus = local bus, ferry = harbor ferry, commuter-rail = MBTA Commuter Rail.

## `directionId` (type: `string`):

Direction of travel: 0 (typically Outbound / South / West), 1 (Inbound / North / East), or any.

## `sort` (type: `string`):

Sort field. Prefix with '-' for descending (e.g. 'arrival\_time', '-departure\_time', 'name', '-severity'). Leave blank for default ordering.

## `include` (type: `string`):

Comma-separated list of related resources to side-load (e.g. 'route,stop,trip,vehicle'). Useful for predictions and schedules.

## Actor input object example

```json
{
  "mode": "routes",
  "maxItems": 10,
  "routeFilter": "",
  "stopFilter": "",
  "transitMode": "all",
  "directionId": "any",
  "sort": "",
  "include": ""
}
```

# Actor output Schema

## `overview` (type: `string`):

Overview of scraped data

## `fullData` (type: `string`):

Complete dataset

# 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 = {
    "maxItems": 10,
    "routeFilter": "",
    "stopFilter": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/mbta-transit-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 = {
    "maxItems": 10,
    "routeFilter": "",
    "stopFilter": "",
}

# Run the Actor and wait for it to finish
run = client.actor("parseforge/mbta-transit-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 '{
  "maxItems": 10,
  "routeFilter": "",
  "stopFilter": ""
}' |
apify call parseforge/mbta-transit-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "MBTA Boston Live Transit Scraper",
        "description": "Scrape live data from the MBTA (Massachusetts Bay Transportation Authority): routes, stops, vehicle positions, predictions, and service alerts across subway, commuter rail, bus, and ferry. Filter by mode, route, or stop.",
        "version": "0.0",
        "x-build-id": "JBlEA1lE5KXaw6evu"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/parseforge~mbta-transit-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-parseforge-mbta-transit-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/parseforge~mbta-transit-scraper/runs": {
            "post": {
                "operationId": "runs-sync-parseforge-mbta-transit-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/parseforge~mbta-transit-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-parseforge-mbta-transit-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",
                "properties": {
                    "mode": {
                        "title": "Data Mode",
                        "enum": [
                            "routes",
                            "stops",
                            "vehicles",
                            "predictions",
                            "alerts",
                            "trips",
                            "schedules",
                            "shapes",
                            "facilities",
                            "lines"
                        ],
                        "type": "string",
                        "description": "Choose what to scrape. Predictions and Schedules require routeFilter or stopFilter. Trips and Shapes require routeFilter. Times are returned in the local Boston (America/New_York) timezone.",
                        "default": "routes"
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 1,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000"
                    },
                    "sectionCaptionFilters": {
                        "title": "Filters",
                        "type": "string",
                        "description": "Narrow results by route, stop, or transit mode."
                    },
                    "routeFilter": {
                        "title": "Route Filter",
                        "type": "string",
                        "description": "Comma-separated route IDs (e.g. 'Red,Orange,Green-B,1,77'). Used by predictions, vehicles, alerts, and stops.",
                        "default": ""
                    },
                    "stopFilter": {
                        "title": "Stop Filter",
                        "type": "string",
                        "description": "Comma-separated stop IDs (e.g. 'place-pktrm,70061'). Used by predictions and alerts.",
                        "default": ""
                    },
                    "transitMode": {
                        "title": "Transit Mode Filter",
                        "enum": [
                            "all",
                            "light-rail",
                            "heavy-rail",
                            "commuter-rail",
                            "bus",
                            "ferry"
                        ],
                        "type": "string",
                        "description": "Filter by transit mode (route_type). Heavy rail = subway, light rail = trolley, bus = local bus, ferry = harbor ferry, commuter-rail = MBTA Commuter Rail.",
                        "default": "all"
                    },
                    "directionId": {
                        "title": "Direction Filter",
                        "enum": [
                            "any",
                            "0",
                            "1"
                        ],
                        "type": "string",
                        "description": "Direction of travel: 0 (typically Outbound / South / West), 1 (Inbound / North / East), or any.",
                        "default": "any"
                    },
                    "sort": {
                        "title": "Sort",
                        "type": "string",
                        "description": "Sort field. Prefix with '-' for descending (e.g. 'arrival_time', '-departure_time', 'name', '-severity'). Leave blank for default ordering.",
                        "default": ""
                    },
                    "include": {
                        "title": "Include Related Resources",
                        "type": "string",
                        "description": "Comma-separated list of related resources to side-load (e.g. 'route,stop,trip,vehicle'). Useful for predictions and schedules.",
                        "default": ""
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
