Skip to main content

Reports API

Endpoints untuk generate reports dan analytics.

GET /reports/sales

Get sales report.
GET /api/v1/reports/sales?start_date=2024-01-01&end_date=2024-01-31
Authorization: Bearer {token}
X-Merchant-ID: merchant_abc
Response:
{
  "data": {
    "total_sales": 50000000,
    "total_transactions": 1250,
    "average_transaction": 40000,
    "top_products": [
      {
        "product_id": "prod_123",
        "name": "Product A",
        "quantity_sold": 500,
        "revenue": 5000000
      }
    ]
  }
}

GET /reports/inventory

Get inventory report.
GET /api/v1/reports/inventory
Authorization: Bearer {token}

POST /reports/export

Export report to CSV/Excel.
POST /api/v1/reports/export
Authorization: Bearer {token}

{
  "report_type": "sales",
  "format": "csv",
  "start_date": "2024-01-01",
  "end_date": "2024-01-31"
}
Response:
{
  "data": {
    "download_url": "https://cdn.mstore.com/exports/sales_2024-01.csv",
    "expires_at": "2024-01-02T00:00:00Z"
  }
}