Skip to content

Commit 6f1e0a2

Browse files
feat: add typed API responses and fix sync/async endpoint classification
Replace ApiResult<unknown> with proper response types for all endpoints. Only crawl uses polling now — all other endpoints are direct POST calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 17ef0a5 commit 6f1e0a2

10 files changed

Lines changed: 204 additions & 130 deletions

File tree

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,26 @@ Command-line interface for [ScrapeGraph AI](https://scrapegraphai.com) — AI-po
1111

1212
```
1313
just-scrape/
14+
├── docs/ # API response docs per endpoint
15+
│ ├── smartscraper.md
16+
│ ├── searchscraper.md
17+
│ ├── markdownify.md
18+
│ ├── crawl.md
19+
│ ├── scrape.md
20+
│ ├── agenticscraper.md
21+
│ ├── generate-schema.md
22+
│ ├── sitemap.md
23+
│ └── credits.md
1424
├── src/
1525
│ ├── cli.ts # Entry point, citty main command + subcommands
1626
│ ├── lib/
1727
│ │ ├── env.ts # Zod-parsed env config (API key, debug, timeout)
1828
│ │ ├── folders.ts # API key resolution + interactive prompt
19-
│ │ ├── scrapegraphai.ts # SDK layer — all API functions
29+
│ │ ├── scrapegraphai.ts # SDK layer — all API functions (typed responses)
2030
│ │ ├── schemas.ts # Zod validation schemas
2131
│ │ └── log.ts # Logger factory + syntax-highlighted JSON output
2232
│ ├── types/
23-
│ │ └── index.ts # Zod-derived types + ApiResult
33+
│ │ └── index.ts # Zod-derived types + ApiResult + response types
2434
│ ├── commands/
2535
│ │ ├── smart-scraper.ts
2636
│ │ ├── search-scraper.ts

src/commands/agentic-scraper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default defineCommand({
4343
if (args["use-session"]) params.use_session = true;
4444

4545
out.start("Running browser automation");
46-
const result = await scrapegraphai.agenticScraper(key, params, out.poll);
46+
const result = await scrapegraphai.agenticScraper(key, params);
4747
out.stop(result.elapsedMs);
4848

4949
if (result.data) out.result(result.data);

src/commands/generate-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default defineCommand({
2828
if (args["existing-schema"]) params.existing_schema = JSON.parse(args["existing-schema"]);
2929

3030
out.start("Generating schema");
31-
const result = await scrapegraphai.generateSchema(key, params, out.poll);
31+
const result = await scrapegraphai.generateSchema(key, params);
3232
out.stop(result.elapsedMs);
3333

3434
if (result.data) out.result(result.data);

src/commands/markdownify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default defineCommand({
3131
if (args.headers) params.headers = JSON.parse(args.headers);
3232

3333
out.start("Converting to markdown");
34-
const result = await scrapegraphai.markdownify(key, params, out.poll);
34+
const result = await scrapegraphai.markdownify(key, params);
3535
out.stop(result.elapsedMs);
3636

3737
if (result.data) out.result(result.data);

src/commands/scrape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default defineCommand({
3131
if (args["country-code"]) params.country_code = args["country-code"];
3232

3333
out.start("Scraping");
34-
const result = await scrapegraphai.scrape(key, params, out.poll);
34+
const result = await scrapegraphai.scrape(key, params);
3535
out.stop(result.elapsedMs);
3636

3737
if (result.data) out.result(result.data);

src/commands/search-scraper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default defineCommand({
4343
if (args.headers) params.headers = JSON.parse(args.headers);
4444

4545
out.start("Searching");
46-
const result = await scrapegraphai.searchScraper(key, params, out.poll);
46+
const result = await scrapegraphai.searchScraper(key, params);
4747
out.stop(result.elapsedMs);
4848

4949
if (result.data) out.result(result.data);

src/commands/smart-scraper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default defineCommand({
4848
if (args["plain-text"]) params.plain_text = true;
4949

5050
out.start("Scraping");
51-
const result = await scrapegraphai.smartScraper(key, params, out.poll);
51+
const result = await scrapegraphai.smartScraper(key, params);
5252
out.stop(result.elapsedMs);
5353

5454
if (result.data) out.result(result.data);

0 commit comments

Comments
 (0)