@microsoft/webiq 0.1.6 → 0.1.8
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 +1 -35
- package/dist/index.d.mts +209 -2964
- package/dist/index.d.ts +209 -2964
- package/dist/index.js +8 -169
- package/dist/index.mjs +8 -161
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -47,16 +47,6 @@ const page = await client.browse.fetch('https://www.microsoft.com', {
|
|
|
47
47
|
});
|
|
48
48
|
console.log(page.content);
|
|
49
49
|
|
|
50
|
-
// Classic search with multiple answer types
|
|
51
|
-
const classic = await client.classic.search('Artificial intelligence trends', {
|
|
52
|
-
responseFilter: ['webResults'],
|
|
53
|
-
});
|
|
54
|
-
// responseFilter selects which answer types come back; the matching
|
|
55
|
-
// fields (e.g. classic.webResults) are populated dynamically and typed as `any`.
|
|
56
|
-
for (const r of classic.webResults ?? []) {
|
|
57
|
-
console.log(` - ${r.title}: ${r.url}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
50
|
await client.close();
|
|
61
51
|
```
|
|
62
52
|
|
|
@@ -170,30 +160,6 @@ const results = await client.images.search(query, {
|
|
|
170
160
|
// results.imageResults → [{title, url, hostPageUrl, caption, width, height, thumbnailUrl, ...}]
|
|
171
161
|
```
|
|
172
162
|
|
|
173
|
-
### Classic Search
|
|
174
|
-
|
|
175
|
-
Given a query, classic search will search and retrieve content from webpages, images, videos, news, weather, sports, etc.
|
|
176
|
-
|
|
177
|
-
```typescript
|
|
178
|
-
import { ContentFormat, SafeSearch } from '@microsoft/webiq';
|
|
179
|
-
|
|
180
|
-
const response = await client.classic.search(query, {
|
|
181
|
-
maxAnswerTypes: 6, // 1-6, default 6
|
|
182
|
-
language: 'en', // ISO 639-1/2 or BCP 47
|
|
183
|
-
region: 'US', // Country/region code
|
|
184
|
-
location: 'lat:40.7;long:-74.0', // Optional
|
|
185
|
-
maxResultsWeb: 10, // 1-50, default 10
|
|
186
|
-
maxLength: 10000, // 1-500000
|
|
187
|
-
contentFormat: ContentFormat.HTML,
|
|
188
|
-
freshness: 'month', // day, week, month, year, or date range
|
|
189
|
-
responseFilter: ['webResults', 'newsResults'], // Answer types to include
|
|
190
|
-
safeSearch: SafeSearch.STRICT, // OFF, STRICT
|
|
191
|
-
});
|
|
192
|
-
// response.querySignals → {originalQuery, normalizedQuery, isDefensive, isAdult, isNav, isFresh}
|
|
193
|
-
// response.traceId → string
|
|
194
|
-
// Additional dynamic fields for different answer types
|
|
195
|
-
```
|
|
196
|
-
|
|
197
163
|
### Enum Types
|
|
198
164
|
|
|
199
165
|
Some parameters require enum values instead of plain strings. Import them from `@microsoft/webiq`:
|
|
@@ -201,7 +167,7 @@ Some parameters require enum values instead of plain strings. Import them from `
|
|
|
201
167
|
```typescript
|
|
202
168
|
import { BrowseContentFormat, ContentFormat } from '@microsoft/webiq';
|
|
203
169
|
|
|
204
|
-
// ContentFormat: format of returned content for web
|
|
170
|
+
// ContentFormat: format of returned content for web and news search
|
|
205
171
|
ContentFormat.PASSAGE; // Selected passages only (plain text)
|
|
206
172
|
ContentFormat.TEXT; // Full page text (plain text)
|
|
207
173
|
ContentFormat.HTML; // HTML format (default for web search)
|