> ## Documentation Index
> Fetch the complete documentation index at: https://docs.steerai.autos/llms.txt
> Use this file to discover all available pages before exploring further.

# Mechanical Diagnostics API

> OBD-II integration and comprehensive mechanical health analysis

## POST /v1/inspections/mechanical

Perform comprehensive mechanical diagnostics using OBD-II data, sensor readings, and AI-powered analysis. Detect engine issues, transmission problems, brake wear, and more.

### Request

```bash theme={null}
curl -X POST "https://api.steerai.autos/v1/inspections/mechanical" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "vehicle_id": "veh_1234567890abcdef",
    "obd_data": {
      "dtcs": ["P0420", "P0171"],
      "live_data": {
        "engine_rpm": 850,
        "coolant_temp": 92,
        "intake_temp": 25,
        "maf_rate": 3.2,
        "throttle_position": 0,
        "fuel_pressure": 380,
        "o2_sensor_voltage": 0.45,
        "timing_advance": 15
      },
      "freeze_frame": {
        "P0420": {
          "engine_rpm": 2800,
          "vehicle_speed": 65,
          "coolant_temp": 95
        }
      }
    },
    "test_results": {
      "battery_voltage": 12.6,
      "alternator_output": 14.2,
      "brake_fluid_level": "ok",
      "engine_oil_level": "ok",
      "coolant_level": "ok",
      "transmission_fluid": "ok"
    },
    "options": {
      "include_recommendations": true,
      "severity_threshold": "minor"
    }
  }'
```

### Request Body

| Field                             | Type    | Required | Description                                                                  |
| --------------------------------- | ------- | -------- | ---------------------------------------------------------------------------- |
| `vehicle_id`                      | string  | Yes      | Vehicle identifier                                                           |
| `obd_data`                        | object  | Yes      | OBD-II diagnostic data                                                       |
| `obd_data.dtcs`                   | array   | No       | Diagnostic trouble codes                                                     |
| `obd_data.live_data`              | object  | Yes      | Real-time sensor readings                                                    |
| `test_results`                    | object  | No       | Manual inspection results                                                    |
| `options.include_recommendations` | boolean | No       | Include repair recommendations (default: true)                               |
| `options.severity_threshold`      | string  | No       | Minimum severity to report: `minor`, `moderate`, `severe` (default: `minor`) |

### Live Data Parameters

| Parameter           | Unit | Description                   |
| ------------------- | ---- | ----------------------------- |
| `engine_rpm`        | RPM  | Engine revolutions per minute |
| `coolant_temp`      | °C   | Engine coolant temperature    |
| `intake_temp`       | °C   | Intake air temperature        |
| `maf_rate`          | g/s  | Mass air flow rate            |
| `throttle_position` | %    | Throttle position (0-100)     |
| `fuel_pressure`     | kPa  | Fuel rail pressure            |
| `o2_sensor_voltage` | V    | Oxygen sensor voltage         |
| `timing_advance`    | °    | Ignition timing advance       |
| `vehicle_speed`     | km/h | Vehicle speed                 |
| `engine_load`       | %    | Calculated engine load        |

### Response

```json theme={null}
{
  "status": "success",
  "data": {
    "diagnostic_id": "mech_1234567890abcdef",
    "vehicle_id": "veh_1234567890abcdef",
    "status": "completed",
    "created_at": "2024-01-15T11:00:00Z",
    "completed_at": "2024-01-15T11:00:15Z",
    "results": {
      "overall_health": "fair",
      "health_score": 6.8,
      "confidence": 0.91,
      "systems": [
        {
          "system": "engine",
          "status": "needs_attention",
          "health_score": 7.0,
          "issues": [
            {
              "issue_id": "eng_cat_efficiency",
              "component": "catalytic_converter",
              "severity": "moderate",
              "status": "active",
              "description": "Catalytic converter efficiency below threshold",
              "dtc": "P0420",
              "confidence": 0.94,
              "symptoms": [
                "Reduced fuel efficiency",
                "Failed emissions test possible",
                "Check engine light on"
              ],
              "recommended_action": "Replace catalytic converter",
              "urgency": "medium",
              "estimated_repair": {
                "min": 800,
                "max": 1500,
                "currency": "USD",
                "labor_hours": 2.5
              }
            },
            {
              "issue_id": "eng_fuel_trim",
              "component": "fuel_system",
              "severity": "minor",
              "status": "active",
              "description": "System running lean (Bank 1)",
              "dtc": "P0171",
              "confidence": 0.88,
              "symptoms": [
                "Rough idle",
                "Slight hesitation on acceleration",
                "Decreased fuel efficiency"
              ],
              "possible_causes": [
                "Vacuum leak",
                "Dirty MAF sensor",
                "Fuel filter restriction",
                "Weak fuel pump"
              ],
              "recommended_action": "Inspect for vacuum leaks, clean MAF sensor",
              "urgency": "low",
              "estimated_repair": {
                "min": 150,
                "max": 400,
                "currency": "USD",
                "labor_hours": 1.5
              }
            }
          ]
        },
        {
          "system": "transmission",
          "status": "good",
          "health_score": 8.5,
          "issues": []
        },
        {
          "system": "brakes",
          "status": "good",
          "health_score": 8.2,
          "issues": []
        },
        {
          "system": "electrical",
          "status": "good",
          "health_score": 9.0,
          "issues": [],
          "notes": "Battery voltage and alternator output within normal range"
        },
        {
          "system": "cooling",
          "status": "good",
          "health_score": 8.8,
          "issues": []
        },
        {
          "system": "emissions",
          "status": "needs_attention",
          "health_score": 6.5,
          "issues": [
            {
              "issue_id": "emis_cat_001",
              "component": "catalytic_converter",
              "severity": "moderate",
              "status": "active",
              "description": "Emissions system efficiency degraded",
              "recommended_action": "Replace catalytic converter to meet emissions standards"
            }
          ]
        }
      ],
      "maintenance_schedule": {
        "overdue": [],
        "due_soon": [
          {
            "service": "engine_oil_change",
            "miles_remaining": 1200,
            "recommended_date": "2024-02-15"
          }
        ],
        "upcoming": [
          {
            "service": "tire_rotation",
            "miles_remaining": 3500,
            "recommended_date": "2024-04-01"
          }
        ]
      },
      "summary": {
        "total_issues": 2,
        "by_severity": {
          "minor": 1,
          "moderate": 1,
          "severe": 0,
          "critical": 0
        },
        "by_urgency": {
          "immediate": 0,
          "high": 0,
          "medium": 1,
          "low": 1
        },
        "total_estimated_repair": {
          "min": 950,
          "max": 1900,
          "currency": "USD"
        },
        "systems_affected": ["engine", "emissions"]
      }
    },
    "reports": {
      "pdf_url": "https://reports.steerai.autos/mech_1234567890abcdef.pdf",
      "json_url": "https://api.steerai.autos/v1/inspections/mechanical/mech_1234567890abcdef/report"
    }
  },
  "meta": {
    "request_id": "req_mech_xyz789",
    "processing_time": 15.123,
    "diagnostic_protocols": ["OBD-II", "CAN", "AI_Analysis"]
  }
}
```

### Response Fields

| Field                    | Type   | Description                                     |
| ------------------------ | ------ | ----------------------------------------------- |
| `diagnostic_id`          | string | Unique diagnostic inspection identifier         |
| `results.overall_health` | string | `excellent`, `good`, `fair`, `poor`, `critical` |
| `results.health_score`   | float  | Overall health score (0-10)                     |
| `systems[].system`       | string | Vehicle system name                             |
| `systems[].status`       | string | `good`, `needs_attention`, `critical`           |
| `issues[].severity`      | string | `minor`, `moderate`, `severe`, `critical`       |
| `issues[].urgency`       | string | `immediate`, `high`, `medium`, `low`            |
| `issues[].dtc`           | string | OBD-II diagnostic trouble code                  |

### Vehicle Systems

<AccordionGroup>
  <Accordion icon="engine" title="Engine System">
    **Components Analyzed:**
    • Engine performance and efficiency
    • Fuel system and injectors
    • Air intake and MAF sensor
    • Ignition system and timing
    • Oil pressure and condition
    • Compression and cylinder health
  </Accordion>

  <Accordion icon="gears" title="Transmission System">
    **Components Analyzed:**
    • Shifting performance
    • Transmission fluid condition
    • Clutch wear (manual)
    • Torque converter (automatic)
    • Gear ratios and synchronizers
    • Electronic controls
  </Accordion>

  <Accordion icon="wrench" title="Brake System">
    **Components Analyzed:**
    • Brake pad/shoe thickness
    • Rotor/drum condition
    • Brake fluid level and quality
    • ABS functionality
    • Brake pressure and response
    • Electronic stability control
  </Accordion>

  <Accordion icon="bolt" title="Electrical System">
    **Components Analyzed:**
    • Battery voltage and health
    • Alternator output
    • Starter motor function
    • Lighting systems
    • Electronic control modules
    • Sensor diagnostics
  </Accordion>

  <Accordion icon="temperature-half" title="Cooling System">
    **Components Analyzed:**
    • Coolant level and condition
    • Radiator and hoses
    • Water pump operation
    • Thermostat function
    • Cooling fan operation
    • Temperature regulation
  </Accordion>

  <Accordion icon="cloud" title="Emissions System">
    **Components Analyzed:**
    • Catalytic converter efficiency
    • Oxygen sensors
    • EVAP system integrity
    • EGR valve function
    • PCV system
    • Emissions compliance
  </Accordion>
</AccordionGroup>

### Common DTCs (Diagnostic Trouble Codes)

| Code  | System    | Description                         | Typical Cause              |
| ----- | --------- | ----------------------------------- | -------------------------- |
| P0420 | Emissions | Catalyst efficiency below threshold | Failed catalytic converter |
| P0171 | Engine    | System too lean (Bank 1)            | Vacuum leak, dirty MAF     |
| P0300 | Engine    | Random/multiple cylinder misfire    | Spark plugs, coils, fuel   |
| P0401 | Emissions | EGR flow insufficient               | Clogged EGR valve          |
| P0456 | Emissions | EVAP small leak detected            | Loose gas cap, leak        |
| P0442 | Emissions | EVAP medium leak detected           | Cracked hoses, purge valve |

### Error Responses

#### 400 Bad Request

```json theme={null}
{
  "status": "error",
  "error": {
    "code": "INVALID_OBD_DATA",
    "message": "OBD data format is invalid or incomplete",
    "type": "validation_error",
    "field": "obd_data.live_data"
  }
}
```

#### 422 Unprocessable Entity

```json theme={null}
{
  "status": "error",
  "error": {
    "code": "VEHICLE_NOT_OBD_COMPATIBLE",
    "message": "Vehicle does not support OBD-II diagnostics (pre-1996 model)",
    "type": "validation_error",
    "details": {
      "vehicle_year": 1994,
      "minimum_year": 1996
    }
  }
}
```

### Integration with Hardware

<CardGroup cols={2}>
  <Card title="OBD-II Adapters" icon="plug">
    **Compatible Devices**

    • Bluetooth OBD-II adapters
    • WiFi OBD-II adapters
    • USB OBD-II readers
    • Professional scan tools
    • Mobile diagnostic apps
  </Card>

  <Card title="Data Protocols" icon="network-wired">
    **Supported Protocols**

    • ISO 15765-4 (CAN)
    • ISO 14230-4 (KWP2000)
    • ISO 9141-2
    • SAE J1850 PWM
    • SAE J1850 VPW
  </Card>
</CardGroup>

### DeepDiag Integration

For advanced diagnostics beyond OBD-II, integrate with **DeepDiag**, our comprehensive diagnostic platform:

```bash theme={null}
curl -X POST "https://api.steerai.autos/v1/inspections/deepdiag" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "vehicle_id": "veh_1234567890abcdef",
    "diagnostic_level": "comprehensive",
    "include_mechanical": true
  }'
```

<Tip>
  **Pro Tip:** Combine mechanical diagnostics with visual inspection for a complete vehicle assessment. Bundle both API calls for discounted pricing.
</Tip>

### Webhooks

```json theme={null}
{
  "event": "mechanical_diagnostic.completed",
  "timestamp": "2024-01-15T11:00:15Z",
  "data": {
    "diagnostic_id": "mech_1234567890abcdef",
    "vehicle_id": "veh_1234567890abcdef",
    "overall_health": "fair",
    "health_score": 6.8,
    "issues_found": 2,
    "critical_issues": 0,
    "report_url": "https://reports.steerai.autos/mech_1234567890abcdef.pdf"
  }
}
```

### Best Practices

<Warning>
  **Data Privacy:** OBD-II data may contain sensitive vehicle information. Ensure you have proper authorization before collecting and transmitting diagnostic data.
</Warning>

1. **Regular Diagnostics:** Run diagnostics every 3,000-5,000 miles for optimal monitoring
2. **Multiple Data Points:** Collect data under various conditions (idle, acceleration, highway)
3. **Baseline Establishment:** Create baseline readings for healthy vehicles
4. **Trend Analysis:** Monitor changes over time to predict failures
5. **Combine with Visual:** Use both mechanical and visual inspections for complete assessment
