API Reference

Complete reference for all ForecastAPI endpoints, parameters, and response formats.

Base URL

https://forecastapi.com/v1

Authentication

Bearer YOUR_API_KEY

Endpoints

Generate Forecast

POST /forecast

Generate forecasts for your time series data with automatic model selection.

Request Body

{
  "data": [
    {"date": "2024-01", "value": 120},
    {"date": "2024-02", "value": 135},
    {"date": "2024-03", "value": 155}
  ],
  "periods": 6,
  "frequency": "M",
  "data_type": "sales",
  "confidence_level": 0.95
}

Parameters

Parameter Type Required Description
data array Yes Array of time series data points with date and value
periods integer Yes Number of forecast periods to generate (1-24)
frequency string Yes Data frequency: D, W, M, Q, Y, H
data_type string No Data type for optimized model selection. Default: "sales"
confidence_level float No Confidence level for intervals (0.8-0.99). Default: 0.95

Data Types

Specialized Types

Support intermittent demand patterns:

  • "sales" - Sales data
  • "demand" - Demand forecasting
  • "inventory" - Inventory levels
Generic Types

Use standard forecasting methods:

  • "web_traffic" - Website analytics
  • "cpu_usage" - System metrics
  • "revenue" - Financial data

Response

{
  "forecast": [
    {
      "date": "2024-04",
      "value": 168.5,
      "lower": 162.3,
      "upper": 174.7
    },
    {
      "date": "2024-05",
      "value": 175.2,
      "lower": 168.1,
      "upper": 182.3
    }
  ],
  "method": "exponential_smoothing",
  "confidence": 0.95,
  "analysis": {
    "pattern_type": "regular",
    "trend": "increasing",
    "seasonality": "none_detected",
    "characteristics": {
      "total_periods": 12,
      "non_zero_events": 12,
      "mean_value": 142.5,
      "coefficient_of_variation": 0.23
    }
  },
  "performance": {
    "response_time_ms": 287,
    "model_selection_time_ms": 45
  }
}

Response Fields

Field Type Description
forecast array Array of forecast periods with values and confidence intervals
method string Forecasting method that was automatically selected
confidence float Confidence level used for prediction intervals
analysis object Data pattern analysis and characteristics
performance object API performance metrics

Error Responses

HTTP Status Codes

400
Bad Request
Invalid request parameters or malformed JSON
401
Unauthorized
Invalid or missing API key
429
Too Many Requests
Rate limit exceeded
500
Internal Server Error
Server error during forecast generation

Error Response Format

{
  "error": {
    "code": "invalid_data_format",
    "message": "Data array must contain at least 3 data points",
    "details": {
      "received_points": 2,
      "minimum_required": 3
    }
  }
}

Next Steps