Letter S Streamline Icon: https://streamlinehq.comserpex
Pricing
Docs
Sign InGet Started

Documentation

Quick Start
GoogleBingDuckDuckGoBraveYahooYandexAuto Route
Web Scraping
TypeScriptPython
Rate Limits & Cost
Letter S Streamline Icon: https://streamlinehq.comSerpex

The fast, affordable search API for AI & data projects.

Product

  • Playground
  • Dashboard
  • Google search API
  • Bing Search API
  • Brave Search API
  • DuckDuckGo Search API

Legal

  • Terms
  • Privacy
  • Data Processing Agreement
  • GDPR
  • SLA

Resources

  • Status page
  • Blog
  • Docs
  • Support

© 2025 Serper.dev. All rights reserved.

Building the future of AI data

Back to Documentation

TypeScript SDK

npm

Official TypeScript SDK for the Serpex SERP API. Fetch search results in JSON format with type safety.

Installation

npm

npm install serpex

yarn

yarn add serpex

pnpm

pnpm add serpex

Quick Start

Get started with the Serpex TypeScript SDK in just a few lines of code.

import { SerpexClient } from 'serpex';

// Initialize the client with your API key
const client = new SerpexClient('your-api-key-here');

// Web search with Google
const webResults = await client.search({
  q: 'typescript tutorial',
  engine: 'google',
  category: 'web',
  time_range: 'week'  // Only for web search
});

// News search - always returns latest news
const newsResults = await client.search({
  q: 'artificial intelligence',
  engine: 'google',
  category: 'news'  // Always returns latest news
});

console.log(webResults.results[0].title);
console.log(newsResults.results[0].published_date);

API Reference

SerpexClient Constructor

new SerpexClient(apiKey: string, baseUrl?: string)
  • apiKey - Your API key from the Serpex dashboard
  • baseUrl - Optional base URL (defaults to production API)

search() Method

const results = await client.search({
  q: 'javascript frameworks',
  engine: 'google',
  category: 'web',
  time_range: 'month'
});

Search Parameters

ParameterTypeRequiredDescription
qstringYesSearch query
enginestringYesSearch engine (auto, google, bing, duckduckgo, brave, yahoo, yandex)
categorystringNoSearch category (web, news). News always returns latest articles.
time_rangestringNoTime range filter (day, week, month, year). Only for web search, ignored for news.

Response Format

interface SearchResponse {
  metadata: {
    number_of_results: number;
    response_time: number;
    timestamp: string;
    credits_used: number;
  };
  id: string;
  query: string;
  engines: string[];
  results: Array<{
    title: string;
    url: string;
    snippet: string;
    position: number;
    engine: string;
    published_date: string | null;
    img_src?: string;
    duration?: string;
    score?: number;
  }>;
  answers: any[];
  corrections: string[];
  infoboxes: any[];
  suggestions: string[];
}

Error Handling

import { SerpexClient, SerpApiException } from 'serpex';

try {
  const results = await client.search({
    q: 'test query',
    engine: 'google'
  });
} catch (error) {
  if (error instanceof SerpApiException) {
    console.log('API Error:', error.message);
    console.log('Status Code:', error.statusCode);
  }
}