1. Go to this page and download the library: Download finlight/client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
finlight / client example snippets
use Finlight\FinlightClient;
use Finlight\Request\GetArticlesParams;
$client = new FinlightClient('your-api-key');
$response = $client->articles->fetchArticles(new GetArticlesParams(
tickers: ['AAPL', 'NVDA'],
countries: ['US'],
pageSize: 10,
));
foreach ($response as $article) {
printf(
"%s %s [%s]\n",
$article->publishDate->format('Y-m-d H:i'),
$article->title,
$article->sentiment ?? 'unscored',
);
}
use Finlight\Model\ArticleCategory;
use Finlight\Model\OrderBy;
use Finlight\Model\SortOrder;
use Finlight\Request\GetArticlesParams;
$response = $client->articles->fetchArticles(new GetArticlesParams(
query: '(ticker:AAPL OR ticker:NVDA) AND NOT source:www.reuters.com AND "earnings"',
from: '2026-01-01',
to: '2026-06-30',
language: 'en',
categories: [ArticleCategory::Markets, ArticleCategory::Economy],
use Finlight\Request\GetArticleByLinkParams;
$article = $client->articles->fetchArticleByLink(new GetArticleByLinkParams(
link: 'https://www.reuters.com/markets/example-article',
);
}
$sources = $client->sources->getSources();
$defaults = array_filter($sources, static fn ($source) => $source->isDefaultSource);
echo count($defaults), ' of ', count($sources), " sources are on by default\n";
use Finlight\Exception\WebhookVerificationException;
use Finlight\Service\WebhookService;
use Illuminate\Http\Request;
Route::post('/webhooks/finlight', function (Request $request) {
try {
$article = WebhookService::constructEvent(
$request->getContent(),
$request->header('X-Webhook-Signature', ''),
config('services.finlight.webhook_secret'),
$request->header('X-Webhook-Timestamp'),
);
} catch (WebhookVerificationException) {
abort(400);
}
ProcessFinlightArticle::dispatch($article->link);
return response()->noContent();
});
#[Route('/webhooks/finlight', methods: ['POST'])]
public function handle(Request $request): Response
{
try {
$article = WebhookService::constructEvent(
$request->getContent(),
$request->headers->get('X-Webhook-Signature', ''),
$this->finlightWebhookSecret,
$request->headers->get('X-Webhook-Timestamp'),
);
} catch (WebhookVerificationException) {
return new Response(status: 400);
}
$this->bus->dispatch(new IngestArticle($article->link));
return new Response(status: 204);
}
use Finlight\Config;
use Finlight\FinlightClient;
$client = new FinlightClient(new Config(
apiKey: 'your-api-key',
baseUrl: 'https://api.finlight.me',
timeoutMs: 5000,
retryCount: 3,
));
use Finlight\Config;
use Finlight\FinlightClient;
use GuzzleHttp\Client as Guzzle;
use Nyholm\Psr7\Factory\Psr17Factory;
$factory = new Psr17Factory();
$client = new FinlightClient(
new Config(apiKey: 'your-api-key'),
new Guzzle(['timeout' => 10]),
$factory,
$factory,
);