feat!: kwargs API — replace *Request objects on public methods#88
feat!: kwargs API — replace *Request objects on public methods#88VinciGit00 merged 6 commits intomainfrom
Conversation
BREAKING CHANGE: Public client methods now accept keyword arguments
directly instead of Pydantic *Request objects. This matches the JS SDK
and conventional Python SDK ergonomics (OpenAI, Anthropic, Stripe).
Before:
sgai.scrape(ScrapeRequest(url="https://example.com", formats=[...]))
After:
sgai.scrape("https://example.com", formats=[...])
The *Request classes remain exported for users who want to build
payloads manually, but are no longer accepted by the client methods.
Structured types (FetchConfig, format configs, schema dicts) still
passed as-is.
- Refactored ScrapeGraphAI + AsyncScrapeGraphAI sync/async methods
- Added _compact helper to strip None kwargs so Pydantic defaults apply
- Updated all 30 examples and README
- Updated unit + integration tests
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Bump minor for new kwargs-based public API (see #88). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The union type was awkwardly named. FormatConfig matches the naming of its members (MarkdownFormatConfig, HtmlFormatConfig, ...) and reads naturally in signatures: formats: list[FormatConfig]. Also exported from the top-level package so users can type-annotate their own code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Renames: - ApiService -> Service - ApiHtmlMode -> HtmlMode - ApiFetchMode -> FetchMode - ApiTimeRange -> TimeRange - ApiCrawlStatus -> CrawlStatus - ApiCrawlPageStatus -> CrawlPageStatus - ApiHistoryStatus -> HistoryStatus - ApiFetchContentType -> FetchContentType - ApiMonitorTickStatus -> MonitorTickStatus Removed (unused): - ApiStatus - ApiScrapeFormat - ApiHistoryService (duplicate of ApiService) Kept: ApiResult. The prefix earns its keep there since it's semantically distinct from the *Response types and "Result[T]" alone would be too generic. All aliases now exported from scrapegraph_py for user type annotations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
845f2ea to
8391478
Compare
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
*Requestobjects — matches the JS SDK and standard Python SDK ergonomics (OpenAI, Anthropic, Stripe).*Requestclasses remain exported for users who want to build payloads manually, but client methods no longer accept them.FetchConfig, format configs,schemadicts) are still passed as-is.Before / After
Scope
ScrapeGraphAI/AsyncScrapeGraphAI:scrape,extract,searchcrawl.startmonitor.create,monitor.update,monitor.activityhistory.listcredits,health,crawl.get/stop/resume/delete,monitor.get/list/delete/pause/resume,history.getInternal detail
A small
_compacthelper stripsNonekwargs so Pydantic fields with non-None defaults (e.g.formats,max_depth,page) fall back to their defaults instead of raising a ValidationError onNone.Breaking Change
Callers must switch from
sgai.method(SomeRequest(...))→sgai.method(...)per the new signatures. Suggest minor version bump (2.1.0) — fresh 2.x line, low blast radius.Test plan
uv run pytest tests/)credits,scrape,search,crawl.start+ poll,extract(with and without schema) all succeeduv run ruff format src testscleanuv run ruff check src testscleanuv buildsucceedsFiles
src/scrapegraph_py/{client,async_client}.py— public method signaturestests/test_client.py,tests/test_integration.py— updated call sitesexamples/**/*.py— all 30 examples updatedREADME.md— every snippet updated🤖 Generated with Claude Code