# FlixBus Route & Price Scraper (`muhammadafzal/flixbus-route-price-scraper`) Actor

Extract current FlixBus routes, trip schedules, stations, availability, amenities, and prices for travel planning and fare research.

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

## Pricing

from $2.00 / 1,000 flixbus 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

## FlixBus Route & Price Scraper

Extract current FlixBus routes, schedules, stations, availability, amenities, and prices into a clean dataset for travel planning, fare monitoring, route research, and agent workflows.

The Actor resolves public city names through FlixBus's own autocomplete service and queries the page-owned trip search service used by the public booking flow. It does not require a FlixBus login and it does not make reservations.

### What it extracts

| Field group | Included data |
|---|---|
| Route | Origin/destination names and FlixBus IDs, departure and arrival stations |
| Schedule | Departure/arrival timestamps, total duration, direct/transfer status |
| Price | Total, original, platform-fee-inclusive amount, requested currency |
| Availability | Seat and bicycle availability when FlixBus discloses it, capacity indicator |
| Journey | Ordered legs, operators, transport type, amenities |
| Source | Search date, booking search URL, scrape timestamp |

Use it for comparing departures, collecting route snapshots, feeding a travel dashboard, or monitoring prices on supported public routes. Do not use it to book tickets, hold seats, access an account, bypass a challenge, or assume that a quoted fare remains available after the search time.

### Input

| Field | Required | Default | Notes |
|---|---:|---:|---|
| `fromCity` | Yes | `Berlin` | Exact public city name works best |
| `toCity` | Yes | `Munich` | Exact public city name works best |
| `departureDate` | No | tomorrow | `YYYY-MM-DD`, today or later |
| `days` | No | `1` | Search 1–14 consecutive dates |
| `adults` | No | `1` | 1–9 |
| `children` | No | `0` | 0–9 |
| `bikes` | No | `0` | 0–9 |
| `currency` | No | `EUR` | Three-letter ISO code |
| `locale` | No | `en` | Language such as `en`, `de`, or `fr` |
| `fromCountry`, `toCountry` | No | — | Two-letter codes for ambiguous city names |
| `directOnly` | No | `false` | Keep only one-leg itineraries |
| `sortBy` | No | `departure` | `departure`, `price`, or `duration` |
| `maxResults` | No | `50` | Total cap, 1–500 |
| `proxyConfiguration` | No | disabled | Optional Apify Proxy configuration |

Example:

```json
{
  "fromCity": "Berlin",
  "toCity": "Munich",
  "departureDate": "2026-09-15",
  "days": 3,
  "adults": 1,
  "currency": "EUR",
  "directOnly": false,
  "sortBy": "price",
  "maxResults": 25
}
```

Run it through the API after deployment:

```bash
curl -X POST "https://api.apify.com/v2/acts/YOUR_USERNAME~flixbus-route-price-scraper/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fromCity":"Berlin","toCity":"Munich","departureDate":"2026-09-15","maxResults":10}'
```

Keep tokens in secrets or authorization headers in production; do not commit them.

The five private example tasks can be recreated or reconciled with the Apify API
using `scripts/configure-tasks.mjs`:

```bash
APIFY_TOKEN="$APIFY_TOKEN" APIFY_ACTOR_ID="YOUR_ACTOR_ID" \
  node scripts/configure-tasks.mjs
```

The script always keeps those tasks private and never stores the token in the repository.

### Output

Each dataset row represents one itinerary on one requested date:

```json
{
  "tripId": "ic:...",
  "searchDate": "2026-09-15",
  "fromCity": "Berlin",
  "toCity": "Munich",
  "departureTime": "2026-09-15T07:15:00+02:00",
  "arrivalTime": "2026-09-15T17:35:00+02:00",
  "durationMinutes": 620,
  "durationText": "10h 20m",
  "direct": false,
  "price": 24.48,
  "priceWithPlatformFee": 25.47,
  "currency": "EUR",
  "availableSeats": 37,
  "amenities": ["WIFI", "POWER_SOCKETS"],
  "operators": ["FlixBus"],
  "bookingUrl": "https://shop.flixbus.com/search?..."
}
```

`SUMMARY` in the default key-value store classifies the outcome as `DATA`, `EMPTY`, `BLOCKED`, or `FAILED`, records resolved cities and searched dates, and lists warnings. An empty valid route is never replaced with fabricated dataset rows.

### Pay per event

| Event | Price | Trigger |
|---|---:|---|
| Actor start | $0.0005 | One run starts |
| FlixBus trip result | $0.002 | One validated row is written to the default dataset |

A run returning 25 trips costs about `$0.0505` in events. A valid empty search costs only the start event. Synthetic events are charged by Apify when live PPE is enabled; the Actor does not manually double-charge them. Final prices and availability can change between search and booking.

### Reliability and limits

Requests use the public FlixBus booking flow with consistent browser-like headers, three bounded attempts, exponential backoff, and one stable proxy session when a proxy is configured. HTTP 403, 429, upstream failures, and per-date errors remain visible in `SUMMARY`. The run preserves results from healthy dates if another date fails.

The Actor caps date ranges at 14 days and output at 500 records. FlixBus may return no sale inventory for near-term, distant, or unsupported routes. City names can be ambiguous; use country filters when needed. The integration relies on an undocumented public page-backing endpoint, so FlixBus can change it without notice.

### Legal and responsible use

Use public trip information responsibly and comply with FlixBus terms, applicable law, and reasonable request rates. This Actor is an independent data extraction tool and is not affiliated with, endorsed by, or sponsored by Flix SE. FlixBus is a trademark of its owner. Do not use the Actor to interfere with the service, circumvent access controls, or make automated purchasing decisions without independently verifying the live booking page.

# Actor input Schema

## `fromCity` (type: `string`):

Use this to choose the departure city by name, for example `Berlin`. Exact public FlixBus city names work best; this is not a station name.

## `toCity` (type: `string`):

Use this to choose the arrival city by name, for example `Munich`. Exact public FlixBus city names work best; this is not a station name.

## `departureDate` (type: `string`):

Use this for the first travel date in `YYYY-MM-DD` format, for example `2026-09-15`. Omit it to search tomorrow; it is not a return date.

## `days` (type: `integer`):

Use this to search consecutive dates starting at the departure date. Default 1; accepted range 1–14.

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

Use this for adult passenger pricing. Default 1; accepted range 1–9.

## `children` (type: `integer`):

Use this for child passengers included in the search. Default 0; accepted range 0–9.

## `bikes` (type: `integer`):

Use this to request bicycle availability. Default 0; accepted range 0–9.

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

Use this for the requested ISO 4217 price currency, for example `EUR`. FlixBus may normalize unsupported currencies.

## `locale` (type: `string`):

Use this for FlixBus city lookup and result language, for example `en`, `de`, or `fr`. Default `en`.

## `fromCountry` (type: `string`):

Use this optional ISO 3166-1 alpha-2 code to disambiguate cities, for example `US` for Portland. Leave empty when the city name is unique.

## `toCountry` (type: `string`):

Use this optional ISO 3166-1 alpha-2 code to disambiguate cities, for example `DE`. Leave empty when the city name is unique.

## `directOnly` (type: `boolean`):

Use this to keep only trips with one leg. Default false includes both direct and transfer options.

## `sortBy` (type: `string`):

Use this to order all returned trips by departure time, total price, or duration. Default `departure`.

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

Use this to cap the total dataset records across all dates. Default 50; accepted range 1–500.

## `proxyConfiguration` (type: `object`):

Use this only when direct public requests are restricted from your region. Apify Proxy settings are optional and do not change city selection.

## Actor input object example

```json
{
  "fromCity": "Berlin",
  "toCity": "Munich",
  "departureDate": "2026-09-15",
  "days": 1,
  "adults": 1,
  "children": 0,
  "bikes": 0,
  "currency": "EUR",
  "locale": "en",
  "directOnly": false,
  "sortBy": "departure",
  "maxResults": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Schema-validated FlixBus trip records.

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

Outcome, resolved cities, dates, 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 = {
    "fromCity": "Berlin",
    "toCity": "Munich",
    "departureDate": "2026-09-15"
};

// Run the Actor and wait for it to finish
const run = await client.actor("muhammadafzal/flixbus-route-price-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 = {
    "fromCity": "Berlin",
    "toCity": "Munich",
    "departureDate": "2026-09-15",
}

# Run the Actor and wait for it to finish
run = client.actor("muhammadafzal/flixbus-route-price-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 '{
  "fromCity": "Berlin",
  "toCity": "Munich",
  "departureDate": "2026-09-15"
}' |
apify call muhammadafzal/flixbus-route-price-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,muhammadafzal/flixbus-route-price-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/5AMHkEEOYIeLoAJTl/builds/EH99aEtwhGfx62b2P/openapi.json
