Skip to content

feat: add apify api subcommand for direct API access#1076

Open
patrikbraborec wants to merge 5 commits intomasterfrom
feat/apify-api-subcommand
Open

feat: add apify api subcommand for direct API access#1076
patrikbraborec wants to merge 5 commits intomasterfrom
feat/apify-api-subcommand

Conversation

@patrikbraborec
Copy link
Copy Markdown
Contributor

Summary

Adds apify api — a general-purpose authenticated HTTP client for the Apify API, inspired by gh api.

  • apify api v2/users/me — make authenticated GET requests
  • apify api v2/acts --method POST --body '{...}' — create resources
  • apify api --list-endpoints — browse all 129 API endpoints (from bundled OpenAPI spec)

Features

  • HTTP methods via --method / -X (GET, POST, PUT, PATCH, DELETE)
  • Request body via --body / -d (JSON string or stdin with -)
  • Custom headers via --header / -H
  • --list-endpoints / -l — lists all available endpoints with color-coded methods and descriptions, powered by the Apify OpenAPI spec fetched at build time

Closes #1075

🤖 Generated with Claude Code

@github-actions github-actions bot added t-c&c Team covering store and finance matters. tested Temporary label used only programatically for some analytics. labels Apr 8, 2026
@patrikbraborec patrikbraborec added t-dx Issues owned by the DX team. and removed t-c&c Team covering store and finance matters. labels Apr 8, 2026
patrikbraborec and others added 4 commits April 15, 2026 15:06
Add a general-purpose authenticated HTTP client for the Apify API,
similar to `gh api` in GitHub CLI. Supports GET/POST/PUT/PATCH/DELETE
methods, request body (including stdin), custom headers, and a
--list-endpoints flag powered by the bundled OpenAPI spec.

Closes #1075

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add missing `return` after `printHelp()` to prevent fetch with undefined endpoint
- Make build resilient to network failures by falling back to committed api-endpoints.json
- Commit api-endpoints.json so fresh checkouts work without network access
- Wrap test cleanup in try/finally to prevent actor leak on assertion failure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…y params, and lint fix

Add support for positional HTTP method syntax (e.g. `apify api GET /v2/users/me`),
auto-prepend `v2/` prefix when omitted, add `--params` flag for query parameters,
use `getLoggedClientOrThrow` for auth, switch to `simpleLog` for output, validate
JSON body before sending, and fix prefer-destructuring lint error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tighten input validation in `apify api`: extract parseParams/parseHeaders
helpers, support multi-header JSON form, reject nested/non-scalar query
params, and detect conflicts between the positional HTTP method and the
--method flag. Derive the base URL from apifyClient.baseUrl so the v2
prefix and APIFY_CLIENT_BASE_URL are handled in one place, and hint at
--list-endpoints on 404 responses.

Register the command in the docs generator (and regenerate docs). Move
fetch-api-endpoints out of `build` into `prepack` so local builds do not
require network access.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@patrikbraborec patrikbraborec force-pushed the feat/apify-api-subcommand branch from 1ab31a3 to 3ab62dd Compare April 15, 2026 14:08
@patrikbraborec patrikbraborec marked this pull request as ready for review April 15, 2026 14:10
useConsoleSpy sets restoreMocks: false, so spy.mock.calls accumulates
across tests. Reading calls[0][0] returned the first test's v2/users/me
response on every subsequent test — passing by coincidence when checking
.data.id/.username, failing when checking .data.items or .data.name.
Switch to logMessages.log[0], which resets per test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-dx Issues owned by the DX team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add apify api subcommand as a general-purpose authenticated HTTP client for the Apify API

3 participants