@hydrafetch/node-sdk 0.6.0 → 0.7.0

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
@@ -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
@@ -323,6 +323,41 @@ interface CompanyHiringChanges {
323
323
  closed: HiringChangePosting[];
324
324
  truncated: boolean;
325
325
  }
326
+ type NewsTimeRange = 'hour' | 'day' | 'week' | 'month';
327
+ interface NewsOptions {
328
+ /** Max articles to return, 1 to 50 (default 10). */
329
+ limit?: number;
330
+ /** Only articles published within this window before now (default "week"). */
331
+ timeRange?: NewsTimeRange;
332
+ /** ISO 3166 alpha-2 country code to lean results toward, like "us". */
333
+ country?: string;
334
+ /** Only articles from these sites, up to 15. */
335
+ includeDomains?: string[];
336
+ /** Drop articles from these sites, up to 15. */
337
+ excludeDomains?: string[];
338
+ /** Also read each article as clean data, 1 extra credit per article read. */
339
+ scrapeResults?: boolean;
340
+ scrapeOptions?: ScrapeOptions;
341
+ }
342
+ interface NewsArticle {
343
+ title: string;
344
+ /** The article's address on the publisher's own site. */
345
+ url: string;
346
+ /** The outlet that published it. */
347
+ source: string | null;
348
+ /** When it was published, ISO 8601. */
349
+ publishedAt: string;
350
+ snippet: string | null;
351
+ imageUrl: string | null;
352
+ /** The article read as clean data when scrapeResults is on, otherwise null. */
353
+ data: ScrapeResult | null;
354
+ }
355
+ interface NewsResult {
356
+ query: string;
357
+ status: 'ok' | 'no_results';
358
+ /** Newest first. */
359
+ results: NewsArticle[];
360
+ }
326
361
 
327
362
  interface HydrafetchOptions {
328
363
  apiKey?: string;
@@ -346,6 +381,7 @@ declare class Hydrafetch {
346
381
  rateResult(input: RateResultInput): Promise<RateResultResponse>;
347
382
  map(url: string, options?: MapOptions): Promise<MapResult>;
348
383
  search(query: string, options?: SearchOptions): Promise<SearchResult>;
384
+ news(query: string, options?: NewsOptions): Promise<NewsResult>;
349
385
  searchJobs(query: string, options?: SearchJobsOptions): Promise<OpenJob[]>;
350
386
  hiringChanges(domains: string | string[], since: string | Date, options?: HiringChangesOptions): Promise<CompanyHiringChanges[]>;
351
387
  extract<T = unknown>(urls: string | string[], options?: ExtractOptions): Promise<ExtractResult<T>>;
@@ -387,4 +423,4 @@ declare class HydrafetchTimeoutError extends HydrafetchError {
387
423
  constructor(message: string);
388
424
  }
389
425
 
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 };
426
+ 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 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
@@ -323,6 +323,41 @@ interface CompanyHiringChanges {
323
323
  closed: HiringChangePosting[];
324
324
  truncated: boolean;
325
325
  }
326
+ type NewsTimeRange = 'hour' | 'day' | 'week' | 'month';
327
+ interface NewsOptions {
328
+ /** Max articles to return, 1 to 50 (default 10). */
329
+ limit?: number;
330
+ /** Only articles published within this window before now (default "week"). */
331
+ timeRange?: NewsTimeRange;
332
+ /** ISO 3166 alpha-2 country code to lean results toward, like "us". */
333
+ country?: string;
334
+ /** Only articles from these sites, up to 15. */
335
+ includeDomains?: string[];
336
+ /** Drop articles from these sites, up to 15. */
337
+ excludeDomains?: string[];
338
+ /** Also read each article as clean data, 1 extra credit per article read. */
339
+ scrapeResults?: boolean;
340
+ scrapeOptions?: ScrapeOptions;
341
+ }
342
+ interface NewsArticle {
343
+ title: string;
344
+ /** The article's address on the publisher's own site. */
345
+ url: string;
346
+ /** The outlet that published it. */
347
+ source: string | null;
348
+ /** When it was published, ISO 8601. */
349
+ publishedAt: string;
350
+ snippet: string | null;
351
+ imageUrl: string | null;
352
+ /** The article read as clean data when scrapeResults is on, otherwise null. */
353
+ data: ScrapeResult | null;
354
+ }
355
+ interface NewsResult {
356
+ query: string;
357
+ status: 'ok' | 'no_results';
358
+ /** Newest first. */
359
+ results: NewsArticle[];
360
+ }
326
361
 
327
362
  interface HydrafetchOptions {
328
363
  apiKey?: string;
@@ -346,6 +381,7 @@ declare class Hydrafetch {
346
381
  rateResult(input: RateResultInput): Promise<RateResultResponse>;
347
382
  map(url: string, options?: MapOptions): Promise<MapResult>;
348
383
  search(query: string, options?: SearchOptions): Promise<SearchResult>;
384
+ news(query: string, options?: NewsOptions): Promise<NewsResult>;
349
385
  searchJobs(query: string, options?: SearchJobsOptions): Promise<OpenJob[]>;
350
386
  hiringChanges(domains: string | string[], since: string | Date, options?: HiringChangesOptions): Promise<CompanyHiringChanges[]>;
351
387
  extract<T = unknown>(urls: string | string[], options?: ExtractOptions): Promise<ExtractResult<T>>;
@@ -387,4 +423,4 @@ declare class HydrafetchTimeoutError extends HydrafetchError {
387
423
  constructor(message: string);
388
424
  }
389
425
 
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 };
426
+ 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 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.0",
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",