No description
Find a file
2026-01-31 21:30:25 +00:00
src switched from url decode to html decode 2026-01-31 21:30:25 +00:00
.editorconfig formatting 2026-01-31 21:23:52 +00:00
.env.example init 2026-01-31 20:37:25 +00:00
.gitignore init 2026-01-31 20:37:25 +00:00
.oxlintrc.json formatting 2026-01-31 21:23:52 +00:00
.prettierignore formatting 2026-01-31 21:23:52 +00:00
.prettierrc formatting 2026-01-31 21:23:52 +00:00
bun.lock formatting 2026-01-31 21:23:52 +00:00
CLAUDE.md init 2026-01-31 20:37:25 +00:00
package.json formatting 2026-01-31 21:23:52 +00:00
README.md init 2026-01-31 20:37:25 +00:00
tsconfig.json init 2026-01-31 20:37:25 +00:00

kagi-search

CLI tool for searching the web using the Kagi Search API. Optimized for LLM consumption with markdown output and intelligent caching.

Prerequisites

Setup

  1. Install dependencies:
bun install
  1. Set your API key:
export KAGI_API_KEY=your_key_here

Or create a .env file:

cp .env.example .env
# Edit .env and add your API key

Usage

Development

bun run dev -- "your search query"

Build Binary

bun run build

This creates a standalone binary at dist/kagi-search.

Install Globally

bun run build
ln -s $(pwd)/dist/kagi-search /usr/local/bin/kagi-search

CLI Options

kagi-search <query> [options]

Options:
  --limit <n>           Limit number of results (default: 10)
  --offset <n>          Skip first n results (default: 0)
  --json                Output raw JSON
  --include-related     Include related searches in output
  --help                Show help message

Examples

kagi-search "python async await tutorial"

Limit results

kagi-search "AI news" --limit 5

Pagination

kagi-search "recipes" --offset 10 --limit 5

JSON for scripting

kagi-search "github stars" --json | jq '.data[].url'
kagi-search "rust programming" --include-related

Features

  • Markdown output: Clean, structured format optimized for LLM consumption
  • Intelligent caching: Results cached for 1 hour to reduce API costs and latency
  • Exit codes:
    • 0: Success
    • 1: General error
    • 2: Missing API key
    • 3: API request failed
    • 4: Invalid arguments

Cache

Search results are cached in ~/.cache/kagi-search/ for 1 hour. If you search again with the same query and the offset+limit fits within the cached data, results are served from cache instead of hitting the API.

API Pricing

Kagi Search API is priced at $25 for 1000 queries. The caching mechanism helps reduce costs for repeated searches.

License

MIT