# Amtrak, Greyhound & Megabus Scraper (`muhammadafzal/us-intercity-rail-bus-scraper`) Actor

Compare Amtrak schedules with live Greyhound and Megabus fares, times, stops, carriers, transfers, availability hints, and booking links in one dataset.

- **URL**: https://apify.com/muhammadafzal/us-intercity-rail-bus-scraper.md
- **Developed by:** [Muhammad Afzal](https://apify.com/muhammadafzal) (community)
- **Categories:** Travel, E-commerce, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 trip 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?

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

## Amtrak, Greyhound & Megabus Scraper — US Intercity Rail & Bus

Compare US intercity travel in one normalized dataset. The Actor returns scheduled Amtrak trains and live fare snapshots from the public Greyhound and Megabus booking flows.

### What it returns

- Departure and arrival times, duration, transfers, stops, service/carrier, and booking link
- Live Greyhound and Megabus price snapshots, currency, availability hints, and amenities when exposed
- Amtrak scheduled services from Amtrak's official GTFS feed
- Multiple routes and provider selection in one run
- A machine-readable `OUTPUT` summary with per-provider counts and warnings

### Important Amtrak limitation

Amtrak does not offer a public self-service booking/fare API for this use case. This Actor therefore uses Amtrak's official public GTFS schedule feed and **does not claim Amtrak fares, seat inventory, or real-time availability**. Amtrak `price`, `currency`, and `seatsLeft` are `null`, while `availability` is `scheduled`.

### Input example

```json
{
  "routes": [
    { "origin": "New York, NY", "destination": "Boston, MA" },
    { "origin": "NYP", "destination": "WAS" }
  ],
  "providers": ["amtrak", "greyhound", "megabus"],
  "dateOffsetDays": 7,
  "adults": 1,
  "maxResults": 50,
  "currency": "USD"
}
```

Set `date` on an individual route as `YYYY-MM-DD`, or omit it and use `dateOffsetDays`. Relative dates make saved Tasks and scheduled runs evergreen. Bus origins accept common city names. Amtrak origins work best as station codes such as `NYP`, `BOS`, `WAS`, `PHL`, `CHI`, and `LAX`.

### Output example

```json
{
  "id": "53aad3c4862936950c4df068",
  "provider": "greyhound",
  "mode": "bus",
  "origin": { "name": "New York, NY", "code": "US-NY", "id": "...", "stopName": "...", "stopId": "..." },
  "destination": { "name": "Boston, MA", "code": "US-MA", "id": "...", "stopName": "...", "stopId": "..." },
  "departureTime": "2026-09-16T08:30:00-04:00",
  "arrivalTime": "2026-09-16T12:50:00-04:00",
  "durationMinutes": 260,
  "transfers": 0,
  "price": 34.99,
  "currency": "USD",
  "bookingUrl": "https://shop.greyhound.com/search?..."
}
```

### Pricing

Pay per event: `$0.005` when a run starts and `$0.003` per trip record written to the default dataset. For 50 records, event charges are about `$0.155`. The Actor stops at `maxResults` and honors the Apify maximum total charge limit. Platform prices can be reconfigured by the owner before publication.

### Reliability and responsible use

The Actor reads public, page-owned carrier data and uses bounded retries and timeouts. Carrier inventory and fares can change between scraping and booking. It does not purchase tickets, access accounts, solve CAPTCHAs, or bypass access controls. Use results in accordance with carrier terms and applicable law, and verify important details on the booking page.

### API

Run the Actor with the Apify API, CLI, schedules, integrations, or MCP. Results are in the default dataset; the `OUTPUT` key contains run diagnostics. Invalid routes are skipped with actionable warnings and no fabricated dataset rows.

# Actor input Schema

## `routes` (type: `array`):

Origin/destination pairs. Use city names for buses and Amtrak station names or three-letter codes for rail. A route date overrides Date offset.

## `providers` (type: `array`):

Providers used unless overridden on a route.

## `dateOffsetDays` (type: `integer`):

Travel date relative to run day when a route has no date. Keeps saved Tasks evergreen.

## `adults` (type: `integer`):

Adult passenger count used for live bus fare searches.

## `maxResults` (type: `integer`):

Global cap across all routes and providers, distributed fairly so one provider cannot crowd out the comparison.

## `currency` (type: `string`):

Currency requested from Greyhound. Megabus US prices are always labeled USD.

## `requestTimeoutSecs` (type: `integer`):

Maximum wait for each carrier request before a bounded retry.

## Actor input object example

```json
{
  "routes": [
    {
      "origin": "New York, NY",
      "destination": "Boston, MA"
    }
  ],
  "providers": [
    "amtrak",
    "greyhound",
    "megabus"
  ],
  "dateOffsetDays": 7,
  "adults": 1,
  "maxResults": 50,
  "currency": "USD",
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

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

Normalized trip records.

## `datasetUi` (type: `string`):

Dataset in Apify Console.

## `summary` (type: `string`):

Outcome, counts, and warnings.

# 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 = {
    "routes": [
        {
            "origin": "New York, NY",
            "destination": "Boston, MA"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("muhammadafzal/us-intercity-rail-bus-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 = { "routes": [{
            "origin": "New York, NY",
            "destination": "Boston, MA",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("muhammadafzal/us-intercity-rail-bus-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 '{
  "routes": [
    {
      "origin": "New York, NY",
      "destination": "Boston, MA"
    }
  ]
}' |
apify call muhammadafzal/us-intercity-rail-bus-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,muhammadafzal/us-intercity-rail-bus-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/Co7oHlQqbEKnTd7WP/builds/6DWuuVgNRSx9ch1te/openapi.json
