No description
- TypeScript 100%
| src | ||
| .editorconfig | ||
| .env.example | ||
| .gitignore | ||
| .oxlintrc.json | ||
| .prettierignore | ||
| .prettierrc | ||
| bun.lock | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
kagi-search
CLI tool for searching the web and extracting page content using the Kagi API. By default it returns Kagi's own markdown output for LLM-friendly consumption.
Prerequisites
- Bun runtime
- Kagi API key (get one here)
Setup
bun install
export KAGI_API_KEY=your_key_here
Usage
Development
bun run dev -- "your search query"
Build Binary
bun run build
This creates a standalone binary at dist/kagi-search.
CLI Options
kagi-search <query> [options]
kagi-search --extract-url <url> [--extract-url <url> ...] [options]
Options:
--limit <n> Limit number of results (default: 10; max: 1024)
--page <n> API page number (default: 1; max: 10)
--images Search images instead of web pages
--workflow <type> Search workflow: search, images, videos, news, podcasts
--extract <n> Extract full markdown content for first n search results (max: 10)
--extract-url <url> Extract markdown content from a URL (can be repeated, max: 10)
--json Output raw JSON instead of Kagi's markdown format
--include-related Accepted for compatibility; Kagi controls markdown sections
--help Show help message
Examples
Basic search
kagi-search "python async await tutorial"
API paging
kagi-search "AI news" --limit 5 --page 2
Image search
kagi-search "golden retriever" --images
# or
kagi-search "golden retriever" --workflow images
JSON for scripting
kagi-search "github stars" --json | jq '.data.search[].url'
kagi-search "golden retriever" --images --json | jq '.data.image[].url'
Extract full content from search results
kagi-search "llm structured outputs" --limit 3 --extract 2
Extract content from specific URLs
kagi-search --extract-url https://example.com/article
kagi-search --extract-url https://example.com/a --extract-url https://example.com/b --json
Features
- Kagi API v1: Uses
https://kagi.com/api/v1with Bearer auth - Kagi markdown output: Delegates markdown formatting to Kagi's API
- API paging: Uses Kagi's native
pageparameter instead of local slicing - Image search: Use
--imagesor--workflow images - Website extraction: Extract markdown content from search results or specific URLs using Kagi Extract
- Intelligent caching: Exact API requests are cached for 1 week
Cache
Search results are cached in ~/.cache/kagi-search/ for 1 week. Cache keys include query, page, limit, workflow, response format, and extraction count.
API Pricing
See Kagi's current API pricing at https://kagi.com/api/pricing. Search and Extract are billed separately.
License
MIT