SERPHouseSERPHouse

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-php

Initialize 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.

$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,
    ]
]);
$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:

ExceptionWhen it occurs
SERPHouseUnauthorizedExceptionInvalid or missing API key
SERPHouseRateLimitExceededExceptionToo many requests in a short period
SERPHousePaymentRequiredExceptionAccount credits exhausted
SERPHouseNotFoundExceptionInvalid SERP ID or endpoint
SERPHouseServerErrorExceptionInternal server error

Best practice

Always wrap API calls in try-catch blocks and handle each exception type appropriately for a robust integration.

Last updated on

How is this guide?

On this page