Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.2.0 - 2026-11-03

Adds `s1 maps "<query>"` and a `maps()` SDK helper for `POST /maps`: one Google Maps page of up to 20 places with category, rating, address, phone, website, open state and Maps link. Options: `-n/--max-results`, `--near <lat,lng>`, `--zoom`, `-p/--page` (page 2+ needs `--near`), `--country`, `-l/--lang`, `--json`. 3 credits per completed page. The agent skill routes "where is / nearby / list of businesses" requests to it.

## 2.1.2 - 2026-10-29

When a command fails, `s1` prints a one-line hint under the error pointing to `s1 feedback`, so agents know they can report the problem. Updates the Agentback SDK to 0.3.0. No other behavior changes.
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ s1 ask "recent papers on speculative decoding" --json

Use `search` when you already know which engine and keywords you want.

### maps

Find businesses and places on Google Maps. Each place shows its category,
rating, address, phone, website, open state, and Google Maps link. Each
completed page of up to 20 places costs 3 credits.

```bash
s1 maps "ramen in Shibuya"
s1 maps "coffee shops" --near 40.7455,-74.0083 --zoom 15 -n 5
s1 maps "coffee shops" --near 40.7455,-74.0083 --page 2 --json
```

| Option | Description |
|---|---|
| `-n, --max-results` | Places to return from the page (1-20); fewer places do not lower the price |
| `--near <lat,lng>` | Search around a point; required for page 2 and later |
| `--zoom` | Map zoom with `--near` (3-30, default 14) |
| `-p, --page` | Google Maps page (1-6); each page is billed separately |
| `--country` | Two-letter country code (default `us`) |
| `-l, --lang` | Result language such as `en`, `de`, `zh-CN` (default `en`) |

### news

Search for news articles.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "search1api-cli",
"version": "2.1.2",
"description": "CLI tool for Search1API - web search, news, crawl, sitemap, and trending",
"version": "2.2.0",
"description": "CLI tool for Search1API - web search, maps, news, crawl, sitemap, and trending",
"type": "module",
"exports": {
".": {
Expand Down
16 changes: 15 additions & 1 deletion skills/search1api/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: search1api
description: >
Live web search, agentic search, page retrieval, news, sitemap discovery, trending topics, and turning a URL into a reusable Agent Skill — all through the Search1API CLI (`s1`). Use this skill whenever the user wants to search the web, look something up, research a topic, read or summarize a URL, check current news, explore a site's links, see trending topics, check API balance, or teach an agent a URL so it can be used later. Trigger on phrases like "search for", "look up", "find out about", "what's happening with", "any news on", "what does this link say", "read this page", "summarize this URL", "trending on GitHub", "learn this URL", "learn this site", "turn these docs into a skill", "记住这个链接", "学会这个文档", or when the user shares a bare URL.
Live web search, agentic search, Google Maps place search, page retrieval, news, sitemap discovery, trending topics, and turning a URL into a reusable Agent Skill — all through the Search1API CLI (`s1`). Use this skill whenever the user wants to search the web, look something up, research a topic, read or summarize a URL, check current news, find businesses or places on a map, explore a site's links, see trending topics, check API balance, or teach an agent a URL so it can be used later. Trigger on phrases like "search for", "look up", "find out about", "what's happening with", "any news on", "coffee shops near", "restaurants in", "what does this link say", "read this page", "summarize this URL", "trending on GitHub", "learn this URL", "learn this site", "turn these docs into a skill", "记住这个链接", "学会这个文档", or when the user shares a bare URL.
---

# Search1API
Expand Down Expand Up @@ -70,6 +70,7 @@ error.
| Asks a question that spans sources, unsure where to look | `s1 ask "<question>"` |
| Wants the full page behind a search result | `s1 crawl <url>` |
| Wants news | `s1 news "<query>"` |
| Wants businesses or places on a map (where is, nearby, a list of shops) | `s1 maps "<what>"` |
| Wants to explore a site's links | `s1 sitemap <url>` |
| Wants trending topics | `s1 trending <service>` |
| Wants to check remaining credits | `s1 balance` |
Expand Down Expand Up @@ -162,6 +163,19 @@ like "this week", and returns at most 10 relevant results with their source
engine and relevance score. The first line of the output shows which engines and
window were used. Costs 5 credits per completed request.

### maps

```bash
s1 maps "<what to find>" [-n 1-20] [--near <lat,lng>] [--zoom 3-30] [-p 1-6] [--country <cc>] [-l <language>] [--json]
```

Finds businesses and places on Google Maps: name, category, rating, address,
phone, website, open state, and a Google Maps link. Put the area in the query
("ramen in Shibuya") or pass `--near` for a point; page 2 and later need
`--near`. Costs 3 credits per page of up to 20 places, however many you show,
so don't page further than the user needs. `crawl` a place's website for more
detail.

### crawl

```bash
Expand Down
57 changes: 57 additions & 0 deletions src/commands/maps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Command } from "commander";
import { maps, type MapsOptions } from "../sdk.js";
import { printMapsResults, printJson } from "../output.js";

function parseNumber(value: string, name: string): number {
const parsed = Number(value);
if (!Number.isFinite(parsed)) {
throw new Error(`${name} must be a number`);
}
return parsed;
}

/** `--near 40.7455,-74.0083` → `{ latitude, longitude }`. */
function parseNear(value: string): { latitude: number; longitude: number } {
const parts = value.split(",").map((part) => part.trim());
if (parts.length !== 2) {
throw new Error('--near must be "latitude,longitude", e.g. 40.7455,-74.0083');
}
return {
latitude: parseNumber(parts[0], "latitude"),
longitude: parseNumber(parts[1], "longitude"),
};
}

export function registerMapsCommand(program: Command): void {
program
.command("maps <query>")
.description("Find businesses and places on Google Maps (3 credits per page of up to 20)")
.option("-n, --max-results <number>", "places to return from the page (1-20)")
.option("--near <lat,lng>", "search around this point, e.g. 40.7455,-74.0083")
.option("--zoom <number>", "map zoom with --near (3-30, default 14)")
.option("-p, --page <number>", "Google Maps page (1-6); page 2+ needs --near")
.option("--country <code>", "two-letter country code (default us)")
.option("-l, --lang <language>", "result language, e.g. en, de, zh-CN (default en)")
.option("--json", "output raw JSON")
.action(async (query: string, opts) => {
const options: MapsOptions = {};
if (opts.maxResults) options.maxResults = parseInt(opts.maxResults);
if (opts.page) options.page = parseInt(opts.page);
if (opts.country) options.country = opts.country;
if (opts.lang) options.language = opts.lang;
if (opts.near) {
options.location = parseNear(opts.near);
if (opts.zoom) options.location.zoom = parseNumber(opts.zoom, "zoom");
} else if (opts.zoom) {
throw new Error("--zoom needs --near");
}

const data = await maps(query, options);

if (opts.json) {
printJson(data);
} else {
printMapsResults(data.results);
}
});
}
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if (isBinary && notifier.update) {
}
import { registerNewsCommand } from "./commands/news.js";
import { registerAskCommand } from "./commands/ask.js";
import { registerMapsCommand } from "./commands/maps.js";
import { registerCrawlCommand } from "./commands/crawl.js";
import { registerSitemapCommand } from "./commands/sitemap.js";
import { registerLearnCommand } from "./commands/learn.js";
Expand All @@ -45,12 +46,13 @@ const program = new Command();

program
.name("search1api")
.description("CLI for Search1API - search, ask, news, crawl, sitemap, learn & trending")
.description("CLI for Search1API - search, ask, maps, news, crawl, sitemap, learn & trending")
.version(pkg.version);

registerSearchCommand(program);
registerNewsCommand(program);
registerAskCommand(program);
registerMapsCommand(program);
registerCrawlCommand(program);
registerSitemapCommand(program);
registerLearnCommand(program);
Expand All @@ -69,6 +71,7 @@ if (process.argv.length <= 2) {
${chalk.bold("Quick start:")}
${chalk.blue("s1 search")} ${chalk.dim('"your query"')} Search the web
${chalk.blue("s1 ask")} ${chalk.dim('"your question"')} Let Search1API pick the sources
${chalk.blue("s1 maps")} ${chalk.dim('"coffee shops"')} Find places on Google Maps
${chalk.blue("s1 news")} ${chalk.dim('"your query"')} Search for news
${chalk.blue("s1 crawl")} ${chalk.dim("<url>")} Extract content from a URL
${chalk.blue("s1 learn")} ${chalk.dim("<url>")} Turn a URL into an Agent Skill
Expand Down
36 changes: 36 additions & 0 deletions src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,42 @@ export function printAskResults(data: AskResponse): void {
}
}

interface MapsPlace {
name: string;
maps_url: string;
address?: string;
phone?: string;
website?: string;
category?: string;
rating?: number;
review_count?: number;
open_state?: string;
price?: string;
}

export function printMapsResults(results: MapsPlace[]): void {
if (!results.length) {
console.log(chalk.yellow("No places found."));
return;
}

for (let i = 0; i < results.length; i++) {
const p = results[i];
console.log(chalk.bold.blue(`${i + 1}. ${p.name}`));
const rating =
p.rating !== undefined
? `${p.rating}★${p.review_count !== undefined ? ` (${p.review_count})` : ""}`
: undefined;
const summary = [p.category, rating, p.price, p.open_state].filter(Boolean).join(" · ");
if (summary) console.log(summary);
if (p.address) console.log(p.address);
const contact = [p.phone, p.website].filter(Boolean).join(" · ");
if (contact) console.log(contact);
console.log(chalk.dim(p.maps_url));
console.log();
}
}

export function printTrendingResults(results: TrendingResult[]): void {
if (!results.length) {
console.log(chalk.yellow("No trending results."));
Expand Down
62 changes: 62 additions & 0 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,51 @@ export interface AskResponse {
errors: Array<{ source: string; message: string }>;
}

export interface MapsLocation {
latitude: number;
longitude: number;
/** Map zoom, 3-30. The API defaults to 14. */
zoom?: number;
}

export interface MapsOptions extends RequestOptions {
/** Two-letter country code. The API defaults to `us`. */
country?: string;
/** Result language such as `en` or `zh-CN`. The API defaults to `en`. */
language?: string;
/** Search around this point. Required for page 2 and later. */
location?: MapsLocation;
/** Google Maps page, 1-6. Each page is billed separately. */
page?: number;
/** Places to return from the page, 1-20. Fewer places do not lower the price. */
maxResults?: number;
}

export interface MapsPlace {
position: number;
name: string;
place_id: string;
maps_url: string;
address?: string;
phone?: string;
website?: string;
thumbnail?: string;
category?: string;
categories?: string[];
rating?: number;
review_count?: number;
coordinates?: { latitude: number; longitude: number };
opening_hours?: Partial<Record<string, string>>;
open_state?: string;
price?: string;
description?: string;
}

export interface MapsResponse {
searchParameters: Record<string, unknown>;
results: MapsPlace[];
}

export interface TrendingOptions extends RequestOptions {
maxResults?: number;
}
Expand Down Expand Up @@ -190,6 +235,23 @@ export async function ask(
return request<AskResponse>("/ask", { query }, options);
}

/**
* Google Maps place search: one page of up to 20 businesses and places.
* 3 credits per completed page.
*/
export async function maps(
query: string,
options: MapsOptions = {}
): Promise<MapsResponse> {
const body: Record<string, unknown> = { query };
if (options.country) body.country = options.country;
if (options.language) body.language = options.language;
if (options.location) body.location = options.location;
if (options.page !== undefined) body.page = options.page;
if (options.maxResults !== undefined) body.max_results = options.maxResults;
return request<MapsResponse>("/maps", body, options);
}

export async function crawl(
url: string,
options: RequestOptions = {}
Expand Down
17 changes: 17 additions & 0 deletions tests/commands.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ test("exposes ask and the new search options", () => {
assert.match(searchHelp.stdout, /day, week, month, year/);
});

test("exposes maps with location options", () => {
const help = runCli("--help");
assert.equal(help.status, 0, help.stderr);
assert.match(help.stdout, /maps \[options\] <query>/);

const mapsHelp = runCli("maps", "--help");
assert.equal(mapsHelp.status, 0, mapsHelp.stderr);
assert.match(mapsHelp.stdout, /--near <lat,lng>/);
assert.match(mapsHelp.stdout, /--page <number>/);
});

test("maps rejects a malformed --near before calling the API", () => {
const result = runCli("maps", "coffee", "--near", "40.7");
assert.equal(result.status, 1);
assert.match(result.stderr, /--near must be "latitude,longitude"/);
});

test("points agents at s1 feedback when a command fails", () => {
const configDir = mkdtempSync(join(tmpdir(), "s1-config-"));
const { SEARCH1API_KEY: _key, ...env } = process.env;
Expand Down
28 changes: 27 additions & 1 deletion tests/sdk.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import test from "node:test";
process.env.SEARCH1API_KEY = "test-key";
process.env.SEARCH1API_API_BASE = "https://api.example.test";

const { ask, crawl, news, search, sitemap, trending } = await import("../dist/sdk.js");
const { ask, crawl, maps, news, search, sitemap, trending } = await import("../dist/sdk.js");

async function captureRequest(run, response) {
const originalFetch = globalThis.fetch;
Expand Down Expand Up @@ -131,3 +131,29 @@ test("ask sends only the query to /ask", async () => {
query: "recent papers on speculative decoding",
});
});

test("maps sends only the options that were set to /maps", async () => {
const response = { searchParameters: { query: "coffee shops" }, results: [] };
const { captured, result } = await captureRequest(
() =>
maps("coffee shops", {
location: { latitude: 40.7455, longitude: -74.0083, zoom: 15 },
page: 2,
maxResults: 5,
country: "us",
}),
response
);
assert.deepEqual(result, response);
assert.equal(captured.input, "https://api.example.test/maps");
assert.deepEqual(JSON.parse(captured.init.body), {
query: "coffee shops",
country: "us",
location: { latitude: 40.7455, longitude: -74.0083, zoom: 15 },
page: 2,
max_results: 5,
});

const minimal = await captureRequest(() => maps("ramen in Shibuya"), response);
assert.deepEqual(JSON.parse(minimal.captured.init.body), { query: "ramen in Shibuya" });
});
Loading