# Google Maps Transit Station Lines, Alerts & Departures (`crawlyth-forge/google-maps-transit-stations`) Actor

Export Google Maps transit stations by city and transit type, station name, or Maps URL/ID. Returns coordinates, address, agency, serving lines, accessibility, service alerts and live departures where published.

- **URL**: https://apify.com/crawlyth-forge/google-maps-transit-stations.md
- **Developed by:** [crawlyth forge](https://apify.com/crawlyth-forge) (community)
- **Categories:** Travel, Automation, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.49 / 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.
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?

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

## Google Maps Transit Station Lines, Alerts & Departures

Turn Google Maps station pages into structured transit data: every line serving a station, its
colour and direction, the operator, wheelchair access, current service alerts with validity
windows, and the live departure board where Google publishes one. Works worldwide, needs no
Google API key, no cookies and no browser.

Use it for commute dashboards, real-estate transit scoring, network inventories, disruption
monitoring and accessibility analysis.

### What you can do

| Mode | What it returns |
|---|---|
| `searchStations` | Stations in a city or area, filtered by transit type (subway, train, bus, tram, ferry) |
| `stationNames` | The transit stations that best match one or more station names |
| `stationUrls` | Stations from Google Maps place URLs, share links, `ChIJ…` place IDs or `0x…:0x…` feature IDs |
| `departures` | One row per upcoming departure with line, headsign, scheduled and expected time, delay and platform where Google shows them |
| `monitorAlerts` | Only the alerts that appeared or cleared since the previous run of the same task |

### Inputs

| Input | Default | Used by | Notes |
|---|---|---|---|
| `city` | `New York` | `searchStations`, fallback for `departures` / `monitorAlerts` | City, district or area, e.g. `New York`, `London`, `Berlin Mitte` |
| `transitTypes` | `["subway"]` | `searchStations`, fallback modes | Multi-select: `subway`, `train`, `bus`, `tram`, `ferry` |
| `stationNames` | `[]` | `stationNames`, `departures`, `monitorAlerts` | One name per list item; add a city inside the name when ambiguous |
| `stationUrls` | `[]` | `stationUrls`, `departures`, `monitorAlerts` | Full place URLs, share links, place IDs or feature IDs |
| `includeDepartures` | `false` | station modes | Attach the upcoming departure board to each station record |
| `maxDeparturesPerLine` | `3` | station and departure modes | Google's board usually shows three per direction |
| `maxLinesPerStation` | `100` | station modes | Large rail terminals can list hundreds of train numbers |
| `includeLineColors` | `true` | station modes | Resolve hex colours from Google's public line badges |
| `includeClearedAlerts` | `true` | `monitorAlerts` | Also emit a row when a previously seen alert disappears |
| `monitorStateKey` | `default` | `monitorAlerts` | Separate saved state for different tasks watching the same station |
| `maxItems` | `50` | all modes | Hard row cap |

Every mode-specific requirement is reported in the run status if it is missing. Only `mode` is a
required field, so the same task can switch modes without form validation errors.

### Station record

A `transitStation` row carries everything Google publishes for the place that is meaningful for
transit:

- identity: `stationName`, `placeId`, `featureId`, `cid`, `sourceUrl`, `inputValue` (the name, URL or search query that produced the row)
- geography: `latitude`, `longitude`, `address`, `countryCode`, `locality`, `timezone`
- classification: `categoryName`, `categories`, `transitTypes`
- quality signals: `rating`, `reviewCount`, `phone`, `website`
- operator: `agencyName`, `agencyWebsite`, `transitAgencies` (name + website)
- service: `lines` (`lineName`, `mode`, `lineColor`, `lineTextColor`, direction `headsigns`),
  `lineNames`
- accessibility: `wheelchairAccessibleEntrance`, and `wheelchairAccessibleRestroom` when Google
  states it
- disruption: `alerts` (`title`, `summary`, `description`, `affectedLines`, `startsAt`, `endsAt`,
  `alertUrl`, `alertKey`) and `alertCount`
- departures: `departureCount`, plus a `departures` array when `includeDepartures` is on

Rows are omit-empty: a field Google does not publish for a station is absent, never `null` or
`"N/A"`.

### Departure rows

`departures` mode (and a station record with `includeDepartures`) exposes:

- `lineName`, `lineColor`, `lineTextColor`, `lineMode`, `headsign`
- `departureTime` (ISO with the station's UTC offset) and `departureTimeText` (Google's own text,
  e.g. `1:37 PM`)
- `scheduledTime` / `scheduledTimeText` and `delayMinutes` when Google shows a separate scheduled
  time. A negative delay means the service is expected early.
- `platform` when Google labels one (e.g. `Platform 4`)
- station identity and `sourceUrl` on every row

### Alert monitoring

`monitorAlerts` stores the alerts it saw under a named key-value store, per station and
`monitorStateKey`. The next run emits:

- `changeType: "new"` with `firstSeenAt` for an alert that was not in the saved state;
- `changeType: "cleared"` with `firstSeenAt`, `lastSeenAt` and `clearedAt` when a saved alert is no
  longer shown (disable with `includeClearedAlerts: false`).

The first run of a task reports every current alert as new. Keep the same `monitorStateKey` on
scheduled runs to keep the diff stable.

### Examples

Find subway stations in New York, with their lines and current alerts:

```json
{
  "mode": "searchStations",
  "city": "New York",
  "transitTypes": ["subway"],
  "maxItems": 25
}
```

Read one station from a Google Maps URL and include its departure board:

```json
{
  "mode": "stationUrls",
  "stationUrls": ["https://www.google.com/maps/place/?q=place_id:ChIJ5RqjPKtZwokRgOy4tBivbcw"],
  "includeDepartures": true,
  "maxDeparturesPerLine": 3
}
```

Departure board for a named station:

```json
{
  "mode": "departures",
  "stationNames": ["Mumbai Central"],
  "maxItems": 20
}
```

Watch alerts at a station:

```json
{
  "mode": "monitorAlerts",
  "stationNames": ["Times Sq-42 St"],
  "monitorStateKey": "times-square",
  "maxItems": 50
}
```

### Coverage

Google Maps carries transit data for metro, suburban rail, bus, tram and ferry networks in most
countries. Station discovery is text-driven, so any city, district or station name that Google Maps
understands works without a separate geocoding key. Station details, alerts and departure boards
are read from the same public page data Google shows to a logged-out visitor.

### Limits

- A single search returns Google's ranked window of up to 13 pages (about 260 places). Split a
  large network into city, district or transit-type queries to cover more.
- Some Google place entities are transit categories but have no transit payload (station
  buildings, some coach stations and ferry docks). They are returned with base fields only.
- Departure boards exist only where Google publishes one. An empty board is not an error and is
  reported in the run status.
- A platform appears only when Google labels it, and a delay only when Google exposes both
  scheduled and expected times.
- `maxLinesPerStation` truncates very large line lists; set it up to 1000 when you need everything.
- Alerts are a point-in-time snapshot. Use `monitorAlerts` for change detection.

### FAQ

**Do I need a Google Maps API key?** No. The actor reads the same public station pages a browser
does, with plain HTTP.

**Do I need cookies or a login?** No. The actor never asks for credentials.

**Do I need to configure a proxy?** No. The actor uses a direct connection and only falls back to
an included datacenter pool automatically if Google starts blocking requests.

**Why is a line colour missing for one line?** Google sometimes publishes a text-only badge without
a colour. The actor emits the line name and omits the colour rather than inventing one.

**Why does a big train station have so many lines?** Google lists every train number that serves
the station. Use `maxLinesPerStation` or the `departures` mode when you only need current service.

**Are departure times real time?** They are exactly what Google's board shows. When Google displays
a separate scheduled and expected time, both are emitted with the delay between them.

**Can I monitor several tasks on the same station?** Yes. Give each task its own
`monitorStateKey` so their alert histories do not mix.

### Data source

Public Google Maps place and transit pages. The actor collects only information visible to a
logged-out visitor and is not affiliated with Google.

# Actor input Schema

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

What to collect. searchStations finds stations in a city; stationNames and stationUrls read named stations; departures returns the departure board; monitorAlerts returns only alerts that appeared or cleared since the previous run.

## `city` (type: `string`):

City, district or area to search, e.g. `New York`, `London`, `Berlin Mitte`. Used by mode=searchStations, and as a fallback in departures/monitorAlerts when no station names or URLs are given.

## `transitTypes` (type: `array`):

Transit types to search for (mode=searchStations, and the fallback in departures/monitorAlerts). Each selected type is searched in the city.

## `stationNames` (type: `array`):

Station names to look up (mode=stationNames, departures, monitorAlerts), e.g. `Times Sq-42 St`, `Oxford Circus`, `Alexanderplatz`. Add a city inside the name when it is ambiguous.

## `stationUrls` (type: `array`):

Google Maps place URLs (including share links), `ChIJ...` place IDs, or `0x...:0x...` feature IDs (mode=stationUrls, departures, monitorAlerts).

## `includeDepartures` (type: `boolean`):

Attach the upcoming departures Google publishes for each station to its station record (mode=searchStations, stationNames, stationUrls). The separate departures mode always returns departure rows.

## `maxDeparturesPerLine` (type: `integer`):

Maximum upcoming departures kept per line in a station record and returned per line in the departures mode.

## `maxLinesPerStation` (type: `integer`):

Maximum line entries kept per station. Large rail terminals can list hundreds of train numbers; raise this only when you need the full list.

## `includeLineColors` (type: `boolean`):

Resolve each line badge colour (hex) from Google's public line icon. Adds one cached request per unique line icon.

## `includeClearedAlerts` (type: `boolean`):

In mode=monitorAlerts, also emit a row when an alert present in the previous run is no longer shown.

## `monitorStateKey` (type: `string`):

Separate saved alert state for mode=monitorAlerts, so different tasks can monitor the same station independently. Keep the same value on every scheduled run.

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

Hard cap on emitted dataset rows: stations in station modes, departure rows in departures mode, change rows in monitorAlerts mode.

## Actor input object example

```json
{
  "mode": "searchStations",
  "city": "New York",
  "transitTypes": [
    "subway"
  ],
  "stationNames": [],
  "stationUrls": [],
  "includeDepartures": false,
  "maxDeparturesPerLine": 3,
  "maxLinesPerStation": 100,
  "includeLineColors": true,
  "includeClearedAlerts": true,
  "monitorStateKey": "default",
  "maxItems": 2
}
```

# Actor output Schema

## `stations` (type: `string`):

Dataset containing transit stations, departure rows or alert-change rows from Google Maps.

# 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 = {
    "mode": "searchStations",
    "city": "New York",
    "transitTypes": [
        "subway"
    ],
    "stationNames": [],
    "stationUrls": [],
    "includeDepartures": false,
    "maxDeparturesPerLine": 3,
    "maxLinesPerStation": 100,
    "includeLineColors": true,
    "includeClearedAlerts": true,
    "monitorStateKey": "default",
    "maxItems": 2
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlyth-forge/google-maps-transit-stations").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 = {
    "mode": "searchStations",
    "city": "New York",
    "transitTypes": ["subway"],
    "stationNames": [],
    "stationUrls": [],
    "includeDepartures": False,
    "maxDeparturesPerLine": 3,
    "maxLinesPerStation": 100,
    "includeLineColors": True,
    "includeClearedAlerts": True,
    "monitorStateKey": "default",
    "maxItems": 2,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlyth-forge/google-maps-transit-stations").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 '{
  "mode": "searchStations",
  "city": "New York",
  "transitTypes": [
    "subway"
  ],
  "stationNames": [],
  "stationUrls": [],
  "includeDepartures": false,
  "maxDeparturesPerLine": 3,
  "maxLinesPerStation": 100,
  "includeLineColors": true,
  "includeClearedAlerts": true,
  "monitorStateKey": "default",
  "maxItems": 2
}' |
apify call crawlyth-forge/google-maps-transit-stations --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,crawlyth-forge/google-maps-transit-stations"
        }
    }
}
```

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/DH4nS7jgHdkdebrOo/builds/ACyxADinZzc51QM77/openapi.json
