@agent-infra/bing-search
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@agent-infra/bing-search

npm version downloads node version license

A lightweight TypeScript client for Bing Search API, designed for AI applications.

Features

  • Type-safe: Full TypeScript support with comprehensive type definitions
  • Configurable: Customizable search parameters and API settings
  • Minimal: Zero external runtime dependencies
  • Developer-friendly: Clean API with Promise-based interface

Installation

npm install @agent-infra/bing-search
# or
yarn add @agent-infra/bing-search
# or
pnpm add @agent-infra/bing-search

Usage

Basic Search

import { BingSearchClient } from '@agent-infra/bing-search';

const client = new BingSearchClient({
  apiKey: 'YOUR_API_KEY',
});

const results = await client.search({
  q: 'climate change',
  count: 5,
});

console.log(results.webPages?.value);

With Environment Variables

// Set in your environment:
// BING_SEARCH_API_KEY=your-api-key

import { BingSearchClient } from '@agent-infra/bing-search';

const client = new BingSearchClient();
const results = await client.search({ q: 'renewable energy' });

With Custom Logger

import { ConsoleLogger } from '@agent-infra/logger';
import { BingSearchClient } from '@agent-infra/bing-search';

const logger = new ConsoleLogger('[BingSearch]');
const client = new BingSearchClient({
  apiKey: 'YOUR_API_KEY',
  logger,
});

const results = await client.search({ q: 'machine learning' });

API Reference

BingSearchClient

constructor(config?: Partial<BingSearchConfig>)

Configuration options:

interface BingSearchConfig {
  baseUrl?: string; // Default: 'https://api.bing.microsoft.com/v7.0'
  apiKey?: string; // Bing API subscription key
  headers?: Record<string, string>;
  logger?: Logger;
}

Search Method

async search(params: BingSearchOptions): Promise<BingSearchResponse>

Search options:

interface BingSearchOptions {
  q: string; // Search query (required)
  count?: number; // Number of results to return
  offset?: number; // Result offset for pagination
  mkt?: string; // Market code (e.g., 'en-US')
  safeSearch?: 'Off' | 'Moderate' | 'Strict';
  [key: string]: any; // Additional parameters
}

Response Types

interface BingSearchResponse {
  webPages?: {
    value: WebPage[];
    totalEstimatedMatches?: number;
    webSearchUrl?: string;
  };
  images?: {
    value: Image[];
    // ...
  };
  videos?: {
    value: Video[];
    // ...
  };
  // Additional response fields
}

Examples

See examples.

License

Copyright (c) 2025 ByteDance, Inc. and its affiliates.

Licensed under the Apache License, Version 2.0.

Readme

Keywords

none

Package Sidebar

Install

npm i @agent-infra/bing-search

Weekly Downloads

2

Version

0.0.1

License

none

Unpacked Size

51.4 kB

Total Files

19

Last publish

Collaborators

  • ulivz
  • ycjcl868