MachinePortal API Documentation
    • Generate Token
      POST
    • Get KWH Data
      POST

      Get KWH Data

      POST
      /api/get_kwh_data
      Retrieve KWH (kilowatt-hour) consumption data based on various filters.
      Authentication: Required - Bearer token in Authorization header
      Parameters (all optional):
      startDate - Start date filter (format: Y-m-d or Y-m-d H:i:s)
      endDate - End date filter (format: Y-m-d or Y-m-d H:i:s)
      user_field_id - Filter by specific circuit/meter ID
      billing_period_id - Filter by specific billing period ID
      circuit_name - Filter by circuit name (partial match, case-insensitive)
      timeZone - Timezone for date conversion (default: 'UTC')
      include_totals - Include summary totals (default: false)
      Response includes:
      Total KWH consumption
      Peak and off-peak KWH breakdown
      Peak demand (kW)
      Cost breakdown (peak, off-peak, demand, fixed, tax)
      Total cost

      Request

      Header Params

      Body Params multipart/form-data

      Responses

      🟢200
      application/json
      Body

      🟠401
      🟠403
      Request Request Example
      Shell
      JavaScript
      Java
      Swift
      curl --location --request POST 'https://prod.your-api-server.com/api/get_kwh_data' \
      --header 'Accept: application/json' \
      --header 'Authorization: Bearer {{api_token}}' \
      --form 'startDate="2026-02-01"' \
      --form 'endDate="2026-02-10"' \
      --form 'timeZone="Asia/Karachi"' \
      --form 'include_totals="true"'
      Response Response Example
      200 - Success Response with Data
      {
          "success": true,
          "data": [
              {
                  "id": 1,
                  "billing_period_id": 5,
                  "user_field_id": 10,
                  "circuit_name": "Main Circuit",
                  "start_date": "2024-01-01 00:00:00",
                  "end_date": "2024-01-31 23:59:59",
                  "period_name": "January 2024",
                  "billing_type": "kWh",
                  "total_kWh": 1250.50,
                  "peak_kWh": 800.25,
                  "off_peak_kWh": 450.25,
                  "peak_demand_kW": 150.75,
                  "peak_cost": 120.50,
                  "off_peak_cost": 45.25,
                  "demand_cost": 30.00,
                  "fixed_charge": 20.00,
                  "tax_amount": 15.50,
                  "total_cost": 231.25,
                  "created_at": "2024-02-01 10:00:00"
              }
          ],
          "count": 1,
          "totals": {
              "total_kWh": 1250.50,
              "peak_kWh": 800.25,
              "off_peak_kWh": 450.25,
              "peak_demand_kW": 150.75,
              "peak_cost": 120.50,
              "off_peak_cost": 45.25,
              "demand_cost": 30.00,
              "fixed_charge": 20.00,
              "tax_amount": 15.50,
              "total_cost": 231.25
          },
          "message": "KWH data retrieved successfully."
      }
      Modified at 2026-03-11 16:25:07
      Previous
      Generate Token
      Built with