HomAI Documentation - Complete Developer Guide

Developer Documentation

Everything you need to integrate HomAI's property intelligence into your applications. Get started with our APIs, SDKs, and comprehensive guides.

Quick Start Guide

Get up and running with HomAI in minutes. Follow this step-by-step guide to perform your first property analysis.

Step 1: Initialize the Client

First, create a new HomAI client instance with your API credentials.

// Initialize HomAI API client
const HomAI = require('@homai/api-client');

const client = new HomAI({
  apiKey: 'your-api-key',
  environment: 'production' // or 'sandbox'
});

// Verify connection
const status = await client.getStatus();
console.log('HomAI status:', status);

Step 2: Upload Property Image

Upload a property image or provide coordinates for satellite imagery analysis.

// Option 1: Upload local image
const fs = require('fs');
const imageFile = fs.readFileSync('property.jpg');

const analysis = await client.analyze({
  image: imageFile,
  location: {
    lat: 40.7128,
    lng: -74.0060,
    address: "123 Main St, New York, NY"
  },
  options: {
    includeRiskAssessment: true,
    generatePDF: true
  }
});

// Option 2: Use satellite imagery
const satelliteAnalysis = await client.analyzeBySatellite({
  coordinates: { lat: 40.7128, lng: -74.0060 },
  zoomLevel: 20,
  options: {
    includeRiskAssessment: true
  }
});

Step 3: Process Results

Handle the analysis results and extract relevant information.

// Process analysis results
console.log('Analysis completed:', analysis.status);
console.log('Confidence score:', analysis.confidenceScore);
console.log('Risk assessment:', analysis.riskScore);

// Access roof analysis data
analysis.roofAnalysis.forEach((roof, index) => {
  console.log(`Roof ${index + 1}:`);
  console.log('  Material:', roof.material);
  console.log('  Condition:', roof.condition);
  console.log('  Risk factors:', roof.riskFactors);
});

// Download PDF report
if (analysis.reportURL) {
  const report = await client.downloadReport(analysis.reportURL);
  fs.writeFileSync('analysis-report.pdf', report);
}

API Reference

Complete reference for all HomAI API endpoints, parameters, and response formats.

Analyze Property

POST https://api.homai.ai/v1/analyze
Headers:
Authorization: Bearer your-api-key
Content-Type: multipart/form-data
Request Body:
{
  "image": "[binary image data]",
  "location": {
    "lat": 40.7128,
    "lng": -74.0060,
    "address": "123 Main St, New York, NY"
  },
  "options": {
    "includeRiskAssessment": true,
    "generatePDF": true,
    "detailLevel": "comprehensive"
  }
}
Response (200 OK):
{
  "analysisId": "ana_1234567890",
  "status": "completed",
  "confidenceScore": "87%",
  "riskScore": "Medium",
  "roofAnalysis": [
    {
      "roofId": "roof_1",
      "material": "Asphalt Shingles",
      "condition": "Good",
      "estimatedAge": "10-15 years",
      "maintenanceNeeded": "Gutter cleaning recommended",
      "riskFactors": ["Tree proximity"]
    }
  ],
  "insuranceAssessment": {
    "premiumMultiplier": 1.1,
    "riskCategory": "Standard",
    "recommendations": ["Annual inspection"]
  },
  "reportURL": "https://api.homai.ai/reports/ana_1234567890.pdf",
  "createdAt": "2025-01-15T10:30:00Z"
}

Integration Guide

Step-by-step integration guides for popular platforms and frameworks.

WordPress Plugin Integration

Integrate HomAI into your WordPress site with our official plugin.

<?php
// Add to your theme's functions.php or custom plugin

// Initialize HomAI
function init_homai_client() {
    return new HomAI_Client([
        'api_key' => get_option('homai_api_key'),
        'environment' => 'production'
    ]);
}

// Shortcode for property analysis
function homai_analysis_shortcode($atts) {
    $atts = shortcode_atts([
        'property_id' => '',
        'show_form' => 'true'
    ], $atts);
    
    ob_start();
    include 'templates/property-analysis-form.php';
    return ob_get_clean();
}
add_shortcode('homai_analysis', 'homai_analysis_shortcode');
?>

React Integration

Build property analysis features into your React applications.

import React, { useState } from 'react';
import { HomAIClient } from '@homai/react-sdk';

const PropertyAnalysis = () => {
  const [analysis, setAnalysis] = useState(null);
  const [loading, setLoading] = useState(false);
  
  const client = new HomAIClient({
    apiKey: process.env.REACT_APP_HOMAI_API_KEY
  });

  const handleAnalysis = async (imageFile, location) => {
    setLoading(true);
    try {
      const result = await client.analyze({
        image: imageFile,
        location: location,
        options: {
          includeRiskAssessment: true,
          generatePDF: true
        }
      });
      setAnalysis(result);
    } catch (error) {
      console.error('Analysis failed:', error);
    } finally {
      setLoading(false);
    }
  };

  return (
    <div className="property-analysis">
      <PropertyUpload onAnalysis={handleAnalysis} />
      {loading && <LoadingSpinner />}
      {analysis && <AnalysisResults data={analysis} />}
    </div>
  );
};

export default PropertyAnalysis;

Code Examples

Ready-to-use code examples for common use cases and integration scenarios.

Batch Property Analysis

Process multiple properties in parallel for large-scale analysis.

// Batch processing multiple properties
const analyzeMultipleProperties = async (properties) => {
  const results = await Promise.allSettled(
    properties.map(async (property) => {
      try {
        const analysis = await client.analyze({
          image: property.imageFile,
          location: property.location,
          options: {
            includeRiskAssessment: true,
            generatePDF: false // Skip PDF for batch processing
          }
        });
        
        return {
          propertyId: property.id,
          status: 'completed',
          data: analysis
        };
      } catch (error) {
        return {
          propertyId: property.id,
          status: 'failed',
          error: error.message
        };
      }
    })
  );
  
  // Process results
  const successful = results.filter(r => r.value?.status === 'completed');
  const failed = results.filter(r => r.value?.status === 'failed');
  
  console.log(`Processed ${successful.length} properties successfully`);
  console.log(`${failed.length} properties failed`);
  
  return results;
};

Real-time Progress Updates

Track analysis progress with real-time status updates.

// Real-time progress tracking
const analyzeWithProgress = async (imageFile, location, onProgress) => {
  // Start analysis
  const analysisId = await client.startAnalysis({
    image: imageFile,
    location: location,
    options: { includeRiskAssessment: true }
  });
  
  // Poll for progress updates
  let analysis;
  let attempts = 0;
  const maxAttempts = 60; // 5 minutes max
  
  while (attempts < maxAttempts) {
    try {
      analysis = await client.getAnalysis(analysisId);
      
      // Update progress
      onProgress({
        stage: analysis.stage,
        progress: analysis.progress,
        estimated_time: analysis.estimatedTimeRemaining
      });
      
      if (analysis.status === 'completed') {
        break;
      } else if (analysis.status === 'failed') {
        throw new Error(analysis.error);
      }
      
      // Wait 5 seconds before next check
      await new Promise(resolve => setTimeout(resolve, 5000));
      attempts++;
      
    } catch (error) {
      console.error('Progress check failed:', error);
      break;
    }
  }
  
  return analysis;
};

// Usage
const progressCallback = (progress) => {
  console.log(`Stage: ${progress.stage}, Progress: ${progress.progress}%`);
  updateProgressBar(progress.progress);
};

const result = await analyzeWithProgress(imageFile, location, progressCallback);

Official SDKs

Official SDKs and libraries for popular programming languages and frameworks.

JS

JavaScript SDK

For Node.js and browser applications

# Install via npm
npm install @homai/api-client

# Install via yarn
yarn add @homai/api-client
View Documentation →
PY

Python SDK

For data science and backend applications

# Install via pip
pip install homai

# Install via conda
conda install -c homai homai
View Documentation →
PHP

PHP SDK

For WordPress and Laravel applications

# Install via Composer
composer require homai/php-sdk
View Documentation →
GO

Go SDK

For high-performance backend services

# Install via go get
go get github.com/homai/go-sdk
View Documentation →

Webhooks

Set up webhooks to receive real-time notifications about analysis completion and status updates.

Webhook Configuration

// Configure webhook endpoint
const express = require('express');
const app = express();

app.use(express.json());

// Webhook endpoint for analysis completion
app.post('/webhooks/homai/analysis-complete', (req, res) => {
  const { analysisId, status, data } = req.body;
  
  // Verify webhook signature
  const signature = req.headers['x-homai-signature'];
  if (!verifyWebhookSignature(req.body, signature)) {
    return res.status(401).send('Invalid signature');
  }

  // Process analysis completion
  handleAnalysisCompletion(analysisId, data);
  
  res.status(200).send('OK');
});

Webhook Verification

// Verify webhook signature for security
const crypto = require('crypto');

function verifyWebhookSignature(payload, signature) {
  const expectedSignature = crypto
    .createHmac('sha256', process.env.HOMAI_WEBHOOK_SECRET)
    .update(JSON.stringify(payload))
    .digest('hex');
    
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(`sha256=${expectedSignature}`)
  );
}

Troubleshooting

Common issues and solutions to help you integrate and use HomAI effectively.

Authentication Issues

Problem: "Invalid API Key" Error

This error occurs when the API key is incorrect or missing.

Solutions:

  • • Verify your API key is correct
  • • Check that the key is not expired
  • • Ensure you're using the correct environment
  • • Make sure the Authorization header is properly formatted

Image Quality Issues

Problem: "Low Quality Image" Error

The uploaded image doesn't meet minimum quality requirements.

Requirements:

  • • Minimum resolution: 1024x768 pixels
  • • Maximum file size: 20MB
  • • Supported formats: JPEG, PNG, WebP
  • • Clear visibility of roof structures
  • • Adequate lighting and contrast

Rate Limiting

Problem: "Rate Limit Exceeded" Error

Your application has exceeded the API rate limits.

Rate Limits:

  • • Free tier: 100 requests/month
  • • Pro tier: 1,000 requests/month
  • • Enterprise: Custom limits
  • • Implement exponential backoff for retry logic
  • • Cache results to reduce API calls

Need help getting started?

Our developer support team is here to help you integrate HomAI into your applications. Get in touch with questions, feedback, or integration assistance.