Skip to main content

PHP Examples for adaline.report

PHP code examples for the Adaline Report API using cURL.

Examples use PHP's built-in cURL extension. No Composer packages required.

Setup

<?php
const API_KEY = 'your-api-key';
const BASE_URL = 'https://api.adaline.report';

function apiRequest(string $method, string $path, ?array $body = null): array {
    $ch = curl_init(BASE_URL . $path);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'X-API-Key: ' . API_KEY,
        'Content-Type: application/json',
    ]);
    if ($method === 'POST') {
        curl_setopt($ch, CURLOPT_POST, true);
        if ($body) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
    } elseif ($method === 'DELETE') {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
    }
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response, true) ?? [];
}

Scan a Document

function scanDocument(string $filePath): array {
    $ch = curl_init(BASE_URL . '/api/v1/scan');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: ' . API_KEY]);
    curl_setopt($ch, CURLOPT_POSTFIELDS, [
        'file' => new CURLFile($filePath),
    ]);
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response, true);
}

$result = scanDocument('syllabus.pdf');
echo "Score: {$result['overall_score']}% (Grade {$result['grade']})\n";

List Reports

$reports = apiRequest('GET', '/api/v1/reports?page=1&page_size=20');
foreach ($reports['items'] as $report) {
    echo "{$report['filename']}: {$report['overall_score']}% ({$report['grade']})\n";
}

Tags

$tag = apiRequest('POST', '/api/v1/tags', ['name' => 'reviewed', 'color' => 'green']);
apiRequest('POST', "/api/v1/tags/{$tag['id']}/reports/{$reportId}");

Share

$share = apiRequest('POST', "/api/v1/reports/{$reportId}/share");
echo "Share URL: {$share['share_url']}\n";

Batch Scan

foreach (glob('./documents/*.pdf') as $file) {
    echo "Scanning " . basename($file) . "...\n";
    $result = scanDocument($file);
    echo "  Score: {$result['overall_score']}% ({$result['grade']})\n";
}
© 2026 Adaline LLC