SERPHouseSERPHouse

Node.js SDK

Official SERPHouse Node.js SDK for integrating SERP search into any Node.js application.

The official Node.js SDK makes it easy to integrate the SERPHouse API into any Node.js application.

Instead of manually creating HTTP requests, the SDK handles authentication, request formatting, and response parsing so you can focus on building your application.

The SDK provides access to Google SERP, Bing SERP, Yahoo SERP, domains, languages, locations, and account information.

Requirements

  • Node.js 18+
  • npm or yarn

Installation

npm install @serphouse/serphouse-nodejs

Get Your API Key

Create a SERPHouse account and generate an API key from your dashboard.

Initialize the Client

import { SERPHouse } from "@serphouse/serphouse-nodejs";

const client = new SERPHouse(process.env.SERPHOUSE_API_KEY);

Using environment variables is recommended. Never hardcode your API key in source code.

SERPHOUSE_API_KEY=your_api_key

Quick Start

const { results } = await client.google.search({
  q: "Coffee",
  domain: "google.com",
  lang: "en",
  device: "desktop",
  loc: "Texas, United States",
});

console.log(results);

Available Services

The SDK exposes the following namespaces.

ServiceDescription
client.googleGoogle SERP APIs (search, image, news, video)
client.bingBing SERP APIs (search, image, news)
client.yahooYahoo SERP APIs (search, image, news)
client.extraAccount info, domains, languages, locations

Google SERP

Retrieve search results immediately.

const { results } = await client.google.search({
  q: "Coffee",
  domain: "google.com",
  lang: "en",
  device: "desktop",
  serp_type: "web",
  loc: "Texas, United States",
  page: 1,
  num_result: 10,
});

Search Other Engines

The same pattern works for Bing and Yahoo.

const { results } = await client.bing.search({
  q: "Coffee",
  domain: "bing.com",
  lang: "en",
  device: "desktop",
  loc: "Texas, United States",
});
const { results } = await client.yahoo.search({
  q: "Coffee",
  domain: "uk.yahoo.com",
  lang: "en",
});

Google and Bing searches require a location — pass loc or loc_id (not both). Yahoo searches do not require a location.

JSON or HTML

Requests return structured JSON by default. Pass { responseType: "html" } as the second argument to get raw HTML instead.

const { results } = await client.google.search(
  {
    q: "Coffee",
    domain: "google.com",
    lang: "en",
    loc: "Texas, United States",
  },
  { responseType: "html" },
);

Domains

Retrieve all supported search domains.

const { results } = await client.extra.domain_list();

Languages

Retrieve supported languages.

const { results } = await client.extra.language_list();

Retrieve Bing languages.

const { results } = await client.extra.language_list({
  type: "bing",
});

Locations

Search available locations.

const { results } = await client.extra.location_search({
  q: "Texas",
  type: "google",
});

Account

Retrieve account details.

const { results } = await client.extra.account_info();

Error Handling

Always handle errors

Network issues, invalid API keys, and rate limits can all cause requests to fail. Always use try-catch.

import { SERPHouse, SERPHouseError } from "@serphouse/serphouse-nodejs";

try {
  const { results } = await client.google.search({
    q: "Coffee",
    loc: "Texas, United States",
  });
  console.log(results);
} catch (error) {
  if (error instanceof SERPHouseError) {
    console.error(`HTTP ${error.statusCode}: ${error.apiMessage}`);
  } else {
    console.error(error.message);
  }
}

Environment Variables

Store your API key securely.

SERPHOUSE_API_KEY=your_api_key
import "dotenv/config";
import { SERPHouse } from "@serphouse/serphouse-nodejs";

const client = new SERPHouse(process.env.SERPHOUSE_API_KEY);

Complete Example

import "dotenv/config";
import { SERPHouse } from "@serphouse/serphouse-nodejs";

const client = new SERPHouse(process.env.SERPHOUSE_API_KEY);

async function main() {
  const { results } = await client.google.search({
    q: "Coffee",
    domain: "google.com",
    lang: "en",
    device: "desktop",
    loc: "Texas, United States",
  });

  console.log(results);
}

main();

Support

If you encounter any issues while installing, configuring, or using the SERPHouse Node.js SDK, we're here to help.

  • Contact the SERPHouse support team at [email protected] for assistance.
  • Report bugs or request features by opening an issue on the GitHub repository.

Last updated on

How is this guide?

On this page