feat(api): add --verbose, --paginate, --no-auth flags + log resolved URL to apify api#1251
Draft
DaveHanns wants to merge 1 commit into
Draft
feat(api): add --verbose, --paginate, --no-auth flags + log resolved URL to apify api#1251DaveHanns wants to merge 1 commit into
DaveHanns wants to merge 1 commit into
Conversation
`apify api` is the escape-hatch REST tool but agents debugging with it currently
have no way to see the resolved outbound URL, no shortcut for walking a
paginated endpoint, and no way to hit auth-less resources through the same
command. This adds three additive, independent flags:
- --verbose (-v): logs "-> METHOD URL" to stderr before the fetch and
"<- STATUS (content-type)" after, so callers can see exactly what the CLI
sent and what came back.
- --paginate: for endpoints returning { data: { items, total, offset, limit } },
automatically advances offset until exhausted and emits all items as a single
JSON array on stdout. Pair with --paginate-max N to cap. Fails loudly if the
response is not paginated (never silently truncates).
- --no-auth: skips the Authorization header. Accepts absolute URLs verbatim so
the same escape hatch can reach public resources like raw.githubusercontent.com
(e.g. actor-templates manifest) without requiring a login.
None of the flags change existing behavior when omitted; all three compose.
Refs internal findings F31 + EF8.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apify apiis a great REST escape hatch, but when an agent (or a human) uses it todebug, three things are painful: the resolved outbound URL is invisible, walking a
paginated endpoint requires a manual offset loop, and hitting an auth-less resource
(e.g. the
actor-templatesmanifest on raw GitHub) requires reaching forcurlinstead of the same command. This PR adds three additive, independent flags —
--verbose,--paginate(+--paginate-max), and--no-auth— to close thosegaps without changing any existing behavior.
Refs internal findings F31 + EF8.
What changes
src/commands/api.tsonly. All flags default to off; omitting them yieldsbyte-identical behavior to today.
--verbose/-v— logs-> METHOD URLto stderr before the fetch and<- STATUS statusText (content-type)after. Payload still goes to stdout, soapify api ... --verbose | jq .keeps working.--paginate— for responses shaped like{ data: { items, total, offset, limit } }(the Apify pagination envelope), advancesoffsetuntiltotalisexhausted and emits all collected items as a single JSON array on stdout.
Errors loudly with a clear message if the response isn't paginated instead of
silently truncating.
--paginaterestricted toGET.--paginate-max N— cap items collected across pagination.--no-auth— skips theAuthorizationheader. Also lets the endpointargument be an absolute
https://...URL so the same command can hitraw.githubusercontent.cometc. When--no-authis set we do not require alogged-in client (so this works out of the box in fresh environments).
Also adds four
apify api --helpexamples covering the new flags.Test plan
apify api users/me --verboseprints the resolvedGET https://api.apify.com/v2/users/meline and status line to stderr; payload still lands on stdout.apify api acts --paginatewalks all pages and emits one JSON array; the array length equalsdata.totalof the first page.apify api acts --paginate --paginate-max 5returns exactly 5 items.apify api POST acts --paginateerrors out with "can only be used with GET requests".apify api users/me --paginateerrors out with "expected a { data: { items } } response shape".apify api --no-auth https://raw.githubusercontent.com/apify/actor-templates/master/templates/manifest.jsonfetches the file without anAuthorizationheader, even when not logged in.apify api acts --paginate --verbose --paginate-max 10prints request/response lines per page and returns 10 items.pnpm exec oxlint --type-aware src/commands/api.tspasses.pnpm exec tsc --noEmit -p .passes.