webcrawlerapi-js 2.2.2 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { CrawlRequest, Job, JobId, ScrapeRequest, ScrapeResponse, ScrapeResponseError, ScrapeId, JobMarkdownResponse, AgentRunRequest, AgentRun } from "./model";
1
+ import { CrawlRequest, Job, JobId, ScrapeRequest, ScrapeResponse, ScrapeResponseError, ScrapeId, JobMarkdownResponse, MarkdownRequest, MarkdownResponse, AgentRunRequest, AgentRun } from "./model";
2
2
  import { JobStatus, ErrorCode } from "./constants";
3
3
  import { WebcrawlerApiError } from "./errors";
4
4
  export { WebcrawlerApiError, JobStatus, ErrorCode };
@@ -20,5 +20,6 @@ export declare class WebcrawlerClient {
20
20
  getJob(jobID: string): Promise<Job>;
21
21
  getJobMarkdown(jobID: string): Promise<JobMarkdownResponse>;
22
22
  getJobMarkdownContent(jobID: string): Promise<string>;
23
+ markdown(request: MarkdownRequest): Promise<MarkdownResponse>;
23
24
  private sendRequest;
24
25
  }
@@ -120,6 +120,15 @@ export interface UploadS3Action extends Action {
120
120
  export interface JobMarkdownResponse {
121
121
  content_url: string;
122
122
  }
123
+ export interface MarkdownRequest {
124
+ /** The URL of the webpage to extract the article markdown from. */
125
+ url: string;
126
+ }
127
+ export interface MarkdownResponse {
128
+ success: boolean;
129
+ /** Cleaned article markdown (main content only). */
130
+ markdown?: string;
131
+ }
123
132
  export interface AgentRunRequest {
124
133
  /** Natural-language task for the agent to complete. */
125
134
  prompt: string;
package/dist/api.js CHANGED
@@ -328,6 +328,15 @@ class WebcrawlerClient {
328
328
  }
329
329
  return response.text();
330
330
  }
331
+ async markdown(request) {
332
+ const url = `${this.basePath}/markdown`;
333
+ const requestOptions = {
334
+ 'method': 'POST',
335
+ 'headers': this.getDefaultHeaders(),
336
+ 'body': JSON.stringify(request),
337
+ };
338
+ return this.sendRequest(url, requestOptions);
339
+ }
331
340
  async sendRequest(url, requestOptions) {
332
341
  let response;
333
342
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcrawlerapi-js",
3
- "version": "2.2.2",
3
+ "version": "2.2.5",
4
4
  "description": "JS client for WebcrawlerAPI",
5
5
  "main": "./dist/api.js",
6
6
  "types": "./dist/@types/api.d.ts",