Skip to main content

AI Flight Intelligence API

Technical Docs Prediction Pricing & Demand B2B
Operated by Spyface Tech Company, LLC • Support: hello@spyface.com

What this API does

AI Flight Intelligence API provides measurable prediction and scoring signals for: fare movement, demand intensity, availability stability, and booking timing. It sits after your flight search results and before your UX decisions (sorting, badges, alerts, price-lock, re-check logic).

Legacy stacks: search → sort by price.
Spyface: search → predict → optimize UX + margin + trust.

Primary outcomes

  • Higher conversion by surfacing “bookable & stable” fares
  • Lower checkout failures (reprice, sold-out)
  • Better margins via timing & elasticity signals
  • Fewer support tickets from “price changed” complaints

1) Overview

Flights are not “lowest price wins”. They are dominated by volatility and availability fragility. The same fare can reprice during checkout, disappear after 30 seconds, or become irrationally expensive due to demand shocks. Spyface converts raw itineraries into actionable, testable intelligence.

Inputs

  • Itineraries (segments, carriers, fare brand, baggage)
  • Price breakdown + taxes + currency
  • Search context (market, device, channel)
  • Optional events (clicks, shortlist, checkout start)

Outputs

  • Fare movement prediction (up/down/stable) + confidence
  • Demand score (route/date pressure)
  • Availability stability score (risk of sold-out/reprice)
  • Booking timing recommendation (buy now vs wait)

No buzzwords

Each AI field is tied to a label and evaluation metric: AUC, calibration error (ECE), Brier score, Lift@K, and live “checkout-fail reduction”.

2) Quickstart

  1. POST your flight search results to /v1/flights/intelligence
  2. Use returned scores to sort, badge and decide re-check steps
  3. Optionally stream events to /v1/events for personalization

3) Authentication

Authorization: Bearer YOUR_SPYFACE_API_KEY

4) Endpoints

MethodEndpointPurpose
POST/v1/flights/intelligenceCompute flight prediction & scoring bundle
POST/v1/flights/fare-forecastPredict fare movement within horizon
POST/v1/flights/demand-scoreRoute/date demand pressure scoring
POST/v1/flights/stabilityAvailability + reprice risk scoring
POST/v1/eventsBehavior signals (view, click, shortlist, checkout)

5) Data Model

5.1 Intelligence Request

{
  "request_id": "req_20260125_fli_19c2",
  "search": {
    "origin": "IST",
    "destination": "JFK",
    "depart_date": "2026-03-12",
    "return_date": "2026-03-19",
    "adults": 1,
    "cabin": "ECONOMY",
    "currency": "USD"
  },
  "context": {
    "market": "US",
    "channel": "web",
    "device": "desktop"
  },
  "itineraries": [
    {
      "itinerary_id": "it_001",
      "segments": [
        {"from":"IST","to":"JFK","dep":"2026-03-12T10:20:00Z","arr":"2026-03-12T20:05:00Z","carrier":"TK","flight_no":"1"}
      ],
      "price": {"total": 720.40, "currency":"USD"},
      "fare_brand": "LIGHT",
      "bags": {"carry_on": 1, "checked": 0},
      "provider": {"name":"gds_x"}
    }
  ]
}

5.2 Intelligence Response

{
  "request_id": "req_20260125_fli_19c2",
  "generated_at": "2026-01-25T12:00:00Z",
  "results": [
    {
      "itinerary_id": "it_001",
      "scores": {
        "fare_movement_up": 0.62,
        "fare_movement_down": 0.10,
        "fare_stability": 0.71,
        "demand_pressure": 0.77,
        "availability_stability": 0.84,
        "reprice_risk": 0.16
      },
      "recommendations": {
        "timing": "BOOK_NOW",
        "badges": ["Price likely to rise", "High bookability"],
        "recheck_policy": "STANDARD"
      },
      "explanations": [
        {"code":"DEMAND_HIGH","detail":"Route/date shows elevated demand vs baseline"},
        {"code":"STABLE_PROVIDER","detail":"Low historical reprice rate for this provider"},
        {"code":"UPWARD_DRIFT","detail":"Short-horizon upward movement probability is high"}
      ]
    }
  ]
}

6) Signals & Definitions

SignalMeaningHow to use
fare_movement_up/downProbabilities for direction within horizon“Book now / wait” UX, alerts, price lock
fare_stabilityProbability price won’t jump in near termTop-rank stable fares for trust
demand_pressureRoute/date demand intensityScarcity messaging, merchandising
availability_stabilityProbability itinerary remains bookableReduce checkout failures, choose recheck policy
reprice_riskProbability price changes at checkoutTrigger “pre-price-check” or warning

7) Models (Measurable AI)

ModelOutputLabelsMetrics
Fare MovementUp/Down/Stable probsObserved price deltas over horizonAUC, Calibration (ECE), MAPE (bucketed)
Availability StabilityP(bookable at checkout)Success vs sold-out vs provider failBrier, Fail-rate reduction
Reprice RiskP(reprice event)Search→checkout price mismatch eventsPrecision/Recall, Lift@K
Demand Pressure0–1 intensity scoreSearch volume + bookings + seasonalityCorrelation w/ price drift, stability impact

8) Decision Patterns (How real teams use it)

Pattern A — Trust-first sorting

Sort by: availability_stability desc → fare_stability desc → price asc.

// pseudo
sortKey = 0.45*availability_stability + 0.35*fare_stability - 0.20*normalized_price

Pattern B — Checkout guardrails

  • if reprice_risk > 0.35 → run pre-price-check
  • if availability_stability < 0.60 → show backup fares in UI
  • if demand_pressure > 0.80 → compress results to “high confidence” subset

9) Code Examples

9.1 cURL

curl -X POST "https://api.spyface.com/v1/flights/intelligence" \
  -H "Authorization: Bearer YOUR_SPYFACE_API_KEY" \
  -H "Content-Type: application/json" \
  -d @flight-intel.json

9.2 Node.js

import fetch from "node-fetch";

const res = await fetch("https://api.spyface.com/v1/flights/intelligence", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SPYFACE_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

if (!res.ok) throw new Error(await res.text());
const data = await res.json();
console.log(data.results[0].recommendations);

9.3 Python

import os, requests

r = requests.post(
  "https://api.spyface.com/v1/flights/intelligence",
  headers={"Authorization": f"Bearer {os.environ['SPYFACE_API_KEY']}"},
  json=payload,
  timeout=10
)
r.raise_for_status()
print(r.json()["results"][0]["scores"])

10) Errors

HTTPMeaningAction
400Schema invalidValidate required fields
401UnauthorizedCheck Bearer token
429Rate limitedRetry with exponential backoff
500InternalRetry once, then contact support

11) Security

  • Do not send payment card data.
  • Minimize PII; use hashed user_id if needed.
  • Optional enterprise HMAC signing available.

Integration review

Send a sanitized search payload + your current sorting logic to hello@spyface.com. We’ll propose a measurable rollout plan (A/B, KPIs, guardrails).