Skip to content

Commit 748c0b5

Browse files
feat: add EXAMPLES block and docsUrl to apify api
Moves the inline example blocks out of the description and into the framework's `examples` field (added in #1080) so they render as the standard shell-comment EXAMPLES block, matching every other command. Also wires up `docsUrl` to surface the API reference in LEARN MORE. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cf00e6f commit 748c0b5

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

src/commands/api.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,38 @@ export class ApiCommand extends ApifyCommand<typeof ApiCommand> {
111111

112112
static override description =
113113
'Makes an authenticated HTTP request to the Apify API and prints the response.\n' +
114-
'The endpoint can be a relative path (e.g. "acts", "v2/acts", or "/v2/acts").\n' +
115-
'The "v2/" prefix is added automatically if omitted.\n\n' +
116-
'You can also pass the HTTP method before the endpoint:\n' +
117-
' apify api GET /v2/actor-runs\n' +
118-
' apify api POST /v2/acts -d \'{"name": "my-actor"}\'\n\n' +
119-
'Use --params/-p to pass query parameters as JSON:\n' +
120-
' apify api actor-runs -p \'{"limit": 1, "desc": true}\'\n\n' +
121-
'Use --list-endpoints to see all available API endpoints.\n' +
122-
'For full documentation, see https://docs.apify.com/api/v2';
114+
'The endpoint can be a relative path (e.g. "acts", "v2/acts", or "/v2/acts"); ' +
115+
'the "v2/" prefix is added automatically if omitted.\n\n' +
116+
'Use --list-endpoints to see all available API endpoints.';
117+
118+
static override examples = [
119+
{
120+
description: 'Make a GET request to an API endpoint (defaults to GET).',
121+
command: 'apify api users/me',
122+
},
123+
{
124+
description: 'Pass the HTTP method as a positional argument before the endpoint.',
125+
command: 'apify api GET /v2/actor-runs',
126+
},
127+
{
128+
description: 'Create a resource by POSTing a JSON body.',
129+
command: `apify api POST acts -d '{"name":"my-actor"}'`,
130+
},
131+
{
132+
description: 'Pass query parameters as a JSON object.',
133+
command: `apify api actor-runs -p '{"limit":1,"desc":true}'`,
134+
},
135+
{
136+
description: 'Send one or more custom headers as a JSON object.',
137+
command: `apify api acts -H '{"X-Foo":"bar","X-Baz":"qux"}'`,
138+
},
139+
{
140+
description: 'List all available Apify API endpoints.',
141+
command: 'apify api --list-endpoints',
142+
},
143+
];
144+
145+
static override docsUrl = 'https://docs.apify.com/api/v2';
123146

124147
static override args = {
125148
methodOrEndpoint: Args.string({

0 commit comments

Comments
 (0)