How to add basic web search from the command line
Basic web search from the command line means sending a query to a search API and receiving ranked results as structured text, without a browser. The two main approaches are calling a search API directly with curl or using a dedicated CLI tool that handles authentication, output formatting, and pagination for you.
| Approach | Setup | Output format | Best for |
|---|---|---|---|
curl + search API | API key, manual auth headers | Raw JSON | Scripting, one-off lookups |
| Dedicated CLI tool | Install once, store key | Formatted text or JSON | Interactive use, shell pipelines |
| Search-enabled agent CLI | Install once | LLM-ready markdown | AI agents, code assistants |
| Browser automation | Headless browser runtime | Full HTML | Sites that block API access |
Command-line search is most useful when you need to pull live web results into a shell script, feed real-time data to a local model, or run a quick lookup without leaving the terminal. The minimum setup is a search API key and one curl call.
The Firecrawl CLI adds web search to the terminal in one step:
npx -y firecrawl-cli@latest init
firecrawl search "your query here"Results come back as LLM-ready markdown with page content included, skipping the separate scrape step. The CLI also registers automatically as a tool in Claude Code, Codex, and other agents that support tool use.
data from the web