# MBTA Boston Realtime Vehicles Scraper (`parseforge/mbta-realtime-scraper`) Actor

Scrapes realtime MBTA vehicle positions by route or route type and returns each observation as a flat row with location, stop, status, and timestamp. No API key needed.

- **URL**: https://apify.com/parseforge/mbta-realtime-scraper.md
- **Developed by:** [ParseForge](https://apify.com/parseforge) (community)
- **Categories:** Travel, Automation, Integrations
- **Stats:** 2 total users, 1 monthly users, 89.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $7.50 / 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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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](https://raw.githubusercontent.com/ParseForge/apify-assets/main/banner.jpg)](https://apify.com/parseforge?fpr=vmoqkp)

### MBTA Boston Realtime Vehicles Scraper

**Scrape realtime vehicle positions from the MBTA Boston transit network, up to a million records per run.** Each record includes route, stop, bearing, current status, and timestamp. No API key required. Export to CSV, JSON, Excel, or XML.

The MBTA's official API needs a developer account and key, and rate-limits you. This reads the public realtime vehicle feed directly, filtered by route or route type, and returns each match in one fixed schema. Get live positions for subway, bus, commuter rail, light rail, and ferry vehicles across Boston.

| Who uses it | What they scrape MBTA Boston for |
|---|---|
| Transit app developers | Build a live map of where every bus and train is right now. |
| Operations analysts | Monitor headway adherence and bunching across the network. |
| Commuter advocates | Track on-time performance for a specific bus or subway line. |
| Data journalists | Investigate service gaps and delays with timestamped vehicle data. |

### What it does

This Actor collects realtime MBTA vehicle positions by route or route type, and returns each one as a flat row.

- 🚇 **Route filter:** target a single route like Red, Orange, 66, or Green-B, or leave empty for all routes.
- 🚌 **Route type filter:** narrow to Light rail, Subway, Commuter rail, Bus, or Ferry only.
- 📊 **Realtime fields:** latitude, longitude, bearing, current stop, current status, and timestamp.
- 📦 **Flat output:** one row per vehicle observation, ready for CSV, JSON, Excel, or XML export.

Results export to CSV, JSON, Excel, or XML, or straight from the API.

### What you can do with MBTA Boston data

**🚇 Build a live transit dashboard.**

A developer runs the Actor every 30 seconds for all subway routes and plots vehicle positions on a map for a public-facing website.

**🚌 Monitor bus bunching on a key route.**

An operations analyst filters by route 66 and collects positions every minute to measure headway variance during the morning peak.

**🚃 Audit commuter rail on-time performance.**

A transit advocate scrapes the commuter rail route type daily and compares scheduled versus actual arrival times at each stop.

**📈 Feed a realtime prediction model.**

A data scientist collects all vehicle positions for a week and trains a model to predict delays based on bearing, status, and time of day.

### Why choose this scraper

|  | What you get |
|---|---|
| **No API key** | Reads the public realtime feed directly, no registration needed. |
| **Live positions** | Latitude, longitude, bearing, and current stop for every vehicle. |
| **Route targeting** | Filter by specific route ID or by mode like Bus or Subway. |
| **Scalable runs** | Collect up to a million records per run for long-duration monitoring. |

### How it compares

No other Store actor targets MBTA Boston the same way, so the honest comparison is with the alternatives teams actually weigh.

| | MBTA Boston Realtime Vehicles Scraper | Build it in-house | By hand |
|---|---|---|---|
| Setup | Run it now, zero config | Days of engineering | None, but hours per pull |
| When MBTA Boston changes | Maintained for you | You fix it | You re-learn the page |
| Proxies, retries, anti-bot | Built in | Your problem | Browser only |
| Output | Fixed JSON schema, CSV/Excel export | Whatever you build | Copy-paste |
| Cost | Pay per result | Engineering time | Analyst hours |

### Configure the run

Drive the Actor from a route ID or route type, alone or together, and filters run as each record is read so only matches reach your dataset. The Input tab lists every parameter.

A first run with the defaults:

```json
{
  "maxItems": 10
}
```

A larger pull:

```json
{
  "maxItems": 200
}
```

### Pricing

Pay-per-result: **$0.0085 per result** collected. You pay only for the results written to your dataset.

| Results collected | Approximate cost |
|---|---|
| 100 results | $0.85 |
| 1,000 results | $8.50 |
| 10,000 results | $85.00 |

New Apify accounts start with $5 in free credit.

### Free users

Free-plan runs return up to 10 results as a preview. [Upgrade your Apify plan](https://console.apify.com/sign-up?fpr=vmoqkp) to collect up to 1,000,000 results per run.

### Run it

1. [Create a free Apify account with $5 in credit](https://console.apify.com/sign-up?fpr=vmoqkp).
2. Open the [MBTA Boston Realtime Vehicles Scraper](https://apify.com/parseforge/mbta-realtime-scraper?fpr=vmoqkp).
3. Set your inputs and any filters, then click **Start**.
4. Export the results as CSV, Excel, JSON, or XML from the **Dataset** tab.

Run it programmatically through the [Apify API](https://docs.apify.com/api/v2) (`run-sync-get-dataset-items`) or the [ApifyClient](https://docs.apify.com/api/client/js) for JavaScript and Python.

### Use with AI agents (MCP)

Give an AI agent live access to MBTA Boston through the Model Context Protocol. Add the Actor to Claude, Cursor, or any MCP client:

```bash
claude mcp add --transport http apify "https://mcp.apify.com/?tools=parseforge/mbta-realtime-scraper"
```

Then prompt it in plain language to run the scraper and read back the results.

### Troubleshooting

**Why am I getting no results?**

Check that your route ID or route type filter is valid. Try leaving both filters empty to see all vehicles. Also confirm the MBTA is operating at the time of your run.

**The Actor runs but stops after very few records.**

Increase the maximum records input. If the route you filtered has few active vehicles, you may need to broaden the filter or run during peak service hours.

**Positions seem stale or not updating.**

The MBTA feed updates every few seconds. Schedule your Actor to run more frequently, and check that your run is not being rate-limited by the source.

**I see duplicate vehicle IDs in my dataset.**

This is expected. Each record is a single observation at a point in time. The same vehicle will appear many times as it moves. Use the timestamp to order them.

**The route ID I entered is not recognized.**

Route IDs are case-sensitive. Use the exact ID as shown in MBTA data, like Red, Orange, Green-B, or 66. Check the MBTA website for a current list.

### FAQ

| Question | Answer |
|---|---|
| Do I need an MBTA API key? | No. This Actor reads the public realtime vehicle feed directly, so no developer account or key is required. |
| What data does each record contain? | Each record includes the vehicle ID, route ID, latitude, longitude, bearing, current stop, current status, and a timestamp of the observation. |
| Can I filter by a specific bus or train line? | Yes. Use the Route Filter input to specify a route ID like Red, Orange, 66, or Green-B. Leave it empty to get all routes. |
| How do I get only subway vehicles? | Set the Route Type filter to Subway. You can also filter by Light rail, Commuter rail, Bus, or Ferry. |
| How many records can I collect in one run? | You can set the maximum records up to 1,000,000 per run. The Actor will stop once it reaches that count. |
| How often should I run this Actor? | Vehicle positions update every few seconds. For live tracking, schedule the Actor to run every 15 to 60 seconds. |
| What export formats are supported? | You can export your dataset to CSV, JSON, Excel, or XML from the Apify platform. |
| Does this cover the entire MBTA network? | Yes. It covers all modes: subway, bus, commuter rail, light rail, and ferry, for the whole MBTA service area. |
| Can I get historical vehicle positions? | This Actor collects current realtime positions. To build history, schedule repeated runs and store the datasets over time. |
| What is the current status field? | It indicates whether the vehicle is in transit to a stop, stopped at a stop, or another operational state as reported by the MBTA feed. |

### Related actors

- [mbta-realtime-scraper](https://apify.com/parseforge/mbta-realtime-scraper?fpr=vmoqkp): Use this for live vehicle positions. For scheduled data, look for a GTFS static scraper instead.

Browse the full [ParseForge collection](https://apify.com/parseforge?fpr=vmoqkp) for more scrapers.

🆘 **Need help?** Email parseforge@protonmail.com with your run ID, your input, and what you expected.

⚠️ **Disclaimer.** This Actor is unofficial and is not affiliated with, endorsed by, or sponsored by Massachusetts Bay Transportation Authority. It collects only publicly available data. You are responsible for using the collected data in compliance with the source's terms of service and applicable data-protection laws, including GDPR, CCPA, and PIPL. Do not use it to collect personal data unlawfully.

# Actor input Schema

## `route` (type: `string`):

Optional route id (e.g. Red, Orange, Blue, Green-B, 1, 66). Leave empty for all routes.

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

How many realtime records to collect per run.

## `routeType` (type: `string`):

Optional route type filter.

## Actor input object example

```json
{
  "maxItems": 10
}
```

# Actor output Schema

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

No description

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

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/mbta-realtime-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 }

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,parseforge/mbta-realtime-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/fSxvmkBVy7f6MuKeo/builds/WYsFqdaJooByYfoZn/openapi.json
