PHP Integration
Call the Venym Search REST API from PHP with cURL or any PSR-18-compatible HTTP client. These examples follow the live API contract.
Canonical origin
Use
https://search.venym.io/api/v1 and send Authorization: Bearer <your-api-key>. Store the key in VENYM_SEARCH_API_KEY.No SDK lock-in
Use native cURL, Guzzle, or your existing HTTP client.
Server-side only
Never expose the API key in browser code.
Structured JSON
Read Search results and Scrape primary_content.
Reusable Request Helper
PHP cURL helper and Search requestPHP
<?php
function venymRequest(string $path, array $payload, string $apiKey): array {
$curl = curl_init('https://search.venym.io/api/v1' . $path);
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_TIMEOUT => 120,
]);
$body = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
$data = json_decode($body ?: '{}', true, flags: JSON_THROW_ON_ERROR);
if ($status < 200 || $status >= 300) {
throw new RuntimeException($data['code'] . ': ' . $data['message']);
}
return $data;
}
$result = venymRequest('/search', [
'query' => 'latest PHP frameworks',
'max_results' => 5,
], $_ENV['VENYM_SEARCH_API_KEY']);
foreach ($result['search_results'] as $item) {
echo $item['title'] . PHP_EOL;
}Scrape One URL
POST /api/v1/scrapePHP
<?php
$result = venymRequest('/scrape', [
'url' => 'https://example.com',
'extract_options' => ['title', 'text', 'links', 'metadata'],
], $_ENV['VENYM_SEARCH_API_KEY']);
$title = $result['primary_content']['title'] ?? null;
$text = $result['primary_content']['text'] ?? '';
echo $title . PHP_EOL;
echo strlen($text) . " characters" . PHP_EOL;The response stores the primary page under primary_content. There is no bulk Scrape endpoint in the current release; coordinate bounded requests in your worker.
Validate Without Charging
GET /api/v1/validatePHP
<?php
$curl = curl_init('https://search.venym.io/api/v1/validate');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $_ENV['VENYM_SEARCH_API_KEY'],
],
]);
$response = json_decode(curl_exec($curl), true, flags: JSON_THROW_ON_ERROR);
curl_close($curl);
var_dump($response['valid'], $response['credits_remaining']);Handle Errors
- •
400— invalid JSON or request fields. - •
401— missing or invalid API key. - •
402— insufficient credits. - •
403— plan-gated feature. - •
429— rate limit; honorRetry-After. - •
500— transient or unexpected failure; retainrequest_id.