@hydrafetch/node-sdk 0.3.0 → 0.4.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
@@ -82,6 +82,16 @@ out.results.forEach((item) => console.log(item.url, item.data?.name));
82
82
 
83
83
  Pass `prompt` instead of, or alongside, `schema` to describe the fields in plain language.
84
84
 
85
+ Sites that price or stock by delivery area serve a different page for each area. Pass `location` to fetch as if from a country and language, and `headers` to send the cookie that picks the store or area, the same options `scrape` takes.
86
+
87
+ ```ts
88
+ const out = await hf.extract(['https://shop.example/search?q=ghee'], {
89
+ prompt: 'every product with its size and price',
90
+ location: { country: 'in' },
91
+ headers: { Cookie: 'store_id=42' },
92
+ });
93
+ ```
94
+
85
95
  ### Zod schemas
86
96
 
87
97
  If you already use Zod, pass the schema directly. Zod stays optional and is imported only when you
package/dist/index.d.cts CHANGED
@@ -34,6 +34,10 @@ interface ScrapeBase {
34
34
  type ScrapeResult<F extends Format = 'markdown'> = ScrapeBase & {
35
35
  [K in F]: ScrapeContent[K];
36
36
  } & Partial<Omit<ScrapeContent, F>>;
37
+ interface Location {
38
+ country?: string;
39
+ languages?: string[];
40
+ }
37
41
  interface ScrapeOptions<F extends readonly Format[] = readonly Format[]> {
38
42
  formats?: F;
39
43
  maxAge?: number;
@@ -48,6 +52,7 @@ interface ScrapeOptions<F extends readonly Format[] = readonly Format[]> {
48
52
  includeLinks?: boolean;
49
53
  waitFor?: number;
50
54
  timeout?: number;
55
+ location?: Location;
51
56
  headers?: Record<string, string>;
52
57
  jsonOptions?: Record<string, unknown>;
53
58
  }
@@ -114,6 +119,8 @@ interface ExtractOptions {
114
119
  showConfidence?: boolean;
115
120
  mergeEntities?: boolean;
116
121
  maxAge?: number;
122
+ location?: Location;
123
+ headers?: Record<string, string>;
117
124
  }
118
125
  interface ExtractItem<T = unknown> {
119
126
  url: string;
@@ -290,4 +297,4 @@ declare class HydrafetchTimeoutError extends HydrafetchError {
290
297
  constructor(message: string);
291
298
  }
292
299
 
293
- export { type BatchOptions, type BrandOptions, type BrandResult, type CrawlOptions, type ExtractItem, type ExtractOptions, type ExtractResult, type ExtractSchema, type Format, Hydrafetch, HydrafetchError, type HydrafetchOptions, HydrafetchTimeoutError, type ImagesResult, type JobPage, type JobResult, type JobStatus, type LogoResult, type MapOptions, type MapResult, type PageImage, type PageMetadata, type ScrapeBase, type ScrapeContent, type ScrapeOptions, type ScrapeResult, type ScreenshotOptions, type ScreenshotResult, type SearchOptions, type SearchResult, type SearchResultItem, type StyleguideOptions, type StyleguideResult, type Usage, type WaitOptions, type ZodLike };
300
+ export { type BatchOptions, type BrandOptions, type BrandResult, type CrawlOptions, type ExtractItem, type ExtractOptions, type ExtractResult, type ExtractSchema, type Format, Hydrafetch, HydrafetchError, type HydrafetchOptions, HydrafetchTimeoutError, type ImagesResult, type JobPage, type JobResult, type JobStatus, type Location, type LogoResult, type MapOptions, type MapResult, type PageImage, type PageMetadata, type ScrapeBase, type ScrapeContent, type ScrapeOptions, type ScrapeResult, type ScreenshotOptions, type ScreenshotResult, type SearchOptions, type SearchResult, type SearchResultItem, type StyleguideOptions, type StyleguideResult, type Usage, type WaitOptions, type ZodLike };
package/dist/index.d.ts CHANGED
@@ -34,6 +34,10 @@ interface ScrapeBase {
34
34
  type ScrapeResult<F extends Format = 'markdown'> = ScrapeBase & {
35
35
  [K in F]: ScrapeContent[K];
36
36
  } & Partial<Omit<ScrapeContent, F>>;
37
+ interface Location {
38
+ country?: string;
39
+ languages?: string[];
40
+ }
37
41
  interface ScrapeOptions<F extends readonly Format[] = readonly Format[]> {
38
42
  formats?: F;
39
43
  maxAge?: number;
@@ -48,6 +52,7 @@ interface ScrapeOptions<F extends readonly Format[] = readonly Format[]> {
48
52
  includeLinks?: boolean;
49
53
  waitFor?: number;
50
54
  timeout?: number;
55
+ location?: Location;
51
56
  headers?: Record<string, string>;
52
57
  jsonOptions?: Record<string, unknown>;
53
58
  }
@@ -114,6 +119,8 @@ interface ExtractOptions {
114
119
  showConfidence?: boolean;
115
120
  mergeEntities?: boolean;
116
121
  maxAge?: number;
122
+ location?: Location;
123
+ headers?: Record<string, string>;
117
124
  }
118
125
  interface ExtractItem<T = unknown> {
119
126
  url: string;
@@ -290,4 +297,4 @@ declare class HydrafetchTimeoutError extends HydrafetchError {
290
297
  constructor(message: string);
291
298
  }
292
299
 
293
- export { type BatchOptions, type BrandOptions, type BrandResult, type CrawlOptions, type ExtractItem, type ExtractOptions, type ExtractResult, type ExtractSchema, type Format, Hydrafetch, HydrafetchError, type HydrafetchOptions, HydrafetchTimeoutError, type ImagesResult, type JobPage, type JobResult, type JobStatus, type LogoResult, type MapOptions, type MapResult, type PageImage, type PageMetadata, type ScrapeBase, type ScrapeContent, type ScrapeOptions, type ScrapeResult, type ScreenshotOptions, type ScreenshotResult, type SearchOptions, type SearchResult, type SearchResultItem, type StyleguideOptions, type StyleguideResult, type Usage, type WaitOptions, type ZodLike };
300
+ export { type BatchOptions, type BrandOptions, type BrandResult, type CrawlOptions, type ExtractItem, type ExtractOptions, type ExtractResult, type ExtractSchema, type Format, Hydrafetch, HydrafetchError, type HydrafetchOptions, HydrafetchTimeoutError, type ImagesResult, type JobPage, type JobResult, type JobStatus, type Location, type LogoResult, type MapOptions, type MapResult, type PageImage, type PageMetadata, type ScrapeBase, type ScrapeContent, type ScrapeOptions, type ScrapeResult, type ScreenshotOptions, type ScreenshotResult, type SearchOptions, type SearchResult, type SearchResultItem, type StyleguideOptions, type StyleguideResult, type Usage, type WaitOptions, type ZodLike };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydrafetch/node-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.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",