Skip to content

Commit 00211db

Browse files
feat(api): api update
1 parent 14914b3 commit 00211db

4 files changed

Lines changed: 42 additions & 22 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-795a81d4c022b9fa5ca31d453fb55d7b75c0b2424f9f4bda5a75762cbb1f9418.yml
3-
openapi_spec_hash: eeb4b6592caa69691a5acfa24b571daa
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-5ee7a321f8e01d2678d56277f011f71294c2b8ac4d0cff0bda412362c0d9cf73.yml
3+
openapi_spec_hash: bf5d57e3bddb6975770cf85c267b5035
44
config_hash: 682b89b02a20f5d1c13e2c91ecbcf5ce

packages/mcp-server/src/local-docs-search.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,20 @@ const EMBEDDED_METHODS: MethodEntry[] = [
202202
httpMethod: 'get',
203203
summary: 'Take screenshot of website',
204204
description:
205-
'Capture a screenshot of a website. Supports both viewport (standard browser view) and full-page screenshots. Can also screenshot specific page types (login, pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to the uploaded screenshot image hosted on our CDN.',
205+
"Capture a screenshot of a website. Supports both viewport (standard browser view) and full-page screenshots. Can also screenshot specific page types (login, pricing, etc.) by using heuristics to find the appropriate URL. Either 'domain' or 'directUrl' must be provided as a query parameter, but not both. Returns a URL to the uploaded screenshot image hosted on our CDN.",
206206
stainlessPath: '(resource) web > (method) screenshot',
207207
qualified: 'client.web.screenshot',
208208
params: [
209-
'domain: string;',
209+
'directUrl?: string;',
210+
'domain?: string;',
210211
"fullScreenshot?: 'true' | 'false';",
211212
"page?: 'login' | 'signup' | 'blog' | 'careers' | 'pricing' | 'terms' | 'privacy' | 'contact';",
212213
"prioritize?: 'speed' | 'quality';",
213214
],
214215
response:
215216
"{ code?: number; domain?: string; screenshot?: string; screenshotType?: 'viewport' | 'fullPage'; status?: string; }",
216217
markdown:
217-
"## screenshot\n\n`client.web.screenshot(domain: string, fullScreenshot?: 'true' | 'false', page?: 'login' | 'signup' | 'blog' | 'careers' | 'pricing' | 'terms' | 'privacy' | 'contact', prioritize?: 'speed' | 'quality'): { code?: number; domain?: string; screenshot?: string; screenshotType?: 'viewport' | 'fullPage'; status?: string; }`\n\n**get** `/brand/screenshot`\n\nCapture a screenshot of a website. Supports both viewport (standard browser view) and full-page screenshots. Can also screenshot specific page types (login, pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to the uploaded screenshot image hosted on our CDN.\n\n### Parameters\n\n- `domain: string`\n Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The domain will be automatically normalized and validated.\n\n- `fullScreenshot?: 'true' | 'false'`\n Optional parameter to determine screenshot type. If 'true', takes a full page screenshot capturing all content. If 'false' or not provided, takes a viewport screenshot (standard browser view).\n\n- `page?: 'login' | 'signup' | 'blog' | 'careers' | 'pricing' | 'terms' | 'privacy' | 'contact'`\n Optional parameter to specify which page type to screenshot. If provided, the system will scrape the domain's links and use heuristics to find the most appropriate URL for the specified page type (30 supported languages). If not provided, screenshots the main domain landing page.\n\n- `prioritize?: 'speed' | 'quality'`\n Optional parameter to prioritize screenshot capture. If 'speed', optimizes for faster capture with basic quality. If 'quality', optimizes for higher quality with longer wait times. Defaults to 'quality' if not provided.\n\n### Returns\n\n- `{ code?: number; domain?: string; screenshot?: string; screenshotType?: 'viewport' | 'fullPage'; status?: string; }`\n\n - `code?: number`\n - `domain?: string`\n - `screenshot?: string`\n - `screenshotType?: 'viewport' | 'fullPage'`\n - `status?: string`\n\n### Example\n\n```typescript\nimport ContextDev from 'context.dev';\n\nconst client = new ContextDev();\n\nconst response = await client.web.screenshot({ domain: 'domain' });\n\nconsole.log(response);\n```",
218+
"## screenshot\n\n`client.web.screenshot(directUrl?: string, domain?: string, fullScreenshot?: 'true' | 'false', page?: 'login' | 'signup' | 'blog' | 'careers' | 'pricing' | 'terms' | 'privacy' | 'contact', prioritize?: 'speed' | 'quality'): { code?: number; domain?: string; screenshot?: string; screenshotType?: 'viewport' | 'fullPage'; status?: string; }`\n\n**get** `/brand/screenshot`\n\nCapture a screenshot of a website. Supports both viewport (standard browser view) and full-page screenshots. Can also screenshot specific page types (login, pricing, etc.) by using heuristics to find the appropriate URL. Either 'domain' or 'directUrl' must be provided as a query parameter, but not both. Returns a URL to the uploaded screenshot image hosted on our CDN.\n\n### Parameters\n\n- `directUrl?: string`\n A specific URL to screenshot directly, bypassing domain resolution (e.g., 'https://example.com/pricing'). When provided, the screenshot is taken of this exact URL.\n\n- `domain?: string`\n Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The domain will be automatically normalized and validated.\n\n- `fullScreenshot?: 'true' | 'false'`\n Optional parameter to determine screenshot type. If 'true', takes a full page screenshot capturing all content. If 'false' or not provided, takes a viewport screenshot (standard browser view).\n\n- `page?: 'login' | 'signup' | 'blog' | 'careers' | 'pricing' | 'terms' | 'privacy' | 'contact'`\n Optional parameter to specify which page type to screenshot. If provided, the system will scrape the domain's links and use heuristics to find the most appropriate URL for the specified page type (30 supported languages). If not provided, screenshots the main domain landing page. Only applicable when using 'domain', not 'directUrl'.\n\n- `prioritize?: 'speed' | 'quality'`\n Optional parameter to prioritize screenshot capture. If 'speed', optimizes for faster capture with basic quality. If 'quality', optimizes for higher quality with longer wait times. Defaults to 'quality' if not provided.\n\n### Returns\n\n- `{ code?: number; domain?: string; screenshot?: string; screenshotType?: 'viewport' | 'fullPage'; status?: string; }`\n\n - `code?: number`\n - `domain?: string`\n - `screenshot?: string`\n - `screenshotType?: 'viewport' | 'fullPage'`\n - `status?: string`\n\n### Example\n\n```typescript\nimport ContextDev from 'context.dev';\n\nconst client = new ContextDev();\n\nconst response = await client.web.screenshot();\n\nconsole.log(response);\n```",
218219
perLanguage: {
219220
http: {
220221
example:
@@ -223,17 +224,17 @@ const EMBEDDED_METHODS: MethodEntry[] = [
223224
python: {
224225
method: 'web.screenshot',
225226
example:
226-
'import os\nfrom context.dev import ContextDev\n\nclient = ContextDev(\n api_key=os.environ.get("CONTEXT_DEV_API_KEY"), # This is the default and can be omitted\n)\nresponse = client.web.screenshot(\n domain="domain",\n)\nprint(response.code)',
227+
'import os\nfrom context.dev import ContextDev\n\nclient = ContextDev(\n api_key=os.environ.get("CONTEXT_DEV_API_KEY"), # This is the default and can be omitted\n)\nresponse = client.web.screenshot()\nprint(response.code)',
227228
},
228229
ruby: {
229230
method: 'web.screenshot',
230231
example:
231-
'require "context_dev"\n\ncontext_dev = ContextDev::Client.new(api_key: "My API Key")\n\nresponse = context_dev.web.screenshot(domain: "domain")\n\nputs(response)',
232+
'require "context_dev"\n\ncontext_dev = ContextDev::Client.new(api_key: "My API Key")\n\nresponse = context_dev.web.screenshot\n\nputs(response)',
232233
},
233234
typescript: {
234235
method: 'client.web.screenshot',
235236
example:
236-
"import ContextDev from 'context.dev';\n\nconst client = new ContextDev({\n apiKey: process.env['CONTEXT_DEV_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.web.screenshot({ domain: 'domain' });\n\nconsole.log(response.code);",
237+
"import ContextDev from 'context.dev';\n\nconst client = new ContextDev({\n apiKey: process.env['CONTEXT_DEV_API_KEY'], // This is the default and can be omitted\n});\n\nconst response = await client.web.screenshot();\n\nconsole.log(response.code);",
237238
},
238239
},
239240
},

src/resources/web.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ export class Web extends APIResource {
88
/**
99
* Capture a screenshot of a website. Supports both viewport (standard browser
1010
* view) and full-page screenshots. Can also screenshot specific page types (login,
11-
* pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to
12-
* the uploaded screenshot image hosted on our CDN.
11+
* pricing, etc.) by using heuristics to find the appropriate URL. Either 'domain'
12+
* or 'directUrl' must be provided as a query parameter, but not both. Returns a
13+
* URL to the uploaded screenshot image hosted on our CDN.
1314
*/
14-
screenshot(query: WebScreenshotParams, options?: RequestOptions): APIPromise<WebScreenshotResponse> {
15+
screenshot(
16+
query: WebScreenshotParams | null | undefined = {},
17+
options?: RequestOptions,
18+
): APIPromise<WebScreenshotResponse> {
1519
return this._client.get('/brand/screenshot', { query, ...options });
1620
}
1721

@@ -287,11 +291,18 @@ export namespace WebWebScrapeSitemapResponse {
287291
}
288292

289293
export interface WebScreenshotParams {
294+
/**
295+
* A specific URL to screenshot directly, bypassing domain resolution (e.g.,
296+
* 'https://example.com/pricing'). When provided, the screenshot is taken of this
297+
* exact URL.
298+
*/
299+
directUrl?: string;
300+
290301
/**
291302
* Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The
292303
* domain will be automatically normalized and validated.
293304
*/
294-
domain: string;
305+
domain?: string;
295306

296307
/**
297308
* Optional parameter to determine screenshot type. If 'true', takes a full page
@@ -304,7 +315,8 @@ export interface WebScreenshotParams {
304315
* Optional parameter to specify which page type to screenshot. If provided, the
305316
* system will scrape the domain's links and use heuristics to find the most
306317
* appropriate URL for the specified page type (30 supported languages). If not
307-
* provided, screenshots the main domain landing page.
318+
* provided, screenshots the main domain landing page. Only applicable when using
319+
* 'domain', not 'directUrl'.
308320
*/
309321
page?: 'login' | 'signup' | 'blog' | 'careers' | 'pricing' | 'terms' | 'privacy' | 'contact';
310322

tests/api-resources/web.test.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const client = new ContextDev({
99

1010
describe('resource web', () => {
1111
// Mock server tests are disabled
12-
test.skip('screenshot: only required params', async () => {
13-
const responsePromise = client.web.screenshot({ domain: 'domain' });
12+
test.skip('screenshot', async () => {
13+
const responsePromise = client.web.screenshot();
1414
const rawResponse = await responsePromise.asResponse();
1515
expect(rawResponse).toBeInstanceOf(Response);
1616
const response = await responsePromise;
@@ -21,13 +21,20 @@ describe('resource web', () => {
2121
});
2222

2323
// Mock server tests are disabled
24-
test.skip('screenshot: required and optional params', async () => {
25-
const response = await client.web.screenshot({
26-
domain: 'domain',
27-
fullScreenshot: 'true',
28-
page: 'login',
29-
prioritize: 'speed',
30-
});
24+
test.skip('screenshot: request options and params are passed correctly', async () => {
25+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
26+
await expect(
27+
client.web.screenshot(
28+
{
29+
directUrl: 'https://example.com',
30+
domain: 'domain',
31+
fullScreenshot: 'true',
32+
page: 'login',
33+
prioritize: 'speed',
34+
},
35+
{ path: '/_stainless_unknown_path' },
36+
),
37+
).rejects.toThrow(ContextDev.NotFoundError);
3138
});
3239

3340
// Mock server tests are disabled

0 commit comments

Comments
 (0)