# 888漫步旅遊 · 888travel - Full LLM & API Reference > Machine-readable specification and guide for AI Agents, autonomous planners, and automation systems integrating with 888travel. --- ## 1. System Architecture & Invariants 888travel is a privacy-first, single-tenant personal travel hub. All data is persisted in Cloudflare KV as a unified store. ### The Invariant Rules 1. **Manual Invariant**: Any segment created or updated via the Agent API is assigned `source: "manual"`. The background sync engine (which periodically scans Google Calendar and Gmail) will **NEVER** overwrite, modify, or delete manual plans. 2. **Category Fidelity**: Categories must strictly match one of the 7 supported values: - `flight` ✈️: Flight bookings, airport codes, flight numbers, terminals. - `hotel` 🏨: Accommodations, hotels, ryokans, villas, Airbnbs. - `restaurant` 🍽️: Dining, restaurants, cafes, food stalls, ramen shops, izakayas. - `rail` 🚆: Trains, high-speed rail (Shinkansen, TGV, ICE), subways, scenic railways. - `car` 🚗: Rental cars, car hire pick-up and drop-off. - `ride` 🚕: Taxi, airport pick-up, Uber, private chauffeur. - `other` 📍: Sightseeing attractions, theme parks, museum entries, appointments. 3. **Contingency / Fallback Plans**: Any segment can hold an embedded `fallback` object representing a backup alternative. If the primary plan is full, closed, or delayed, the user can switch to the fallback plan in 1 click in the UI, or agents can invoke `/swap-fallback`. 4. **Data Layer Purity**: Never localize data literals (e.g. store `"flight"`, not `"航班"`). UI and markdown formatters handle display localization. --- ## 2. Authentication External agents authenticate using an HTTP Bearer token in the `Authorization` header: ```http Authorization: Bearer rr_agent_ Content-Type: application/json ``` Agent keys are generated in the 888travel Web App (Settings -> AI Agent Integration). Tokens are prefixed with `rr_agent_` and can be regenerated or revoked at any time. --- ## 3. Data Schemas ### Trip Schema ```json { "id": "t_202610_tokyo", "from": "TPE", "to": "NRT", "start": "2026-10-15", "end": "2026-10-20", "label": "Tokyo Autumn Voyage", "notes": "Flight booked via BR198", "timezone": "Asia/Tokyo", "photo": "https://example.com/p.jpg", "segments": [], "updatedAt": 1729000000000 } ``` ### Segment Schema ```json { "sid": "s_123456", "type": "restaurant", "name": "Ichiran Ramen Shibuya", "address": "1-22-7 Jinnan, Shibuya", "note": "18:00 Dinner reservation", "start": "2026-10-15T18:00", "end": "2026-10-15T19:30", "conf": "RES-889900", "source": "manual", "rating": 4.5, "userRatingsTotal": 2450, "openNow": true, "mapsUrl": "https://maps.google.com/?cid=123", "placeId": "ChIJN1t_tDeuEmsRUsoyG83frY4", "fallback": { "name": "Afuri Ramen Harajuku", "address": "1-1-7 Jingumae, Shibuya", "note": "Backup option if Ichiran line exceeds 30 mins", "mapsUrl": "https://maps.google.com/?cid=456", "rating": 4.3, "userRatingsTotal": 1820 } } ``` ### Wishlist Item Schema ```json { "id": "w_98765", "from": "TPE", "dest": "KIX", "days": "6", "month": "November", "budget": "NT$35,000", "note": "Autumn maple season flight deals", "updatedAt": 1729000000000 } ``` --- ## 4. Comprehensive API Endpoints Specification ### 4.1 System & Diagnostics #### `GET /api/v1/status` Returns instance health, version, metric counts, and configured integrations. - **Request**: No body required. - **Response**: `200 OK` ### 4.2 Trips Management #### `GET /api/v1/trips` Retrieves all trips sorted chronologically by start date. #### `GET /api/v1/trips/:id` Retrieves single trip details by ID. #### `POST /api/v1/trips` Creates a new trip. #### `PUT /api/v1/trips/:id` Updates an existing trip's properties (`from`, `to`, `start`, `end`, `label`, `notes`, `timezone`, `photo`). #### `DELETE /api/v1/trips/:id` Deletes a trip and its itinerary. ### 4.3 Segments & Fallback Orchestration #### `POST /api/v1/trips/:id/segments` Appends one or more itinerary segments to an existing trip (single object or array of objects). #### `PUT /api/v1/trips/:id/segments/:sid` Updates an existing segment. #### `DELETE /api/v1/trips/:id/segments/:sid` Removes a segment from the trip and tombstones its confirmation reference. #### `POST /api/v1/trips/:id/segments/:sid/swap-fallback` 1-Click Contingency Swap: Swaps the active primary plan with its configured fallback alternative. ### 4.4 Google Places Discovery #### `POST /api/v1/places/search` Queries Google Places API for verified venues, ratings, review counts, and open status. - **Request Body**: `{ "query": "Ginza Kagari", "language": "zh-TW" }` #### `POST /api/v1/places/details` Retrieves detailed information for a specific Google Place ID. - **Request Body**: `{ "placeId": "ChIJ..." }` ### 4.5 Wishlist & Airfare Radar #### `GET /api/v1/wishes` Retrieves all tracked wishlist radar items. #### `POST /api/v1/wishes` Creates or updates a wishlist radar item. #### `DELETE /api/v1/wishes/:id` Deletes a tracked wishlist item. ### 4.6 Synchronization & Snapshots #### `POST /api/v1/sync` Triggers an immediate background synchronization pass with Google Calendar and Gmail. #### `GET /api/v1/backups` Lists all available weekly automated cloud snapshots and pre-restore snapshots. #### `GET /api/v1/export` Exports a full JSON snapshot of trips, wishes, and home configuration. ### 4.7 In-App AI Copilot Chat #### `POST /api/v1/copilot/chat` Allows external agents or companion tools to chat directly with 888travel's internal AI copilot with active trip context.