# Itinerary Scheduler Api (`intimate_axinite/itinerary-scheduler-api`) Actor

- **URL**: https://apify.com/intimate_axinite/itinerary-scheduler-api.md
- **Developed by:** [Yang Cai](https://apify.com/intimate_axinite) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 schedule itineraries

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?

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

## Deterministic Travel Itinerary & Opening-Hours Scheduler (API + MCP)

Zero-LLM, deterministic travel itinerary constraint solver built for **AI Travel Agents**, **Apify Store (Standby + Input Runs + MCP)**, **RapidAPI**, **Smithery / Glama**, and **n8n / Make workflows**.

LLMs are great at recommending places, and terrible at scheduling them: they book museums on Monday closing days, bounce travelers back and forth across town, ignore winter vs. summer sunset times, and overpack afternoons.

This engine solves those constraints deterministically in milliseconds with **zero external API cost**:

- **Geographic Clustering & 2-opt / Or-opt Optimization** — exact permutation solver for up to 7 stops/day, automatically inferring `walk` / `transit` / `drive` / `scooter` / `bike` modes.
- **Weekly Closing-Day Avoidance** — permutes multi-day stretches so museums and sights land on days they are actually open.
- **Google + OpenStreetMap Opening-Hours Parser** — accepts both Google `weekdayDescriptions` arrays and OSM `opening_hours` strings (`"Tu-Su 09:30-18:00; Mo off"`).
- **NOAA Solar Sunset Alignment** — schedules viewpoints and rooftops ~1 hour before true local sunset with IANA timezone & DST resolution.
- **Realistic Pacing & Rainy-Day Backups** — `relaxed` / `balanced` / `full` load budgets, major-museum queue buffers, lunch breaks, multi-stay moving days, and indoor backup recommendations.
- **Explainable Unscheduled Pool & Quality Telemetry** — structured reason codes (`closed`, `far`, `day-full`, `similar`, `lodging`, `duplicate`, `other-area`) plus `planQuality` metrics.

***

### Tools (MCP & REST)

| MCP Tool | REST Endpoint | Purpose |
|---|---|---|
| `schedule_itinerary` | `POST /v1/itineraries/schedule` | Build a conflict-free multi-day itinerary from 1–100 candidate places |
| `retime_itinerary` | `POST /v1/itineraries/retime` | Recompute exact clocks & opening-hours conflicts for a fixed stop order |
| `parse_opening_hours` | `POST /v1/hours/parse` | Parse Google or OSM opening hours into structured weekday windows + open-at-time checks |
| `compute_sunset` | `POST /v1/sun/sunset` | Compute local solar sunset, golden hour start, and IANA timezone |

Additional system endpoints: `GET /v1/health`, `GET /openapi.json`, and `POST /mcp` (Streamable HTTP JSON-RPC 2.0).

***

### Installation

#### 1. Remote MCP (Apify Standby or Cloudflare Workers)

Connect any Streamable HTTP MCP client (Claude Desktop, Cursor, Windsurf, Smithery, Apify MCP):

```json
{
  "mcpServers": {
    "itinerary-scheduler": {
      "url": "https://intimate-axinite--itinerary-scheduler-api.apify.actor/mcp",
      "headers": {
        "Authorization": "Bearer <YOUR_APIFY_TOKEN>"
      }
    }
  }
}
```

Available on [Apify Store](https://apify.com/intimate_axinite/itinerary-scheduler-api) and RapidAPI Hub.

#### 2. Local Stdio MCP (Claude Desktop / Cursor)

```bash
git clone https://github.com/ladyissy/itinerary-scheduler-api.git
cd itinerary-scheduler-api
npm install
```

```json
{
  "mcpServers": {
    "itinerary-scheduler": {
      "command": "node",
      "args": ["--experimental-strip-types", "/path/to/itinerary-scheduler-api/src/mcp-stdio.ts"]
    }
  }
}
```

#### 3. Docker / Self-Hosted HTTP Server

```bash
docker build -t itinerary-scheduler .
docker run -p 8787:8787 itinerary-scheduler
```

***

### Usage

#### REST API (`curl`)

```bash
curl -s http://localhost:8787/v1/itineraries/schedule \
  -H 'Content-Type: application/json' \
  -d '{
    "days": 2,
    "pace": "balanced",
    "startDate": "2026-05-11",
    "places": [
      {
        "id": "louvre",
        "name": "Louvre Museum",
        "latitude": 48.8606,
        "longitude": 2.3376,
        "category": "Museum",
        "city": "Paris",
        "country": "France",
        "reviews": 320000,
        "hours": ["Monday: 9:00 AM – 6:00 PM", "Tuesday: Closed", "Wednesday: 9:00 AM – 9:00 PM"]
      },
      {
        "id": "orsay",
        "name": "Musée d\u2019Orsay",
        "latitude": 48.86,
        "longitude": 2.3266,
        "category": "Museum",
        "city": "Paris",
        "country": "France",
        "reviews": 95000,
        "hours": "Tu-Su 09:30-18:00; Mo off"
      },
      {
        "id": "arc",
        "name": "Arc de Triomphe Viewpoint",
        "latitude": 48.8738,
        "longitude": 2.295,
        "category": "Viewpoint",
        "city": "Paris",
        "country": "France",
        "reviews": 210000
      }
    ]
  }' | jq .
```

#### MCP Streamable HTTP (`POST /mcp`)

```bash
curl -s -X POST http://localhost:8787/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | jq .
```

#### Apify Actor Modes

This Actor works in **both** modes automatically:

- **Standby / Server + MCP Mode** (`usesStandbyMode: true`, `webServerMcpPath: "/mcp"`, `webServerSchema: "../openapi.json"`): real-time REST & MCP with Pay-Per-Event billing (`schedule-itinerary`, `retime-itinerary`, `utility-call`) and multi-tenant `X-Actor-Request-ID` support.
- **Standard Input Run Mode** (Apify Console / n8n / Make): reads JSON input from the Input tab, computes the itinerary, and writes the structured result to the default Dataset and `OUTPUT` Key-Value Store record.

See [docs/APIFY_MCP_LAUNCH.md](docs/APIFY_MCP_LAUNCH.md) and [docs/LAUNCH_COPY.md](docs/LAUNCH_COPY.md) for deployment checklists.

# Actor input Schema

## `action` (type: `string`):

Operation to perform in standard run mode.

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

Number of days to schedule (1–14).

## `pace` (type: `string`):

Controls stop budget, daily load, lunch break length, and end time.

## `startDate` (type: `string`):

Enables weekly closing-day avoidance, opening-hours validation, and exact local solar sunset alignment.

## `transport` (type: `string`):

Transport mode override, or auto to infer walk / metro / drive from spatial density.

## `lookStyle` (type: `string`):

Adjusts dwell time per stop (linger +10-20%, quick -20-40%).

## `places` (type: `array`):

1–100 places with name, latitude, longitude, and optional category, city, country, rating, reviews, and hours (Google weekdayDescriptions or OSM opening_hours string).

## `stays` (type: `array`):

Optional single or multi-stay accommodations with { latitude, longitude, label, nights }.

## `mustDoIds` (type: `array`):

IDs of places that must be included in the itinerary.

## `routing` (type: `object`):

Set { "enabled": true } to fetch real street-level OSRM walking times (with automatic haversine fallback).

## Actor input object example

```json
{
  "action": "schedule",
  "days": 2,
  "pace": "balanced",
  "startDate": "2026-05-11",
  "transport": "auto",
  "lookStyle": "standard",
  "places": [
    {
      "id": "louvre",
      "name": "Louvre Museum",
      "latitude": 48.8606,
      "longitude": 2.3376,
      "category": "Museum",
      "city": "Paris",
      "country": "France",
      "reviews": 320000,
      "rating": 4.7,
      "hours": [
        "Monday: 9:00 AM – 6:00 PM",
        "Tuesday: Closed",
        "Wednesday: 9:00 AM – 9:00 PM",
        "Thursday: 9:00 AM – 6:00 PM",
        "Friday: 9:00 AM – 9:00 PM",
        "Saturday: 9:00 AM – 6:00 PM",
        "Sunday: 9:00 AM – 6:00 PM"
      ]
    },
    {
      "id": "orsay",
      "name": "Musée d'Orsay",
      "latitude": 48.86,
      "longitude": 2.3266,
      "category": "Museum",
      "city": "Paris",
      "country": "France",
      "reviews": 95000,
      "rating": 4.8,
      "hours": "Tu-Su 09:30-18:00; Mo off"
    },
    {
      "id": "flore",
      "name": "Café de Flore",
      "latitude": 48.854,
      "longitude": 2.3325,
      "category": "Cafe",
      "city": "Paris",
      "country": "France",
      "reviews": 18000,
      "rating": 4.2
    },
    {
      "id": "arc",
      "name": "Arc de Triomphe Rooftop Viewpoint",
      "latitude": 48.8738,
      "longitude": 2.295,
      "category": "Viewpoint",
      "city": "Paris",
      "country": "France",
      "reviews": 210000,
      "rating": 4.7
    }
  ]
}
```

# Actor output Schema

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

Dataset containing the structured itinerary, day-by-day schedule, unscheduled explanations, and planQuality telemetry.

## `outputJson` (type: `string`):

Complete raw JSON response stored as the OUTPUT record in the default Key-Value Store.

# 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 = {
    "places": [
        {
            "id": "louvre",
            "name": "Louvre Museum",
            "latitude": 48.8606,
            "longitude": 2.3376,
            "category": "Museum",
            "city": "Paris",
            "country": "France",
            "reviews": 320000,
            "rating": 4.7,
            "hours": [
                "Monday: 9:00 AM – 6:00 PM",
                "Tuesday: Closed",
                "Wednesday: 9:00 AM – 9:00 PM",
                "Thursday: 9:00 AM – 6:00 PM",
                "Friday: 9:00 AM – 9:00 PM",
                "Saturday: 9:00 AM – 6:00 PM",
                "Sunday: 9:00 AM – 6:00 PM"
            ]
        },
        {
            "id": "orsay",
            "name": "Musée d'Orsay",
            "latitude": 48.86,
            "longitude": 2.3266,
            "category": "Museum",
            "city": "Paris",
            "country": "France",
            "reviews": 95000,
            "rating": 4.8,
            "hours": "Tu-Su 09:30-18:00; Mo off"
        },
        {
            "id": "flore",
            "name": "Café de Flore",
            "latitude": 48.854,
            "longitude": 2.3325,
            "category": "Cafe",
            "city": "Paris",
            "country": "France",
            "reviews": 18000,
            "rating": 4.2
        },
        {
            "id": "arc",
            "name": "Arc de Triomphe Rooftop Viewpoint",
            "latitude": 48.8738,
            "longitude": 2.295,
            "category": "Viewpoint",
            "city": "Paris",
            "country": "France",
            "reviews": 210000,
            "rating": 4.7
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("intimate_axinite/itinerary-scheduler-api").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 = { "places": [
        {
            "id": "louvre",
            "name": "Louvre Museum",
            "latitude": 48.8606,
            "longitude": 2.3376,
            "category": "Museum",
            "city": "Paris",
            "country": "France",
            "reviews": 320000,
            "rating": 4.7,
            "hours": [
                "Monday: 9:00 AM – 6:00 PM",
                "Tuesday: Closed",
                "Wednesday: 9:00 AM – 9:00 PM",
                "Thursday: 9:00 AM – 6:00 PM",
                "Friday: 9:00 AM – 9:00 PM",
                "Saturday: 9:00 AM – 6:00 PM",
                "Sunday: 9:00 AM – 6:00 PM",
            ],
        },
        {
            "id": "orsay",
            "name": "Musée d'Orsay",
            "latitude": 48.86,
            "longitude": 2.3266,
            "category": "Museum",
            "city": "Paris",
            "country": "France",
            "reviews": 95000,
            "rating": 4.8,
            "hours": "Tu-Su 09:30-18:00; Mo off",
        },
        {
            "id": "flore",
            "name": "Café de Flore",
            "latitude": 48.854,
            "longitude": 2.3325,
            "category": "Cafe",
            "city": "Paris",
            "country": "France",
            "reviews": 18000,
            "rating": 4.2,
        },
        {
            "id": "arc",
            "name": "Arc de Triomphe Rooftop Viewpoint",
            "latitude": 48.8738,
            "longitude": 2.295,
            "category": "Viewpoint",
            "city": "Paris",
            "country": "France",
            "reviews": 210000,
            "rating": 4.7,
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("intimate_axinite/itinerary-scheduler-api").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 '{
  "places": [
    {
      "id": "louvre",
      "name": "Louvre Museum",
      "latitude": 48.8606,
      "longitude": 2.3376,
      "category": "Museum",
      "city": "Paris",
      "country": "France",
      "reviews": 320000,
      "rating": 4.7,
      "hours": [
        "Monday: 9:00 AM – 6:00 PM",
        "Tuesday: Closed",
        "Wednesday: 9:00 AM – 9:00 PM",
        "Thursday: 9:00 AM – 6:00 PM",
        "Friday: 9:00 AM – 9:00 PM",
        "Saturday: 9:00 AM – 6:00 PM",
        "Sunday: 9:00 AM – 6:00 PM"
      ]
    },
    {
      "id": "orsay",
      "name": "Musée d'\''Orsay",
      "latitude": 48.86,
      "longitude": 2.3266,
      "category": "Museum",
      "city": "Paris",
      "country": "France",
      "reviews": 95000,
      "rating": 4.8,
      "hours": "Tu-Su 09:30-18:00; Mo off"
    },
    {
      "id": "flore",
      "name": "Café de Flore",
      "latitude": 48.854,
      "longitude": 2.3325,
      "category": "Cafe",
      "city": "Paris",
      "country": "France",
      "reviews": 18000,
      "rating": 4.2
    },
    {
      "id": "arc",
      "name": "Arc de Triomphe Rooftop Viewpoint",
      "latitude": 48.8738,
      "longitude": 2.295,
      "category": "Viewpoint",
      "city": "Paris",
      "country": "France",
      "reviews": 210000,
      "rating": 4.7
    }
  ]
}' |
apify call intimate_axinite/itinerary-scheduler-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,intimate_axinite/itinerary-scheduler-api"
        }
    }
}
```

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/1ZGBJjNj72rptnSq4/builds/vvJRrjGNuh7TBhZRC/openapi.json
