Skip to content

Profit Analytics

Get comprehensive profit data including revenue, costs, margins, and trends for your e-commerce business.

GET /v1/profit/overview

Get high-level profit overview for a specific period.

Parameters

ParameterTypeRequiredDescription
periodstringNoPreset period: today, yesterday, 7d, 30d, 90d, all
startDatestringNoCustom start date (YYYY-MM-DD)
endDatestringNoCustom end date (YYYY-MM-DD)

Note: Either use period OR startDate/endDate, not both.

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/profit/overview?period=30d"

Response

json
{
  "success": true,
  "data": {
    "totalRevenue": 125000,
    "totalCost": 87500,
    "totalProfit": 37500,
    "profitMargin": 30.0,
    "adSpend": 15000,
    "roas": 8.33,
    "orderCount": 450,
    "avgOrderValue": 277.78,
    "period": {
      "start": "2024-01-01",
      "end": "2024-01-31"
    }
  }
}

Response Fields

FieldTypeDescription
totalRevenuenumberTotal revenue in SAR
totalCostnumberTotal costs (product + shipping + ads)
totalProfitnumberNet profit (revenue - costs)
profitMarginnumberProfit margin percentage
adSpendnumberTotal advertising spend
roasnumberReturn on ad spend (revenue / ad spend)
orderCountnumberNumber of orders
avgOrderValuenumberAverage order value

GET /v1/profit/daily

Get daily profit breakdown over time.

Parameters

ParameterTypeRequiredDescription
periodstringNo7d, 30d, 90d (default: 30d)
startDatestringNoCustom start date
endDatestringNoCustom end date

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/profit/daily?period=7d"

Response

json
{
  "success": true,
  "data": [
    {
      "date": "2024-01-25",
      "revenue": 4200,
      "cost": 2940,
      "profit": 1260,
      "profitMargin": 30.0,
      "adSpend": 500,
      "roas": 8.4,
      "orders": 15
    },
    {
      "date": "2024-01-24",
      "revenue": 3800,
      "cost": 2660,
      "profit": 1140,
      "profitMargin": 30.0,
      "adSpend": 450,
      "roas": 8.44,
      "orders": 13
    }
  ]
}

Get profit trends and growth metrics.

Parameters

ParameterTypeRequiredDescription
periodstringNo30d, 90d, 6m, 1y (default: 30d)
granularitystringNodaily, weekly, monthly (default: daily)

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/profit/trends?period=90d&granularity=weekly"

Response

json
{
  "success": true,
  "data": {
    "trends": [
      {
        "period": "Week 1 (Jan 1-7)",
        "revenue": 28000,
        "profit": 8400,
        "profitMargin": 30.0,
        "growth": 5.2
      },
      {
        "period": "Week 2 (Jan 8-14)",
        "revenue": 32000,
        "profit": 9600,
        "profitMargin": 30.0,
        "growth": 14.3
      }
    ],
    "summary": {
      "avgProfit": 9000,
      "avgGrowth": 9.75,
      "highestProfit": 9600,
      "lowestProfit": 8400
    }
  }
}

GET /v1/profit/products

Get profit breakdown by product.

Parameters

ParameterTypeRequiredDescription
periodstringNo7d, 30d, 90d, all (default: 30d)
sortBystringNoprofit, revenue, margin, quantity (default: profit)
orderstringNoasc, desc (default: desc)
limitnumberNoNumber of products to return (default: 100)

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/profit/products?period=30d&sortBy=profit&limit=10"

Response

json
{
  "success": true,
  "data": {
    "products": [
      {
        "id": "prod_123",
        "name": "Premium Laptop Bag",
        "sku": "LB-001",
        "revenue": 15000,
        "cost": 9000,
        "profit": 6000,
        "profitMargin": 40.0,
        "quantity": 50,
        "avgPrice": 300
      },
      {
        "id": "prod_456",
        "name": "Wireless Headphones",
        "sku": "WH-002",
        "revenue": 12000,
        "cost": 8400,
        "profit": 3600,
        "profitMargin": 30.0,
        "quantity": 80,
        "avgPrice": 150
      }
    ],
    "meta": {
      "total": 125,
      "showing": 10
    }
  }
}

GET /v1/profit/comparison

Compare profit across different time periods.

Parameters

ParameterTypeRequiredDescription
currentPeriodstringYesCurrent period to analyze
comparisonPeriodstringYesPeriod to compare against

Preset periods: today, yesterday, this_week, last_week, this_month, last_month, this_year, last_year

Example Request

bash
curl -H "Authorization: Bearer looha_your_api_key" \
  "https://api.looha.app/v1/profit/comparison?currentPeriod=this_month&comparisonPeriod=last_month"

Response

json
{
  "success": true,
  "data": {
    "current": {
      "period": "January 2024",
      "revenue": 125000,
      "profit": 37500,
      "profitMargin": 30.0,
      "orders": 450
    },
    "comparison": {
      "period": "December 2023",
      "revenue": 110000,
      "profit": 33000,
      "profitMargin": 30.0,
      "orders": 400
    },
    "changes": {
      "revenue": 13.64,
      "profit": 13.64,
      "profitMargin": 0.0,
      "orders": 12.5
    }
  }
}

Error Responses

400 Bad Request

json
{
  "success": false,
  "error": "Invalid period format. Use 7d, 30d, 90d, or all"
}

401 Unauthorized

json
{
  "success": false,
  "error": "Invalid or expired API key"
}

403 Forbidden

json
{
  "success": false,
  "error": "API access requires Pro plan subscription"
}

Use Cases

Daily Profit Tracking in Google Sheets

javascript
function fetchDailyProfit() {
  const API_KEY = PropertiesService.getScriptProperties().getProperty('LOOHA_API_KEY')

  const response = UrlFetchApp.fetch(
    'https://api.looha.app/v1/profit/overview?period=today',
    {
      headers: { 'Authorization': `Bearer ${API_KEY}` }
    }
  )

  const data = JSON.parse(response.getContentText())
  const sheet = SpreadsheetApp.getActiveSheet()

  sheet.appendRow([
    new Date(),
    data.data.totalRevenue,
    data.data.totalProfit,
    data.data.profitMargin
  ])
}

Track Top Profitable Products

python
import requests

API_KEY = 'looha_your_api_key'
response = requests.get(
    'https://api.looha.app/v1/profit/products',
    params={'period': '30d', 'sortBy': 'profit', 'limit': 5},
    headers={'Authorization': f'Bearer {API_KEY}'}
)

products = response.json()['data']['products']
for product in products:
    print(f"{product['name']}: {product['profit']} SAR profit")

Next: Ad Performance Analytics →

Profit analytics platform for Saudi e-commerce merchants