POST
/
v1
/
ai
/
prediction
import { JigsawStack } from "jigsawstack";

const jigsaw = JigsawStack({ apiKey: "your-api-key" });

const response = await jigsaw.prediction({
  "dataset": [
        {
              "date": "2023-01-01",
              "value": 353459
        },
        {
              "date": "2023-01-02",
              "value": 313734
        },
        {
              "date": "2023-01-03",
              "value": 333774
        },
        {
              "date": "2023-01-04",
              "value": 348636
        },
        {
              "date": "2023-01-05",
              "value": 278903
        }
  ],
  "steps": 3
})
{
  "success": true,
  "prediction": [
        {
              "date": "2023-01-08 00:00:00",
              "value": 315214.5625
        },
        {
              "date": "2023-01-07 00:00:00",
              "value": 320094.71875
        },
        {
              "date": "2023-01-06 00:00:00",
              "value": 316329.9375
        }
  ],
  "steps": 3
}

Request Parameters

Body

dataset
Array<object>
required

The dataset to make predictions on. This is an array of objects with keys date and value. See example below for more information.

  • Minimum: 5 data points
  • Maximum: 1000 data points

Note: The larger the dataset provided, the more accurate the predictions become. For best results, provide at least 20-30 data points with consistent intervals.

steps
number
default:"5"

The number of predictions to make. - Minimum: 1 - Maximum: 500

Sample Dataset

A dataset must be an array of object containing keys date and value.

type Dataset = {
  date: string,
  value: number | string,
};

const dataset: Array<Dataset> = [
  { date: "2023-01-01", value: 353459 },
  { date: "2023-01-02", value: 313734 },
  { date: "2023-01-03", value: 333774 },
  { date: "2023-01-04", value: 348636 },
  { date: "2023-01-05", value: 278903 },
];
x-api-key
string
required

Your JigsawStack API key

Response Structure

success
boolean

Indicates whether the call was successful.

prediction
Array<object>

Array of predicted data points. Each object contains: - date: Timestamp for the predicted point - value: Predicted value

steps
number

The number of predictions that were made.