Developer Docs

Affinsy API Reference

Push order data, trigger MBA or RFM reports, and retrieve results programmatically. Perfect for integrating Affinsy into your data pipeline.

Base URL: https://www.affinsy.com/api/v1OpenAPI Spec (JSON)

Authentication

All endpoints require a Bearer token. Generate API keys in Dashboard → Integrations. API access requires the Max plan or higher.

curl https://www.affinsy.com/api/v1/datasets \
  -H "Authorization: Bearer afn_your_key_here"

Quick Start: The Automation Loop

The full automation flow in 4 steps: push data, trigger a report, receive a webhook, fetch results.

1

Push order data

curl -X POST https://www.affinsy.com/api/v1/data/orders \
  -H "Authorization: Bearer afn_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "dataset_id": "my-store",
    "orders": [
      {
        "order_id": "ORD-1001",
        "customer_id": "CUST-42",
        "order_date": "2025-03-15T10:30:00Z",
        "line_items": [
          { "product_name": "Running Shoes", "unit_price": 129.99, "quantity": 1 },
          { "product_name": "Sport Socks 3-Pack", "unit_price": 14.99, "quantity": 2 }
        ]
      }
    ]
  }'
2

Trigger a report

Use a template for pre-configured settings, or specify params manually.

# Using a template (simplest)
curl -X POST https://www.affinsy.com/api/v1/reports \
  -H "Authorization: Bearer afn_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "high_value_baskets",
    "dataset_id": "my-store",
    "webhook_url": "https://your-server.com/hooks/affinsy"
  }'

# Or with full control over parameters
curl -X POST https://www.affinsy.com/api/v1/reports \
  -H "Authorization: Bearer afn_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "report_type": "MBA",
    "name": "Q1 2025 Bundle Analysis",
    "dataset_id": "my-store",
    "webhook_url": "https://your-server.com/hooks/affinsy",
    "filters": {
      "dateRange": { "start": "2025-01-01", "end": "2025-03-31" }
    },
    "params": {
      "min_support": 0.02,
      "min_confidence": 0.15,
      "scope": "order",
      "customer_scope": "high_value"
    }
  }'

# Response: { "report_id": "abc123", "status": "Processing" }
3

Receive webhook (or poll)

# Affinsy POSTs to your webhook_url:
{
  "event": "report.completed",
  "report_id": "abc123",
  "report_type": "MBA",
  "status": "Completed",
  "timestamp": "2025-03-15T10:32:00Z"
}
4

Fetch results

curl https://www.affinsy.com/api/v1/reports/abc123 \
  -H "Authorization: Bearer afn_your_key"

# Returns full report with association rules, AI insights, etc.

Report Templates

Templates pre-configure analysis settings for common use cases. Pass a template ID instead of manually setting report_type and params. You can still override any param — explicit values take precedence.

Template IDTypeDescriptionCustomer Scope
standard_mbaMBAAll orders — full cross-sell & bundling insightsall
first_orderMBAGateway products that win new customersfirst_order
repeat_purchaseMBAWhat keeps customers coming backrepeat
high_value_basketsMBAWhat your top 20% by spend buy togetherhigh_value
churning_analysisMBAWin-back campaigns from lapsed customer historychurning
standard_rfmRFMSegment all customers by recency, frequency, monetaryall
new_customer_cohortRFMSegment customers acquired in last 90 daysnew_90d

Endpoints

Affinsy LogoAffinsy

AI-powered e-commerce analytics to increase AOV & LTV through smart bundling and customer segmentation.

Made with `ღ´ around the world by © 2026 Affinsy