Documentation

Build on the PredictFlow API

Connect to the PredictFlow API from JavaScript, Python, or PHP. Get an API key, install an SDK, and make your first call in a few minutes. Every SDK is open source and verified against this same API - nothing here is aspirational.

Quickstart

1

Create an API key

From Settings → Security, create a personal access token. It authenticates as you, the same as your session login - the full key (pk_live_...) is shown once, so copy it immediately.

2

Install an SDK

Pick JavaScript, Python, or PHP - see SDKs below. No SDK for your language? Call the REST API directly with any HTTP client.

3

Make your first call

List your connected stores, then forecast a product:

JavaScript
import { PredictFlow } from '@predictflow/sdk';

const client = new PredictFlow({
  apiKey: process.env.PREDICTFLOW_API_KEY, // server-side only
});

const stores = await client.stores.list();
const forecast = await client.products.forecast(stores[0].id, {
  horizonDays: 30,
});

console.log(forecast.forecast_data);

Authentication

Every request authenticates with a Bearer token in the Authorization header:

curl https://predictflow.co/api/v1/stores \
  -H "Authorization: Bearer pk_live_..."
Server-side only. An API key authenticates as your full account - never ship it inside browser-side/client-side JavaScript where anyone viewing your page source could read it. Keep it in an environment variable on your server or backend function.

SDKs

Official, open-source, MIT-licensed. Each one is a thin, typed client verified directly against this API before every release.

JavaScript / TypeScript

@predictflow/sdk
v0.1.2
Install
npm install @predictflow/sdk
Example
import { PredictFlow } from '@predictflow/sdk';

const client = new PredictFlow({
  apiKey: process.env.PREDICTFLOW_API_KEY, // server-side only
});

const stores = await client.stores.list();
const forecast = await client.products.forecast(stores[0].id, {
  horizonDays: 30,
});

console.log(forecast.forecast_data);

Python

predictflow
v0.1.0
Install
pip install predictflow
Example
from predictflow import PredictFlow

client = PredictFlow(api_key="pk_live_...")  # or PREDICTFLOW_API_KEY env var

stores = client.stores.list()
forecast = client.products.forecast(stores[0]["id"], horizon_days=30)

print(forecast["forecast_data"])

PHP

predictflow/sdk
v0.1.0
Install
composer require predictflow/sdk
Example
use PredictFlow\Sdk\PredictFlow;

$client = new PredictFlow(apiKey: 'pk_live_...');

$stores = $client->stores->list();
$forecast = $client->products->forecast($stores[0]['id'], horizonDays: 30);

echo $forecast['forecast_data'];

REST API

Base URL:

https://predictflow.co/api/v1

Every SDK method wraps one of these endpoint groups - call them directly if there's no SDK for your language yet:

Stores

Connect Shopify/WooCommerce, trigger syncs, import CSV catalogs and orders.

Products

Catalog, inventory health, ABC analysis, forecasting, cost/margin, competitor prices.

Predictions

Monte Carlo simulation, stockout risk, and inventory policy for an existing forecast.

Analytics

KPIs, revenue trends, day-of-week seasonality, product growth, projections.

Pricing

Elasticity, optimization, simulation, cross-elasticity, batch repricing.

Scenarios

What-if scenario planning and side-by-side comparisons.

Alerts

Alert rules, templates, and evaluation history.

Exports

CSV/XLSX/PDF exports of products, sales, inventory, forecasts, reorder, dead stock.

Every method, parameter, and response field across these 8 groups is documented in an interactive reference - filtered to only this public surface, nothing internal:

Open full API reference ↗

Rate limits

300 requests per minute per API key. A 429 response includes a Retry-After header - every SDK reads it and backs off automatically on the retryable methods (GET/PUT/DELETE).

Errors

Non-2xx responses return JSON with a detail field. Validation errors (422) return an array of field-level messages rather than a single string - every SDK unwraps this into a readable error message automatically:

{
  "detail": [
    { "loc": ["query", "horizon_days"], "msg": "Input should be greater than 0", "type": "greater_than" }
  ]
}
401 / 403Authentication failed - check your API key.
404The resource doesn’t exist, or isn’t owned by your account.
400 / 422Request validation failed - see the message for which field.
429Too many requests - a Retry-After header, if present, says how long to wait.
5xxSomething went wrong on our end - safe to retry a GET/PUT/DELETE, not a POST/PATCH.

Ready to build?

Start your 14-day free trial, connect a store, and create your first API key from Settings.

Start free trial