5 live

docs / integrations

PHP SDK

A dependency-free PHP 8.1 client, a launch watcher, and a signed webhook receiver.

The PHP SDK lives in the `php/` folder of the repository. It only needs ext-curl and ext-json, so it drops into any host — shared hosting, Laravel, WordPress plugins, or a cron job.

Install

bash
composer config repositories.knar path ./php
composer require knar/knar-php

Client

php
<?php
require 'vendor/autoload.php';

use Knar\KnarClient;

$knar = new KnarClient('https://useknar.vercel.app');

$ton = $knar->tonPrice();
echo "TON $" . number_format($ton['usd'], 4) . PHP_EOL;

foreach ($knar->launches(limit: 20, maxRisk: 40) as $coin) {
    printf("%-10s %6.1f%% to grad · risk %d\n", $coin['symbol'], $coin['progressPct'], $coin['risk']);
}

$signals = $knar->scan(agents: ['curve', 'tide'], minTradeTon: 50);
MethodEndpoint
launches(limit, since, maxRisk)/api/launches
coin(seq)/api/launches/:seq
coinChart(seq, range)/api/launches/:seq/chart
trades(minTon, since)/api/trades
trending()/api/trending
tonPrice()/api/ton
tonChart(days)/api/ton/chart
scan(agents, since, minTradeTon, graduationPct, maxRisk)/api/agents/onrank
status()/api/status

Launch watcher

`php/examples/launch_watcher.php` polls the agents every 15 seconds, de-duplicates by signal id, and prints each new signal. Run it with `php php/examples/launch_watcher.php`.

Webhook receiver

`php/examples/webhook_receiver.php` verifies the `X-Knar-Signature` HMAC header with `hash_equals`, rejects malformed events, and forwards hot signals to a Telegram chat.

php
$expected = 'sha256=' . hash_hmac('sha256', $payload, $secret);
if (!hash_equals($expected, $signature)) {
    http_response_code(401);
    exit;
}

Keep KNAR_WEBHOOK_SECRET and TELEGRAM_BOT_TOKEN in environment variables — never commit them.