Introduction

The iLEAPP AI API provides a comprehensive set of tools for integrating AI-powered forensic analysis capabilities into your applications. This reference documents all the available modules, classes, and methods that you can use to interact with iLEAPP AI programmatically.

Note: This API reference assumes you have a basic understanding of Python programming and digital forensics concepts. If you're new to iLEAPP AI, we recommend starting with the Getting Started guide.

Getting Started with the API

To use the iLEAPP AI API in your Python code, you first need to import the necessary modules:

from ileapp_ai import Analyzer, LLMClient
from ileapp_ai.analyzers import MessageAnalyzer, AppUsageAnalyzer
from ileapp_ai.security import ChainOfCustody
from ileapp_ai.visualization import TimelineGenerator

A basic example of using the API to analyze iOS messages:

from ileapp_ai import Analyzer, LLMClient

# Initialize the LLM client with your API key
llm_client = LLMClient(provider="openrouter", api_key="your_api_key")

# Create an analyzer instance
analyzer = Analyzer(llm_client=llm_client)

# Analyze iOS messages
results = analyzer.analyze_artifact(
    artifact_path="/path/to/sms.db",
    artifact_type="messages",
    analysis_depth="comprehensive"
)

# Print the results
print(results.summary)
print(results.insights)

# Generate a report
report = analyzer.generate_report(results, output_format="html")
print(f"Report generated at: {report.path}")

Core Modules

Analyzer

The Analyzer class is the main entry point for the iLEAPP AI API. It provides methods for analyzing iOS artifacts and generating reports.

Analyzer(llm_client, config=None)

Constructor for the Analyzer class.

Parameters:
Name Type Description
llm_client LLMClient An instance of the LLMClient class for communicating with AI models.
config dict, optional Configuration options for the analyzer. Defaults to None.
Example:
from ileapp_ai import Analyzer, LLMClient

llm_client = LLMClient(provider="openrouter", api_key="your_api_key")
analyzer = Analyzer(llm_client=llm_client)

analyze_artifact(artifact_path, artifact_type, analysis_depth="standard", options=None)

Analyzes an iOS artifact using AI capabilities.

Parameters:
Name Type Description
artifact_path str Path to the artifact file or directory.
artifact_type str Type of artifact (e.g., "messages", "app_usage", "browser_history").
analysis_depth str, optional Depth of analysis: "basic", "standard", or "comprehensive". Defaults to "standard".
options dict, optional Additional options for the analysis. Defaults to None.
Returns:

AnalysisResult: An object containing the analysis results, including summary, insights, and raw data.

Example:
results = analyzer.analyze_artifact(
    artifact_path="/path/to/sms.db",
    artifact_type="messages",
    analysis_depth="comprehensive"
)

analyze_case(case_path, artifacts=None, analysis_depth="standard", options=None)

Analyzes multiple artifacts from an iOS case directory.

Parameters:
Name Type Description
case_path str Path to the case directory containing multiple artifacts.
artifacts list, optional List of artifact types to analyze. If None, analyzes all supported artifacts.
analysis_depth str, optional Depth of analysis: "basic", "standard", or "comprehensive". Defaults to "standard".
options dict, optional Additional options for the analysis. Defaults to None.
Returns:

CaseAnalysisResult: An object containing the analysis results for all artifacts, including cross-artifact correlations.

Example:
case_results = analyzer.analyze_case(
    case_path="/path/to/case_directory",
    artifacts=["messages", "app_usage", "browser_history"],
    analysis_depth="comprehensive"
)

generate_report(analysis_result, output_format="html", template=None, output_path=None)

Generates a report from analysis results.

Parameters:
Name Type Description
analysis_result AnalysisResult or CaseAnalysisResult The result object from analyze_artifact or analyze_case.
output_format str, optional Format of the report: "html", "pdf", or "json". Defaults to "html".
template str, optional Path to a custom report template. Defaults to None (uses built-in template).
output_path str, optional Path where the report should be saved. Defaults to None (auto-generated).
Returns:

Report: An object containing information about the generated report, including its path.

Example:
report = analyzer.generate_report(
    analysis_result=results,
    output_format="pdf",
    output_path="/path/to/output/report.pdf"
)

LLM Client

The LLMClient class provides an interface for communicating with various AI models through different providers.

LLMClient(provider, api_key=None, model=None, config=None)

Constructor for the LLMClient class.

Parameters:
Name Type Description
provider str The AI provider to use: "openrouter", "anthropic", "openai", or "local".
api_key str, optional API key for the provider. Not required for "local" provider.
model str, optional Specific model to use. If None, uses the provider's default model.
config dict, optional Additional configuration options for the client. Defaults to None.
Example:
from ileapp_ai import LLMClient

# Using OpenRouter
client = LLMClient(
    provider="openrouter",
    api_key="your_openrouter_api_key",
    model="anthropic/claude-3-opus-20240229"
)

# Using a local model
local_client = LLMClient(
    provider="local",
    model="llama-3-70b"
)

analyze_text(text, prompt=None, options=None)

Analyzes text using the configured AI model.

Parameters:
Name Type Description
text str The text to analyze.
prompt str, optional Custom prompt to guide the analysis. Defaults to None (uses standard prompt).
options dict, optional Additional options for the analysis. Defaults to None.
Returns:

dict: The analysis result from the AI model.

Example:
result = client.analyze_text(
    text="Hello, how are you doing today?",
    prompt="Analyze the sentiment and tone of this message."
)

analyze_structured_data(data, prompt=None, options=None)

Analyzes structured data (JSON, dict, etc.) using the configured AI model.

Parameters:
Name Type Description
data dict or list The structured data to analyze.
prompt str, optional Custom prompt to guide the analysis. Defaults to None (uses standard prompt).
options dict, optional Additional options for the analysis. Defaults to None.
Returns:

dict: The analysis result from the AI model.

Example:
app_usage_data = [
    {"app": "Messages", "duration": 3600, "timestamp": "2025-04-01T12:00:00"},
    {"app": "Safari", "duration": 1800, "timestamp": "2025-04-01T13:00:00"},
    {"app": "Camera", "duration": 300, "timestamp": "2025-04-01T15:00:00"}
]

result = client.analyze_structured_data(
    data=app_usage_data,
    prompt="Identify patterns in this app usage data."
)

Artifact Processors

The ArtifactProcessor classes handle the extraction and preprocessing of different types of iOS artifacts before they are analyzed by AI models.

get_processor(artifact_type)

Factory method to get the appropriate processor for a given artifact type.

Parameters:
Name Type Description
artifact_type str Type of artifact (e.g., "messages", "app_usage", "browser_history").
Returns:

ArtifactProcessor: An instance of the appropriate processor class.

Example:
from ileapp_ai.processors import get_processor

processor = get_processor("messages")
processed_data = processor.process("/path/to/sms.db")

Specialized Analyzers

iLEAPP AI includes specialized analyzers for different types of iOS artifacts. These analyzers extend the base Analyzer class with artifact-specific functionality.

Message Analyzer

The MessageAnalyzer class provides specialized analysis for iOS messages and conversations.

MessageAnalyzer(llm_client, config=None)

Constructor for the MessageAnalyzer class.

Parameters:
Name Type Description
llm_client LLMClient An instance of the LLMClient class for communicating with AI models.
config dict, optional Configuration options for the analyzer. Defaults to None.
Example:
from ileapp_ai import LLMClient
from ileapp_ai.analyzers import MessageAnalyzer

llm_client = LLMClient(provider="openrouter", api_key="your_api_key")
message_analyzer = MessageAnalyzer(llm_client=llm_client)

analyze_conversations(messages_data, options=None)

Analyzes conversations from iOS messages data.

Parameters:
Name Type Description
messages_data dict or list Processed messages data from a MessageProcessor.
options dict, optional Additional options for the analysis. Defaults to None.
Returns:

ConversationAnalysisResult: An object containing the analysis results for conversations.

Example:
from ileapp_ai.processors import get_processor

processor = get_processor("messages")
messages_data = processor.process("/path/to/sms.db")

conversation_results = message_analyzer.analyze_conversations(messages_data)

Visualization

The visualization module provides tools for creating visual representations of forensic data and analysis results.

TimelineGenerator(config=None)

Constructor for the TimelineGenerator class, which creates interactive timelines from forensic data.

Parameters:
Name Type Description
config dict, optional Configuration options for the timeline generator. Defaults to None.
Example:
from ileapp_ai.visualization import TimelineGenerator

timeline_generator = TimelineGenerator()

generate_timeline(events, output_path=None, options=None)

Generates an interactive timeline from a list of events.

Parameters:
Name Type Description
events list List of event dictionaries, each with at least 'timestamp' and 'description' keys.
output_path str, optional Path where the timeline should be saved. Defaults to None (auto-generated).
options dict, optional Additional options for the timeline generation. Defaults to None.
Returns:

Timeline: An object containing information about the generated timeline, including its path.

Example:
events = [
    {
        "timestamp": "2025-04-01T12:00:00",
        "description": "Message sent to John",
        "type": "message",
        "details": {"recipient": "John", "content": "Hello"}
    },
    {
        "timestamp": "2025-04-01T12:05:00",
        "description": "Opened Safari",
        "type": "app_usage",
        "details": {"app": "Safari", "duration": 300}
    }
]

timeline = timeline_generator.generate_timeline(
    events=events,
    output_path="/path/to/output/timeline.html"
)

Report Generation

The report generation module provides tools for creating comprehensive forensic reports from analysis results.

ReportGenerator(config=None)

Constructor for the ReportGenerator class.

Parameters:
Name Type Description
config dict, optional Configuration options for the report generator. Defaults to None.
Example:
from ileapp_ai.reporting import ReportGenerator

report_generator = ReportGenerator()

generate_report(analysis_results, template=None, output_format="html", output_path=None, options=None)

Generates a report from analysis results.

Parameters:
Name Type Description
analysis_results dict or AnalysisResult The analysis results to include in the report.
template str, optional Path to a custom report template. Defaults to None (uses built-in template).
output_format str, optional Format of the report: "html", "pdf", or "json". Defaults to "html".
output_path str, optional Path where the report should be saved. Defaults to None (auto-generated).
options dict, optional Additional options for the report generation. Defaults to None.
Returns:

Report: An object containing information about the generated report, including its path.

Example:
from ileapp_ai import Analyzer, LLMClient
from ileapp_ai.reporting import ReportGenerator

llm_client = LLMClient(provider="openrouter", api_key="your_api_key")
analyzer = Analyzer(llm_client=llm_client)
results = analyzer.analyze_artifact("/path/to/sms.db", "messages")

report_generator = ReportGenerator()
report = report_generator.generate_report(
    analysis_results=results,
    output_format="pdf",
    output_path="/path/to/output/report.pdf"
)

Security

The security module provides tools for maintaining forensic integrity and chain of custody.

ChainOfCustody(case_id, investigator=None, config=None)

Constructor for the ChainOfCustody class, which tracks all actions performed on forensic data.

Parameters:
Name Type Description
case_id str Unique identifier for the case.
investigator str, optional Name or ID of the investigator. Defaults to None.
config dict, optional Configuration options for the chain of custody. Defaults to None.
Example:
from ileapp_ai.security import ChainOfCustody

chain_of_custody = ChainOfCustody(
    case_id="CASE-2025-001",
    investigator="John Doe"
)

log_action(action, artifact=None, details=None)

Logs an action in the chain of custody.

Parameters:
Name Type Description
action str Description of the action performed.
artifact str, optional The artifact affected by the action. Defaults to None.
details dict, optional Additional details about the action. Defaults to None.
Returns:

str: The ID of the logged action.

Example:
action_id = chain_of_custody.log_action(
    action="Analyzed messages",
    artifact="/path/to/sms.db",
    details={"analysis_depth": "comprehensive", "model": "claude-3-opus"}
)

Extending iLEAPP AI

iLEAPP AI is designed to be extensible. You can create custom analyzers, processors, and report templates to suit your specific needs.

For detailed information on extending iLEAPP AI, please refer to the Integration Guide.

Note: This API reference is for iLEAPP AI version 1.0.0. Future versions may include additional functionality and changes to the API.