No description
  • TypeScript 100%
Find a file
2026-05-22 12:43:54 +02:00
src updated with final kagi api v1 spec 2026-05-22 12:43:54 +02: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, lint and types 2026-05-13 22:17:09 +02:00
bun.lock deps 2026-05-13 22:16:13 +02:00
package.json formatting, lint and types 2026-05-13 22:17:09 +02:00
README.md updated with final kagi api v1 spec 2026-05-22 12:43:54 +02:00
tsconfig.json formatting, lint and types 2026-05-13 22:17:09 +02:00

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

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

kagi-search "python async await tutorial"

API paging

kagi-search "AI news" --limit 5 --page 2
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/v1 with Bearer auth
  • Kagi markdown output: Delegates markdown formatting to Kagi's API
  • API paging: Uses Kagi's native page parameter instead of local slicing
  • Image search: Use --images or --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