npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

search-ai-core

v0.0.1

Published

Search the web with advanced filters and LLM-friendly output formats (TypeScript port of SearchAI)

Readme

search-ai-core

Search the web with advanced filters and LLM-friendly output formats!

TypeScript port of SearchAI.

import { search } from 'search-ai-core';

const results = await search({ query: 'What is the best LLM in 2025?', count: 10 });

for (const result of results) {
  console.log(result.title);
}

Example output:

LLM Leaderboard 2025 - Verified AI Rankings
Best LLM Models 2025: Top 10 AI Models Ranked & Compared
Top 7 LLMs Ranked in 2025: GPT-4o, Gemini, Claude & More
10 Best Large Language Models (LLMs) in 2025 - Beebom
Best Large Language Models (LLMs) of 2025 - TechRadar
...

Install

npm install search-ai-core

Requires Node.js 18+. No native dependencies — uses the built-in https module with browser-like TLS settings to query DuckDuckGo.

Examples

The examples/ folder has runnable snippets (mirrors the reference repo's examples). Examples use top-level await, so run them with Bun from the repo root:

bun examples/basic-search.ts
bun examples/json-example.ts
bun examples/markdown-example.ts

See examples/README.md for the full list.

Using filters

import { search, Filters } from 'search-ai-core';

const searchFilters = new Filters({
  inTitle: 'python',              // Only include results with "python" in the title
  tlds: ['.edu', '.org'],         // Restrict results to .edu and .org domains
  httpsOnly: true,                // Only include websites that support HTTPS
  excludeSites: 'quora.com',      // Exclude results from quora.com
  excludeFiletypes: 'pdf',        // Exclude PDF documents from results
});

const results = await search({ filters: searchFilters, count: 10 });

for (const result of results) {
  console.log(result.title);
}

Example output:

Welcome to Python.org
Python Tutorial - W3Schools
Python (programming language) - Wikipedia
Learn Python - Free Interactive Python Tutorial
CS50's Introduction to Programming with Python | Harvard University
Real Python: Python Tutorials
Python for Everybody Specialization - Coursera
scikit-learn: machine learning in Python — scikit-learn 1.6.1 ...
Table Of Contents - Learn Python the Hard Way
Python Institute - PROGRAM YOUR FUTURE

Regional targeting

import { search, Filters, Regions } from 'search-ai-core';

const searchFilters = new Filters({ region: Regions.JAPAN });

const results = await search({ query: 'Python', filters: searchFilters });

for (const result of results) {
  console.log(result.title);
}

Example output:

Welcome to Python.org
python.jp: プログラミング言語 Python 総合情報サイト
【入門】Pythonとは|活用事例やメリット、できること、学習方法 ...
ゼロからのPython入門講座 - python.jp
Pythonの開発環境を用意しよう!(Windows) - Progate
Python - Wikipedia
...

Markdown & JSON formats

Once you have results, you can get them as Markdown or JSON for further processing.

If extend is set to true, the content of each result's page is fetched and included in the output. Pages are fetched with Node's https module and automatically decompressed (gzip, deflate, brotli). Metadata is extracted when available (e.g. author, twitter handle).

Markdown:

const results = await search({ query: 'TypeScript', count: 5 });

await results.markdown({
  extend: false,           // Set to true to fetch and include page content
  contentLength: 1000,      // Limit the length of extracted content
  ignoreLinks: false,      // Exclude hyperlinks in the content
  ignoreImages: true,      // Exclude images from the content
  onlyPageContent: false,  // If true, omits metadata from the output
});

JSON:

await results.json({
  extend: false,           // Set to true to fetch and include page content
  contentLength: 1000,      // Limit the length of extracted content
  ignoreLinks: false,      // Exclude hyperlinks in the content
  ignoreImages: true,      // Exclude images from the content
});

Using proxies

Create a Proxy instance and pass it to search or asyncSearch:

import { Proxy, search } from 'search-ai-core';

const proxy = new Proxy({
  protocol: 'http',         // or 'https', 'socks4', 'socks5'
  host: '[host]',
  port: 9999,
  username: 'optional username',
  password: 'optional password',
});

const results = await search({ query: 'query', proxy });

Async support

Both search and asyncSearch are async and return the same SearchResults type. asyncSearch is provided as an alias for compatibility with the Python library's API.

import { asyncSearch, Filters } from 'search-ai-core';

const results = await asyncSearch({
  query: 'Node.js',
  filters: new Filters({ inTitle: 'guide' }),
  count: 10,
});

await results.json({ extend: true });

All filters

You can narrow searches with a Filters object:

new Filters({
  sites: 'example.com',
  tlds: ['.edu', '.gov'],
  filetype: 'pdf',
  excludeSites: ['facebook.com', 'twitter.com'],
  inTitle: 'python',
  notInUrl: ['login', 'signup'],
});

| Filter | Description | Example (one) | Example (many) | | ------ | ----------- | ------------- | -------------- | | region | Only show results from specific regions | Regions.US_ENGLISH | | | timeSpan | Timespan for the search | Timespans.PAST_WEEK | | | sites | Only show results from specific domains | 'example.com' | ['example.com', 'another.com'] | | tlds | Only show results from specific TLDs (e.g. .gov, .edu) | '.edu' | ['.edu', '.gov'] | | filetype | Only show documents of a specific file type (one only) | 'pdf' | | | httpsOnly | Only show websites that support HTTPS | true | | | excludeSites | Exclude results from specific domains | 'facebook.com' | ['facebook.com', 'twitter.com'] | | excludeTlds | Exclude results from specific TLDs | '.xyz' | ['.xyz', '.ru'] | | excludeFiletypes | Exclude documents with specific file types | 'doc' | ['doc', 'xls'] | | excludeHttps | Exclude HTTPS pages | true | | | anyKeywords | Require at least one word anywhere in the page | 'python' | ['python', 'django'] | | allKeywords | Require all of these words somewhere in the page | 'ai' | ['ai', 'ml', 'nlp'] | | exactPhrases | Include results with exact phrases | 'machine learning' | ['deep learning', 'language model'] | | excludeAllKeywords | Exclude pages containing certain words | 'ads' | ['ads', 'tracking'] | | excludeExactPhrases | Exclude results with exact phrases | 'click here' | ['click here', 'buy now'] | | inTitle | Require specific words in the title | 'resume' | ['resume', 'portfolio'] | | inUrl | Require specific words in the URL | 'blog' | ['blog', 'tutorial'] | | inText | Require specific words in the page text | 'case study' | ['case study', 'example'] | | notInTitle | Exclude pages with specific words in the title | 'login' | ['login', 'signup'] | | notInUrl | Exclude pages with specific words in the URL | 'register' | ['register', 'checkout'] | | notInText | Exclude pages with specific words in the page text | 'error' | ['error', '404'] |

Search configuration options

search and asyncSearch accept an options object with:

| Parameter | Type | Description | Default | | --------- | ---- | ----------- | ------- | | query | string | The search query. | '' | | filters | Filters \| null | Optional filters to narrow results. | null | | count | number | Number of results to return. | 10 | | offset | number | Number of results to skip at the start. | 0 | | proxy | Proxy \| null | Optional proxy for requests. | null |

License

MIT