# GTFS Service Change Diff (`afkdigital/gtfs-service-change-diff`) Actor

Compare uploaded GTFS ZIP timetable releases with holiday, overnight, coverage and ID-review safeguards. Planned service only; no provider account.

- **URL**: https://apify.com/afkdigital/gtfs-service-change-diff.md
- **Developed by:** [AFK Digital](https://apify.com/afkdigital) (community)
- **Categories:** Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1,000.00 / 1,000 completed gtfs feed pair comparisons

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## GTFS Service Change Diff

Compare two uploaded GTFS Schedule ZIP files and investigate planned public transport changes with source-file and CSV-row evidence. Built by AFK Digital — NEWAPI99, version 0.1.1.

Use this Actor for timetable release QA, transport planning, feed revision review and passenger information preparation. It compares **planned schedules**, not actual operated trips, punctuality or GTFS Realtime. No transit data provider account, proxy or geocoding service is required.

### Quick start

Run the prefilled free demo to see a new stop, a holiday service removal and an overnight timetable change. For your own comparison, upload both ZIP files in the input form, select an inclusive date range of at most 31 service dates, and run. The file upload fields resolve to direct Apify key-value store record URLs. API callers can upload files to their own Apify KVS and pass those URLs. Private URLs must already grant access; the Actor never forwards its account credentials to a supplied URL. Redirects, local filesystem paths and arbitrary external websites are rejected.

Input example:

```json
{
  "baselineFeed": "https://api.apify.com/v2/key-value-stores/YOUR_STORE/records/baseline.zip",
  "candidateFeed": "https://api.apify.com/v2/key-value-stores/YOUR_STORE/records/candidate.zip",
  "comparisonDateFrom": "2026-12-24",
  "comparisonDateTo": "2026-12-26",
  "optionalIdMapping": {"trips": {"old_trip": "new_trip"}},
  "maxFindings": 10000
}
```

The reserved demo pair is `demo://baseline` and `demo://candidate`. Supply both real files together. Empty input runs only the bundled synthetic demo.

### What changes are reported?

- Route and stop additions, removals and supported attribute changes.
- Active trip additions/removals, stop sequences, pickup/drop-off flags, headsigns and clock-time changes on selected service dates.
- Service-day additions/removals after combining weekly calendar rules and date exceptions.
- First scheduled departure and last scheduled arrival by route, direction and service date.
- Frequency window/headway changes without generating individual departures, for both exact_times values.
- Coverage, timezone and ID matching review findings when a definite comparison would be misleading.

A service date remains the GTFS service date. For example, 25:10:00 belongs to the original service day even though the passenger boards after midnight. First/last times are numeric seconds from that service-day origin; 90600 means 25:10:00. Timezone changes are explicitly flagged for review; local clock values are not converted into UTC or actual trip timestamps.

An absent trip on a date can be a genuine planned service change inside comparable coverage. Dates outside either feed's declared/inferred coverage produce review findings. A shortened period for a matched service also produces review rather than a service reduction; affected route endpoint summaries are suppressed. Coverage is taken from feed_info when supplied and otherwise conservatively inferred from calendar/calendar_dates endpoints. Missing periods cannot prove a service cut.

### Identity rules

Stable IDs match exactly. optionalIdMapping accepts one-to-one baseline-to-candidate ID objects under `routes`, `stops`, `trips` and `services`. Trip references and parent stations are canonicalized for mapped routes/stops; service calendars are evaluated separately on each side.

When unmatched IDs exist on both sides of a namespace, unmatched entities are review candidates. Trip add/remove assertions and first/last summaries are conservatively suppressed in affected identity comparisons. There is no fuzzy automatic match. Supply explicit mappings and rerun. This can deliberately send simultaneous genuine additions and removals to review. Mappings never silently merge IDs.

### Output

The default Dataset contains one row per finding with:

| Field | Meaning |
|---|---|
| change_id | Deterministic finding identifier |
| entity_type | route, stop, trip, service_day, route_service_day, frequency, coverage or agency |
| route_id / stop_id / trip_id | Relevant ID, using baseline identity for mapped records |
| service_date | Original service date, or empty for feed-wide metadata |
| change_type | Specific change or review reason |
| old_value / new_value | Structured before/after values; null for absent side |
| match_confidence | exact_id, explicit_mapping or review_required; never a probability |
| evidence_files_rows | baseline/candidate, original file name and 1-based CSV record row, with header at row 1 |

CSV row references count parsed CSV records, not physical text lines when a quoted field spans lines. Evidence includes calendar and exception rows alongside relevant trips and stop times.

Key-value store downloads: `SUMMARY` (counts, coverage, limits, status and warnings), `RESULT` (summary and findings), `changes.json` and `changes.csv`. Native Dataset JSON/CSV export is also available. Nested CSV values use JSON; formula-like scalar cells are prefixed with an apostrophe for spreadsheet safety. Zero-change comparisons return an empty Dataset plus a completed summary.

maxFindings caps returned findings, not comparison work. SUMMARY reports total_findings, returned_findings and truncated. Review findings do not assert actual service reductions. A hard safety limit rejects the run rather than returning an apparently complete comparison.

### Supported GTFS subset

Validated against the official [GTFS Schedule reference](https://gtfs.org/documentation/schedule/reference/) on 2026-11-14. This is a fixed-stop Schedule comparison tool, **not a complete GTFS conformance validator**.

| File | v1 use |
|---|---|
| agency.txt | Required identity metadata and timezone validation; changed timezone sets trigger review |
| routes.txt | IDs, agency reference value, names, type, description, URL and colors |
| stops.txt | IDs, code, name, description, coordinates, zone, URL, location type, parent station, wheelchair boarding and platform |
| trips.txt | IDs, route, service, headsign, short name, direction, block, shape ID, wheelchair and bike flags |
| stop_times.txt | Trip/stop IDs, sequence, arrival/departure, headsign, pickup/drop-off, timepoint, shape distance |
| calendar.txt | Weekday flags and inclusive start/end dates |
| calendar_dates.txt | Per-date add/remove overrides; may provide the entire calendar |
| frequencies.txt | start/end times, positive headway and exact_times; windows are not expanded |
| feed_info.txt | Coverage boundaries; metadata is retained for validation, not a separate metadata diff |

The exact field manifest is in artifacts/supported-fields.json. Unknown columns do not enter comparison signatures. Unknown files are listed in SUMMARY. Fares, shape geometry, transfers, pathways, translations, levels, booking rules, Flex zones/windows and realtime are not compared. Flex stop-time records are explicitly rejected. Interpolated intermediate stop times remain blank rather than being invented. GTFS hours up to 999 are accepted as a resource-bounded v1 subset.

ZIP tables must be at the archive root, UTF-8 (optional BOM), comma-separated. The supported v1 requires nonempty agency, routes, stops, trips and stop_times plus calendar and/or calendar_dates. Referential integrity, duplicate entity/sequence/exception keys, calendar flags, coordinates, monotonic supplied times, endpoint times and nonoverlapping frequency windows are checked. Extended/demand-responsive feeds outside this subset may be rejected even when valid under the wider specification.

### Limits and proposed billing

One billable `feed-pair-completed` event means one completed comparison of two uploaded files within **all** these limits:

| Limit | Maximum |
|---|---:|
| Compressed ZIP | 20 MiB each |
| Declared expanded ZIP content | 100 MiB each |
| Archive members | 40 each |
| Parsed supported CSV records | 500,000 each |
| Inclusive comparison period | 31 service dates |
| Combined trips × selected dates | 2,000,000 |
| Returned findings | 100,000 |
| Serialized returned finding payload | 25 MiB |
| Core computation deadline | 180 seconds |

Owner-approved launch price: **USD 1.00 per completed uploaded feed pair**. No per-finding, per-trip or per-date fee. The bundled synthetic demo does not emit the comparison charge. Zero-change and review-only completed customer comparisons count as one pair. Rejected/failed input does not emit a comparison event.

Configure PPE with this single primary custom event; remove synthetic startup and Dataset-item charges for the stated completed-pair-only offer. PPE+usage must remain off for a fixed event-only customer price. The owner approved this price and paid publication on 2026-11-14. Further price changes require approval. Code charges only after Dataset and downloadable artifacts have been persisted.

Official [PPE documentation](https://docs.apify.com/actors/monetize/pay-per-event) supports custom completion events. [Current cost documentation](https://docs.apify.com/actors/monetize/pricing-and-costs) lists USD 0.20/CU at the Free/Bronze tier and USD 0.005 per 1,000 Dataset writes. At a configured 2 GiB and 180 seconds, compute alone is approximately USD 0.020; 100,000 Dataset writes add approximately USD 0.50, before storage/transfer and the revenue share. Actual usage must be checked from run records; this is not a measured maximum. Author revenue is modeled as 80% of event revenue minus platform usage costs under current PPE documentation.

### Development and verification

All implementation lives in /opt/NEWAPI/NEWAPI99 on adf-netcup-01. Run:

```sh
python3 -m unittest discover -s tests -v
python3 prepare.py
docker build -t afk-newapi99:0.1.0 .
docker run --rm afk-newapi99:0.1.0
```

The Docker run with empty input exercises the bundled demo and creates local SDK storage inside the disposable container. Automated tests cover holidays, dates-only calendars, midnight-crossing trips, regenerated IDs, explicit mapping, new stops, service deletion, shortened coverage, frequency windows, broken references, malformed times and archive/resource safety. Cloud validation evidence is stored under artifacts after deployment. A run budget below one completed pair stops before processing customer files.

### Data handling

Only supplied files and the bundled demo are processed. No feed discovery, external data enrichment or provider login is performed. Inputs/outputs remain subject to the user's Apify storage retention and access settings. Evidence can contain supplied route and stop descriptions. Keep upload record URLs private when they include access tokens.

# Actor input Schema

## `baselineFeed` (type: `string`):

Upload a root-level GTFS Schedule ZIP (20 MiB maximum). API: direct Apify KVS record URL. Demo token runs the bundled free pair.

## `candidateFeed` (type: `string`):

Upload a root-level GTFS Schedule ZIP (20 MiB maximum). API: direct Apify KVS record URL. Demo token runs the bundled free pair.

## `comparisonDateFrom` (type: `string`):

Inclusive service date, YYYY-MM-DD. Maximum 31 days per comparison.

## `comparisonDateTo` (type: `string`):

Inclusive service date, YYYY-MM-DD. Maximum 31 days per comparison.

## `optionalIdMapping` (type: `object`):

Old IDs to candidate IDs under routes, stops, trips, services. One-to-one only. Unmatched IDs on both sides are review candidates.

## `maxFindings` (type: `integer`):

1–100000. The full comparison is counted; output truncation is explicit in SUMMARY.

## Actor input object example

```json
{
  "baselineFeed": "demo://baseline",
  "candidateFeed": "demo://candidate",
  "comparisonDateFrom": "2026-12-24",
  "comparisonDateTo": "2026-12-26",
  "optionalIdMapping": {},
  "maxFindings": 10000
}
```

# Actor output Schema

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

No description

## `result` (type: `string`):

No description

## `csv` (type: `string`):

No description

## `json` (type: `string`):

No description

## `dataset` (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 = {
    "baselineFeed": "demo://baseline",
    "candidateFeed": "demo://candidate",
    "comparisonDateFrom": "2026-12-24",
    "comparisonDateTo": "2026-12-26"
};

// Run the Actor and wait for it to finish
const run = await client.actor("afkdigital/gtfs-service-change-diff").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 = {
    "baselineFeed": "demo://baseline",
    "candidateFeed": "demo://candidate",
    "comparisonDateFrom": "2026-12-24",
    "comparisonDateTo": "2026-12-26",
}

# Run the Actor and wait for it to finish
run = client.actor("afkdigital/gtfs-service-change-diff").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 '{
  "baselineFeed": "demo://baseline",
  "candidateFeed": "demo://candidate",
  "comparisonDateFrom": "2026-12-24",
  "comparisonDateTo": "2026-12-26"
}' |
apify call afkdigital/gtfs-service-change-diff --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,afkdigital/gtfs-service-change-diff"
        }
    }
}
```

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/g6smD9BScLGIc5GQC/builds/MfN2gGjF9Ma6W2TyG/openapi.json
