Skip to content

feat(crawl): make depth optional; defaults are 100 pages and 100 items - #36

Closed
gonzalo-zenrows wants to merge 1 commit into
feat/crawl-client-v2from
feat/crawl-optional-depth
Closed

gonzalo-zenrows wants to merge 1 commit into
feat/crawl-client-v2from
feat/crawl-optional-depth

Conversation

@gonzalo-zenrows

Copy link
Copy Markdown

Summary

depth is now optional on ZenRowsCrawlClient.create() and on the Crawl model, and the docs give the API's new defaults of 100 for max_pages and max_items. Stacked on #31: merge after it.

What the task asked for

The Crawl API changes POST /v1/crawls in three ways:

  • depth is optional. Left out or null, the crawl has no depth limit. It follows links until max_pages or max_items stops it, or it runs out of links to open. An explicit depth is still 1 to 100,000. Anything else gets 422 invalid_parameter.
  • max_pages and max_items default to 100 instead of 10. The caps stay at 100,000.
  • A crawl created without depth comes back from create, get and list with no depth field. A crawl created with one still echoes it.

How the check confirmed it

Unit tests check that a create without depth sends {"url": ...} only and reads depth is None. They also check that a create with depth=1 sends it, and that list parses a page that mixes both. 220 passed. ruff check and ruff format --check are clean, ty reports nothing new, and mypy --strict on the acceptance type-check file shows depth: int | None. Check 1's offline half now creates without depth, and check 21 expects 100.

How to try it

crawl = client.create("https://www.scrapingcourse.com/ecommerce/", max_pages=20)
print(crawl.depth)  # None: no depth limit

Provenance

  • depth: int | None = None, sent only when given, matching the other optional create arguments.

Review

Pass Model Findings
1, review of the diff before opening AI assistant None

Human must verify:

  • The API change is live before acceptance check 21 runs: until then it reads 10 and fails.

Record owed

None in this repo. The changelog entry for the new defaults ships with the API.

Deviations

  • The README quickstart keeps depth=1 and max_pages=100, so the harness's cost substitutions still apply.

The Crawl API now accepts a create without depth: the crawl has no
depth limit and follows links until max_pages or max_items stops it,
or no link is left. max_pages and max_items now default to 100.

- create(): depth is an optional keyword, sent only when given.
- Crawl.depth is optional: a crawl created without depth omits it.
- README and docstrings state the new defaults.
- Acceptance: check 21 expects the documented default of 100; check 1's
  offline half creates without depth and expects none sent or read back.
@ZenRows ZenRows deleted a comment from linear Bot Oct 12, 2026
@StefanoGuerrini
StefanoGuerrini self-requested a review October 13, 2026 07:05
@StefanoGuerrini
StefanoGuerrini marked this pull request as ready for review October 13, 2026 07:05

Copy link
Copy Markdown
Contributor

Folded into #31, which now carries this change, so the Crawl client ships as one pull request.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants