Traffic forecasting.
The traffic-forecasting endpoint turns a historical traffic series into an infrastructure plan. It forecasts future traffic for a single series. From the forecast it derives scaling recommendations, per-period capacity analysis, traffic alerts for spikes and anomalies, and a cost-optimization summary. These results tell you whether to scale, how much, and when.
https://forecastapi.com/v2Bearer YOUR_API_KEYEndpoint
Supply your historical traffic series in data. Describe your current infrastructure and
thresholds in traffic_settings. The API returns a full plan. The endpoint forecasts
traffic automatically, so you do not call /forecast separately. The endpoint always runs
the forecast with data_type set to "web_traffic". This value selects methods
tuned for continuous, non-intermittent series.
Request Body
{
"identifier": "api-endpoint-users",
"frequency": "H",
"periods": 24,
"data": [
{"date": "2024-06-01 00:00:00", "value": 1200},
{"date": "2024-06-01 01:00:00", "value": 850},
{"date": "2024-06-01 02:00:00", "value": 620},
{"date": "2024-06-01 03:00:00", "value": 480},
{"date": "2024-06-01 04:00:00", "value": 520},
{"date": "2024-06-01 05:00:00", "value": 780},
{"date": "2024-06-01 06:00:00", "value": 1150},
{"date": "2024-06-01 07:00:00", "value": 1680}
],
"traffic_settings": {
"current_capacity": 2000,
"baseline_traffic": 1000,
"scaling_buffer": 0.2,
"scale_up_threshold": 0.8,
"scale_down_threshold": 0.3,
"alert_threshold": 1.5,
"anomaly_threshold": 3.0,
"cost_per_unit": 0.01,
"fixed_cost_per_capacity": 0.10,
"base_scaling_time": 5,
"enable_auto_scaling": false
}
}
Top-level Parameters
date (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS, consistent across the series) and a numeric value. The API sorts the series ascending automatically.H, D, W, M, MS, ME, Q, or Y. It also sets each period's real-time duration for breach dates and alert timestamps (e.g. H = 60 min). Most traffic forecasts use H or D.data.standard (default), advanced-quantized, advanced-patched, or auto. The auto option routes each identifier to the model that has proven most accurate on that series. It uses the same evidence that /forecast and /batch accumulate. On this endpoint the auto ensemble default runs as standard until a winning model emerges. See Model Options. Advanced variants and auto cost 25% more usage.forecast_data (0.10–0.99). Default: 0.80.auto (default), combined, mase, or smape. The semantics match those on /forecast."web_traffic" and ignores any value you send.traffic_settings Object
Only current_capacity and baseline_traffic are required. Every other field
is optional and uses the default shown. All values share the same unit as your traffic
series (requests, users, or RPS — whatever you supply).
alert_threshold).0.2 sizes capacity to 120% of the forecast peak.scale_up.scale_down. Between the two thresholds the action is maintain.baseline_traffic that triggers a traffic_spike alert. A value of 1.5 alerts at 150% of baseline.anomaly alert.estimated_time_to_scale).false and savings are possible, the response adds an enable_auto_scaling cost recommendation.Response
{
"result": {
"tenant_context": null,
"identifier": "api-endpoint-users",
"current_capacity": 2000,
"baseline_traffic": 1000,
"scaling_recommendations": {
"peak_traffic": 1920.00,
"average_traffic": 1245.50,
"current_utilization": 96.0,
"recommendations": [
{
"action": "scale_up",
"current_capacity": 2000,
"recommended_capacity": 2304,
"scaling_factor": 1.15,
"reason": "Peak traffic (1920) will exceed 80% of current capacity (2000)",
"urgency": "high",
"estimated_time_to_scale": 5
}
]
},
"capacity_analysis": {
"current_capacity": 2000,
"utilization_periods": [
{"period": 1, "traffic": 1200.00, "utilization": 60.0, "status": "normal"},
{"period": 2, "traffic": 1920.00, "utilization": 96.0, "status": "critical"}
],
"over_capacity_periods": 0,
"critical_periods": 4,
"forecast_duration_minutes": 1440,
"next_capacity_breach": "2024-06-01",
"capacity_efficiency": 72.5
},
"traffic_alerts": {
"total_alerts": 1,
"high_severity": 0,
"medium_severity": 1,
"alerts": [
{
"type": "traffic_spike",
"severity": "medium",
"period": 8,
"date": "2024-06-01 07:00:00",
"predicted_traffic": 1920.00,
"baseline_traffic": 1000,
"increase_factor": 1.92,
"message": "Traffic spike predicted: 1920 (1.9x baseline) at Jun 01, 07:00"
}
]
},
"cost_optimization": {
"current_cost": 498.80,
"optimized_cost": 510.00,
"potential_savings": -11.20,
"savings_percentage": -2.2,
"cost_breakdown": {
"fixed_cost": 200.00,
"variable_cost": 298.80
},
"recommendations": [
{
"type": "enable_auto_scaling",
"description": "Enable auto-scaling to save approximately $34.50 by dynamically adjusting capacity",
"potential_savings": 34.50
}
]
},
"forecast_data": [
{"period": 1, "date": "2024-06-01 08:00:00", "forecast": 1200.00, "lower": 1050.00, "upper": 1400.00},
{"period": 2, "date": "2024-06-01 09:00:00", "forecast": 1920.00, "lower": 1700.00, "upper": 2150.00}
]
},
"meta": {
"timing": { "validation": 8.5, "forecasting": 142.3, "total": 150.8 }
}
}
On success (HTTP 200) the response always has this single shape: a result
object with the plan and a meta object with timing. The numeric values above are
illustrative. Real figures come from the forecast. Both example arrays are truncated.
utilization_periods and forecast_data contain one entry per forecast period.
result Fields
null if you do not send one).traffic_settings.traffic_settings.scaling_recommendations Fields
peak_traffic ÷ current_capacity × 100.recommendations[] Fields
scale_up, scale_down, or maintain (see values below).ceil(peak × (1 + scaling_buffer)). For maintain it equals current capacity.recommended_capacity ÷ current_capacity. 1.0 for maintain.base_scaling_time. The API doubles it when the scaling factor exceeds 1.5 and triples it above 2.0.(current − recommended) × fixed_cost_per_capacity.action — possible values
| Value | Returned when | Extra field |
|---|---|---|
scale_up |
Peak utilization > scale_up_threshold. |
estimated_time_to_scale |
scale_down |
Peak utilization < scale_down_threshold. Recommended capacity never drops below 50% of current. |
potential_savings |
maintain |
Peak utilization is between the two thresholds. | — (none) |
urgency — possible values
| Value | Returned when |
|---|---|
critical |
scale_up and peak utilization > 100% (traffic already exceeds capacity). |
high |
scale_up and utilization > scale_up_threshold × 1.1. |
medium |
scale_up and utilization is just above scale_up_threshold. |
low |
Whenever the action is scale_down. |
none |
Whenever the action is maintain. |
capacity_analysis Fields
period, traffic, utilization (%), and a status label (see below).periods × period_duration (per the frequency).null if none.utilization_periods[].status — possible values
The API derives each period's status from its utilization (traffic ÷ capacity). It checks the conditions in order and the first match wins.
| Value | Condition |
|---|---|
over_capacity |
Utilization > 100% — forecast traffic exceeds capacity. |
critical |
Utilization > 90%. |
high |
Utilization > 70%. |
normal |
Utilization > 30%. |
low |
Utilization ≤ 30% — capacity is under-used. |
traffic_alerts Fields
severity: "high".severity: "medium".alerts[] — traffic_spike
The API emits this alert for any period where forecast > baseline_traffic × alert_threshold.
"traffic_spike"."high" when traffic > 2× baseline, otherwise "medium".YYYY-MM-DD HH:MM:SS).predicted_traffic ÷ baseline_traffic.alerts[] — anomaly
The API emits this alert for any period whose forecast is more than anomaly_threshold
standard deviations from the forecast mean. The anomaly alert shares period,
date, predicted_traffic, and message with the spike alert.
It differs on these fields:
"anomaly"."high" when the z-score > 4, otherwise "medium".baseline_traffic / increase_factor).cost_optimization Fields
Costs are relative to your inputs. They are only meaningful if you set realistic
cost_per_unit and fixed_cost_per_capacity values. "Optimized" cost sizes
capacity to ceil(peak × 1.1) (10% buffer).
current_capacity × fixed_cost_per_capacity + total_traffic × cost_per_unit.ceil(peak × 1.1) (variable cost unchanged).current_cost − optimized_cost. This value can be negative. A negative value means you are currently under-provisioned, and the "optimized" (safe) capacity costs more.potential_savings ÷ current_cost × 100.fixed_cost (capacity) and variable_cost (traffic served).cost_optimization.recommendations[] — possible entries
type |
Included when | Fields |
|---|---|---|
capacity_optimization |
potential_savings > 0 (you can safely shrink). |
description, current_capacity, recommended_capacity, potential_savings |
enable_auto_scaling |
enable_auto_scaling is false and estimated auto-scaling savings > 0. |
description, potential_savings |
forecast_data[] Fields
The raw traffic forecast that every section above uses. It contains one entry per forecast period.
YYYY-MM-DD, or YYYY-MM-DD HH:00:00 for hourly data).confidence_level).meta.timing
Server-side timing in milliseconds: validation (request checks), forecasting
(forecast + all infrastructure analysis), and total (whole request).
Reading the Plan
The four sections answer different questions. Use them together rather than in isolation:
| Section | Answers |
|---|---|
scaling_recommendations |
Should I resize, and to what? Start here — action and urgency tell you whether to act now. |
capacity_analysis |
When does capacity become tight? Watch next_capacity_breach and per-period status to time the change. |
traffic_alerts |
Where are the spikes and anomalies? Send these to on-call alerting. high_severity is a good paging trigger. |
cost_optimization |
What does it cost, and can I save? A negative potential_savings is a signal to scale up, not down. |
model consumes 25% more
usage, exactly as on the forecast endpoint. The same
rate limits apply.Error Responses
HTTP Status Codes
traffic_settings.current_capacity or baseline_traffic, a threshold outside its allowed range, a bad date format, or too many data points for your plan. The body lists per-field errors.422 Validation Error
{
"message": "The traffic_settings.current_capacity field is required.",
"errors": {
"traffic_settings.current_capacity": [
"The traffic_settings.current_capacity field is required."
]
}
}
500 Forecasting Error
{
"error": "Traffic forecasting failed",
"time_taken_ms": 42.7
}