@hydrafetch/node-sdk 0.6.0 → 0.7.1

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.
package/README.md CHANGED
@@ -127,7 +127,7 @@ tells the model which one you meant. The same works in a plain JSON Schema with
127
127
 
128
128
  ```ts
129
129
  const { links } = await hf.map('https://example.com', { limit: 1000 });
130
- const docs = links.filter((url) => url.includes('/docs/'));
130
+ const docs = links.map((l) => l.url).filter((url) => url.includes('/docs/'));
131
131
  ```
132
132
 
133
133
  `batchAndWait` and `crawlAndWait` submit a job and poll until it finishes.
@@ -166,6 +166,18 @@ const { results } = await hf.search('post-quantum TLS adoption', {
166
166
  results.forEach((r) => console.log(r.title, r.url, r.data?.markdown));
167
167
  ```
168
168
 
169
+ ## News
170
+
171
+ Find recent news articles about anything, newest first, each with its outlet and publish time:
172
+
173
+ ```ts
174
+ const { results } = await hf.news('acme raises funding', { timeRange: 'week', limit: 10 });
175
+
176
+ results.forEach((a) => console.log(a.publishedAt, a.source, a.title, a.url));
177
+ ```
178
+
179
+ A news search costs 1 credit, and one that finds nothing is free. Set `scrapeResults: true` to also read each article as clean data, at 1 extra credit per article.
180
+
169
181
  ## Jobs
170
182
 
171
183
  Search open jobs collected from company career sites and hiring platforms, by the words in the job title:
@@ -276,6 +288,7 @@ const hf = new Hydrafetch({
276
288
  | `markdown(url, options?)` | `string` | 1 |
277
289
  | `map(url, options?)` | `MapResult` | 1 |
278
290
  | `search(query, options?)` | `SearchResult` | 1 + 1 per scraped result |
291
+ | `news(query, options?)` | `NewsResult` | 1 + 1 per article read; free when empty |
279
292
  | `searchJobs(query, options?)` | `OpenJob[]` | 1 per 10 jobs |
280
293
  | `hiringChanges(domains, since, options?)` | `CompanyHiringChanges[]` | 1 per company with jobs |
281
294
  | `extract(urls, options?)` | `ExtractResult<T>` | 5 per URL |
package/dist/index.cjs CHANGED
@@ -235,6 +235,9 @@ var Hydrafetch = class {
235
235
  search(query, options = {}) {
236
236
  return this.request("POST", "/v1/web/search", { query, ...options });
237
237
  }
238
+ news(query, options = {}) {
239
+ return this.request("POST", "/v1/web/news", { query, ...options });
240
+ }
238
241
  searchJobs(query, options = {}) {
239
242
  return this.request("POST", "/v1/web/index/jobs/search", { query, ...options });
240
243
  }
package/dist/index.d.cts CHANGED
@@ -67,9 +67,14 @@ interface MapOptions {
67
67
  includeSubdomains?: boolean;
68
68
  ignoreQueryParameters?: boolean;
69
69
  }
70
+ interface MapLink {
71
+ url: string;
72
+ /** When the site's sitemap says the page last changed, or null when it does not say. */
73
+ lastmod: string | null;
74
+ }
70
75
  interface MapResult {
71
76
  url: string;
72
- links: string[];
77
+ links: MapLink[];
73
78
  count: number;
74
79
  total?: number;
75
80
  truncated?: boolean;
@@ -323,6 +328,41 @@ interface CompanyHiringChanges {
323
328
  closed: HiringChangePosting[];
324
329
  truncated: boolean;
325
330
  }
331
+ type NewsTimeRange = 'hour' | 'day' | 'week' | 'month';
332
+ interface NewsOptions {
333
+ /** Max articles to return, 1 to 50 (default 10). */
334
+ limit?: number;
335
+ /** Only articles published within this window before now (default "week"). */
336
+ timeRange?: NewsTimeRange;
337
+ /** ISO 3166 alpha-2 country code to lean results toward, like "us". */
338
+ country?: string;
339
+ /** Only articles from these sites, up to 15. */
340
+ includeDomains?: string[];
341
+ /** Drop articles from these sites, up to 15. */
342
+ excludeDomains?: string[];
343
+ /** Also read each article as clean data, 1 extra credit per article read. */
344
+ scrapeResults?: boolean;
345
+ scrapeOptions?: ScrapeOptions;
346
+ }
347
+ interface NewsArticle {
348
+ title: string;
349
+ /** The article's address on the publisher's own site. */
350
+ url: string;
351
+ /** The outlet that published it. */
352
+ source: string | null;
353
+ /** When it was published, ISO 8601. */
354
+ publishedAt: string;
355
+ snippet: string | null;
356
+ imageUrl: string | null;
357
+ /** The article read as clean data when scrapeResults is on, otherwise null. */
358
+ data: ScrapeResult | null;
359
+ }
360
+ interface NewsResult {
361
+ query: string;
362
+ status: 'ok' | 'no_results';
363
+ /** Newest first. */
364
+ results: NewsArticle[];
365
+ }
326
366
 
327
367
  interface HydrafetchOptions {
328
368
  apiKey?: string;
@@ -346,6 +386,7 @@ declare class Hydrafetch {
346
386
  rateResult(input: RateResultInput): Promise<RateResultResponse>;
347
387
  map(url: string, options?: MapOptions): Promise<MapResult>;
348
388
  search(query: string, options?: SearchOptions): Promise<SearchResult>;
389
+ news(query: string, options?: NewsOptions): Promise<NewsResult>;
349
390
  searchJobs(query: string, options?: SearchJobsOptions): Promise<OpenJob[]>;
350
391
  hiringChanges(domains: string | string[], since: string | Date, options?: HiringChangesOptions): Promise<CompanyHiringChanges[]>;
351
392
  extract<T = unknown>(urls: string | string[], options?: ExtractOptions): Promise<ExtractResult<T>>;
@@ -387,4 +428,4 @@ declare class HydrafetchTimeoutError extends HydrafetchError {
387
428
  constructor(message: string);
388
429
  }
389
430
 
390
- export { type BatchOptions, type BrandOptions, type BrandResult, type CompanyHiringChanges, type CrawlOptions, type ExtractItem, type ExtractOptions, type ExtractResult, type ExtractSchema, type Format, type HiringChangePosting, type HiringChangesOptions, type HiringCounts, Hydrafetch, HydrafetchError, type HydrafetchOptions, HydrafetchTimeoutError, type ImagesResult, type JobPage, type JobPay, type JobResult, type JobStatus, type Location, type LogoResult, type MapOptions, type MapResult, type OpenJob, type PageImage, type PageMetadata, type RateResultInput, type RateResultResponse, type ResultFeedbackReason, type ResultRating, type ScrapeBase, type ScrapeContent, type ScrapeOptions, type ScrapeResult, type ScreenshotOptions, type ScreenshotResult, type SearchJobsOptions, type SearchOptions, type SearchResult, type SearchResultItem, type StyleguideOptions, type StyleguideResult, type Usage, type WaitOptions, type ZodLike };
431
+ export { type BatchOptions, type BrandOptions, type BrandResult, type CompanyHiringChanges, type CrawlOptions, type ExtractItem, type ExtractOptions, type ExtractResult, type ExtractSchema, type Format, type HiringChangePosting, type HiringChangesOptions, type HiringCounts, Hydrafetch, HydrafetchError, type HydrafetchOptions, HydrafetchTimeoutError, type ImagesResult, type JobPage, type JobPay, type JobResult, type JobStatus, type Location, type LogoResult, type MapLink, type MapOptions, type MapResult, type NewsArticle, type NewsOptions, type NewsResult, type NewsTimeRange, type OpenJob, type PageImage, type PageMetadata, type RateResultInput, type RateResultResponse, type ResultFeedbackReason, type ResultRating, type ScrapeBase, type ScrapeContent, type ScrapeOptions, type ScrapeResult, type ScreenshotOptions, type ScreenshotResult, type SearchJobsOptions, type SearchOptions, type SearchResult, type SearchResultItem, type StyleguideOptions, type StyleguideResult, type Usage, type WaitOptions, type ZodLike };
package/dist/index.d.ts CHANGED
@@ -67,9 +67,14 @@ interface MapOptions {
67
67
  includeSubdomains?: boolean;
68
68
  ignoreQueryParameters?: boolean;
69
69
  }
70
+ interface MapLink {
71
+ url: string;
72
+ /** When the site's sitemap says the page last changed, or null when it does not say. */
73
+ lastmod: string | null;
74
+ }
70
75
  interface MapResult {
71
76
  url: string;
72
- links: string[];
77
+ links: MapLink[];
73
78
  count: number;
74
79
  total?: number;
75
80
  truncated?: boolean;
@@ -323,6 +328,41 @@ interface CompanyHiringChanges {
323
328
  closed: HiringChangePosting[];
324
329
  truncated: boolean;
325
330
  }
331
+ type NewsTimeRange = 'hour' | 'day' | 'week' | 'month';
332
+ interface NewsOptions {
333
+ /** Max articles to return, 1 to 50 (default 10). */
334
+ limit?: number;
335
+ /** Only articles published within this window before now (default "week"). */
336
+ timeRange?: NewsTimeRange;
337
+ /** ISO 3166 alpha-2 country code to lean results toward, like "us". */
338
+ country?: string;
339
+ /** Only articles from these sites, up to 15. */
340
+ includeDomains?: string[];
341
+ /** Drop articles from these sites, up to 15. */
342
+ excludeDomains?: string[];
343
+ /** Also read each article as clean data, 1 extra credit per article read. */
344
+ scrapeResults?: boolean;
345
+ scrapeOptions?: ScrapeOptions;
346
+ }
347
+ interface NewsArticle {
348
+ title: string;
349
+ /** The article's address on the publisher's own site. */
350
+ url: string;
351
+ /** The outlet that published it. */
352
+ source: string | null;
353
+ /** When it was published, ISO 8601. */
354
+ publishedAt: string;
355
+ snippet: string | null;
356
+ imageUrl: string | null;
357
+ /** The article read as clean data when scrapeResults is on, otherwise null. */
358
+ data: ScrapeResult | null;
359
+ }
360
+ interface NewsResult {
361
+ query: string;
362
+ status: 'ok' | 'no_results';
363
+ /** Newest first. */
364
+ results: NewsArticle[];
365
+ }
326
366
 
327
367
  interface HydrafetchOptions {
328
368
  apiKey?: string;
@@ -346,6 +386,7 @@ declare class Hydrafetch {
346
386
  rateResult(input: RateResultInput): Promise<RateResultResponse>;
347
387
  map(url: string, options?: MapOptions): Promise<MapResult>;
348
388
  search(query: string, options?: SearchOptions): Promise<SearchResult>;
389
+ news(query: string, options?: NewsOptions): Promise<NewsResult>;
349
390
  searchJobs(query: string, options?: SearchJobsOptions): Promise<OpenJob[]>;
350
391
  hiringChanges(domains: string | string[], since: string | Date, options?: HiringChangesOptions): Promise<CompanyHiringChanges[]>;
351
392
  extract<T = unknown>(urls: string | string[], options?: ExtractOptions): Promise<ExtractResult<T>>;
@@ -387,4 +428,4 @@ declare class HydrafetchTimeoutError extends HydrafetchError {
387
428
  constructor(message: string);
388
429
  }
389
430
 
390
- export { type BatchOptions, type BrandOptions, type BrandResult, type CompanyHiringChanges, type CrawlOptions, type ExtractItem, type ExtractOptions, type ExtractResult, type ExtractSchema, type Format, type HiringChangePosting, type HiringChangesOptions, type HiringCounts, Hydrafetch, HydrafetchError, type HydrafetchOptions, HydrafetchTimeoutError, type ImagesResult, type JobPage, type JobPay, type JobResult, type JobStatus, type Location, type LogoResult, type MapOptions, type MapResult, type OpenJob, type PageImage, type PageMetadata, type RateResultInput, type RateResultResponse, type ResultFeedbackReason, type ResultRating, type ScrapeBase, type ScrapeContent, type ScrapeOptions, type ScrapeResult, type ScreenshotOptions, type ScreenshotResult, type SearchJobsOptions, type SearchOptions, type SearchResult, type SearchResultItem, type StyleguideOptions, type StyleguideResult, type Usage, type WaitOptions, type ZodLike };
431
+ export { type BatchOptions, type BrandOptions, type BrandResult, type CompanyHiringChanges, type CrawlOptions, type ExtractItem, type ExtractOptions, type ExtractResult, type ExtractSchema, type Format, type HiringChangePosting, type HiringChangesOptions, type HiringCounts, Hydrafetch, HydrafetchError, type HydrafetchOptions, HydrafetchTimeoutError, type ImagesResult, type JobPage, type JobPay, type JobResult, type JobStatus, type Location, type LogoResult, type MapLink, type MapOptions, type MapResult, type NewsArticle, type NewsOptions, type NewsResult, type NewsTimeRange, type OpenJob, type PageImage, type PageMetadata, type RateResultInput, type RateResultResponse, type ResultFeedbackReason, type ResultRating, type ScrapeBase, type ScrapeContent, type ScrapeOptions, type ScrapeResult, type ScreenshotOptions, type ScreenshotResult, type SearchJobsOptions, type SearchOptions, type SearchResult, type SearchResultItem, type StyleguideOptions, type StyleguideResult, type Usage, type WaitOptions, type ZodLike };
package/dist/index.js CHANGED
@@ -207,6 +207,9 @@ var Hydrafetch = class {
207
207
  search(query, options = {}) {
208
208
  return this.request("POST", "/v1/web/search", { query, ...options });
209
209
  }
210
+ news(query, options = {}) {
211
+ return this.request("POST", "/v1/web/news", { query, ...options });
212
+ }
210
213
  searchJobs(query, options = {}) {
211
214
  return this.request("POST", "/v1/web/index/jobs/search", { query, ...options });
212
215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydrafetch/node-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Official Node/TypeScript client for the Hydrafetch web data API. Turn any URL into clean Markdown and structured data.",
5
5
  "keywords": [
6
6
  "hydrafetch",