PHP SDK
Official SERPHouse PHP SDK for integrating SERP search into any PHP application.
The official PHP SDK makes it easy to integrate the SERPHouse API into any PHP application.
Requirements
- PHP 7.2+
- Composer
Installation
composer require serphouse/serphouse-phpInitialize the Client
require 'vendor/autoload.php';
use SERPHouse\SERPHouseClient;
$client = new SERPHouseClient('YOUR_API_KEY');Replace YOUR_API_KEY with your actual SERPHouse API key from the dashboard.
Live SERP Search
$response = $client->serpApi->live([
'data' => [
'q' => 'apple',
'domain' => 'google.com',
'lang' => 'en',
'device' => 'desktop',
'serp_type' => 'web',
'loc' => 'Texas, United States',
'page' => 1,
'num_result' => 10,
]
]);Schedule a Search
$response = $client->serpApi->schedule([...]);Check Search Status
$response = $client->serpApi->check($searchId);Get Search Result
$response = $client->serpApi->get($searchId);Additional Services
$response = $client->domains->list();
$response = $client->languages->list();
$response = $client->location->search(['q' => 'Texas']);
$response = $client->account->fetch();Exception Handling
The SDK throws dedicated exception classes for common error scenarios:
| Exception | When it occurs |
|---|---|
SERPHouseUnauthorizedException | Invalid or missing API key |
SERPHouseRateLimitExceededException | Too many requests in a short period |
SERPHousePaymentRequiredException | Account credits exhausted |
SERPHouseNotFoundException | Invalid SERP ID or endpoint |
SERPHouseServerErrorException | Internal server error |
Best practice
Always wrap API calls in try-catch blocks and handle each exception type appropriately for a robust integration.
Related Links
Last updated on
How is this guide?