@knowledgesdk/node 0.1.0 → 0.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.
- package/README.md +19 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ import { KnowledgeSDK } from '@knowledgesdk/node';
|
|
|
20
20
|
const client = new KnowledgeSDK('sk_ks_your_api_key');
|
|
21
21
|
|
|
22
22
|
// Run the full extraction pipeline on a website
|
|
23
|
-
const result = await client.extract.run('https://
|
|
23
|
+
const result = await client.extract.run('https://stripe.com');
|
|
24
24
|
console.log(result.business.businessName);
|
|
25
25
|
console.log(result.knowledgeItems);
|
|
26
26
|
```
|
|
@@ -58,12 +58,12 @@ Run the full pipeline against a URL: scrape, classify, and return structured kno
|
|
|
58
58
|
#### Synchronous
|
|
59
59
|
|
|
60
60
|
```typescript
|
|
61
|
-
const result = await client.extract.run('https://
|
|
61
|
+
const result = await client.extract.run('https://stripe.com', {
|
|
62
62
|
maxPages: 20,
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
console.log(result.business.businessName); // "
|
|
66
|
-
console.log(result.business.industrySector); // "
|
|
65
|
+
console.log(result.business.businessName); // "Stripe"
|
|
66
|
+
console.log(result.business.industrySector); // "Fintech"
|
|
67
67
|
console.log(result.business.confidenceScore); // 0.92
|
|
68
68
|
console.log(result.pagesScraped); // 18
|
|
69
69
|
console.log(result.sitemapUrls); // 54
|
|
@@ -108,7 +108,7 @@ result.knowledgeItems.forEach((item) => {
|
|
|
108
108
|
For long-running extractions, use `runAsync` to get a job ID and poll for the result:
|
|
109
109
|
|
|
110
110
|
```typescript
|
|
111
|
-
const { jobId, status } = await client.extract.runAsync('https://
|
|
111
|
+
const { jobId, status } = await client.extract.runAsync('https://stripe.com', {
|
|
112
112
|
maxPages: 50,
|
|
113
113
|
callbackUrl: 'https://your-server.com/webhooks/knowledgesdk',
|
|
114
114
|
});
|
|
@@ -132,9 +132,9 @@ if (job.status === 'completed') {
|
|
|
132
132
|
Scrape a single page and receive its content as Markdown along with metadata.
|
|
133
133
|
|
|
134
134
|
```typescript
|
|
135
|
-
const page = await client.scrape.run('https://
|
|
135
|
+
const page = await client.scrape.run('https://stripe.com/pricing');
|
|
136
136
|
|
|
137
|
-
console.log(page.title); // "Pricing —
|
|
137
|
+
console.log(page.title); // "Pricing & Fees — Stripe"
|
|
138
138
|
console.log(page.description); // "Simple, transparent pricing..."
|
|
139
139
|
console.log(page.markdown); // Full page content in Markdown
|
|
140
140
|
console.log(page.links); // Array of hrefs found on the page
|
|
@@ -159,15 +159,15 @@ console.log(page.links); // Array of hrefs found on the page
|
|
|
159
159
|
Classify a business by analyzing its website. Returns a structured profile without scraping the full site.
|
|
160
160
|
|
|
161
161
|
```typescript
|
|
162
|
-
const classification = await client.classify.run('https://
|
|
162
|
+
const classification = await client.classify.run('https://stripe.com');
|
|
163
163
|
|
|
164
|
-
console.log(classification.businessName); // "
|
|
164
|
+
console.log(classification.businessName); // "Stripe"
|
|
165
165
|
console.log(classification.businessType); // "B2B Software"
|
|
166
|
-
console.log(classification.industrySector); // "
|
|
167
|
-
console.log(classification.targetAudience); // "
|
|
168
|
-
console.log(classification.valueProposition); // "
|
|
169
|
-
console.log(classification.painPoints); // ["
|
|
170
|
-
console.log(classification.uniqueSellingPoints); // ["
|
|
166
|
+
console.log(classification.industrySector); // "Payments & Financial Infrastructure"
|
|
167
|
+
console.log(classification.targetAudience); // "Developers and businesses of all sizes"
|
|
168
|
+
console.log(classification.valueProposition); // "Financial infrastructure for the internet"
|
|
169
|
+
console.log(classification.painPoints); // ["Complex payment integrations", "Global compliance"]
|
|
170
|
+
console.log(classification.uniqueSellingPoints); // ["Developer-first APIs", "Global payments"]
|
|
171
171
|
console.log(classification.confidenceScore); // 0.89
|
|
172
172
|
```
|
|
173
173
|
|
|
@@ -178,7 +178,7 @@ console.log(classification.confidenceScore); // 0.89
|
|
|
178
178
|
Capture a full-page screenshot of any URL. Returns a base64-encoded PNG.
|
|
179
179
|
|
|
180
180
|
```typescript
|
|
181
|
-
const { url, screenshot } = await client.screenshot.run('https://
|
|
181
|
+
const { url, screenshot } = await client.screenshot.run('https://stripe.com');
|
|
182
182
|
|
|
183
183
|
// Write to disk
|
|
184
184
|
import { writeFileSync } from 'fs';
|
|
@@ -196,7 +196,7 @@ const dataUrl = `data:image/png;base64,${screenshot}`;
|
|
|
196
196
|
Discover all publicly accessible URLs for a website via its sitemap or by crawling.
|
|
197
197
|
|
|
198
198
|
```typescript
|
|
199
|
-
const { url, urls, count } = await client.sitemap.run('https://
|
|
199
|
+
const { url, urls, count } = await client.sitemap.run('https://stripe.com');
|
|
200
200
|
|
|
201
201
|
console.log(`Found ${count} URLs`);
|
|
202
202
|
urls.forEach((u) => console.log(u));
|
|
@@ -350,7 +350,7 @@ import {
|
|
|
350
350
|
const client = new KnowledgeSDK('sk_ks_your_api_key');
|
|
351
351
|
|
|
352
352
|
try {
|
|
353
|
-
const result = await client.extract.run('https://
|
|
353
|
+
const result = await client.extract.run('https://stripe.com');
|
|
354
354
|
} catch (err) {
|
|
355
355
|
if (err instanceof AuthenticationError) {
|
|
356
356
|
console.error('Invalid API key:', err.message);
|
|
@@ -401,7 +401,7 @@ const client = new KnowledgeSDK('sk_ks_your_api_key');
|
|
|
401
401
|
client.setDebugMode(true);
|
|
402
402
|
|
|
403
403
|
// All requests and responses will now be printed to the console
|
|
404
|
-
const result = await client.scrape.run('https://
|
|
404
|
+
const result = await client.scrape.run('https://stripe.com');
|
|
405
405
|
```
|
|
406
406
|
|
|
407
407
|
---
|
|
@@ -457,7 +457,7 @@ async function extractWebsite(url: string): Promise<ExtractResult> {
|
|
|
457
457
|
return job.result as ExtractResult;
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
const result = await extractWebsite('https://
|
|
460
|
+
const result = await extractWebsite('https://shopify.com');
|
|
461
461
|
console.log(`Extracted ${result.knowledgeItems.length} knowledge items`);
|
|
462
462
|
```
|
|
463
463
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knowledgesdk/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "KnowledgeSDK Node.js SDK - Official Node.js client for the KnowledgeSDK API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"homepage": "https://knowledgesdk.com",
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
62
|
-
"url": "https://github.com/
|
|
62
|
+
"url": "https://github.com/KnowledgeSDK/knowledgesdk-node"
|
|
63
63
|
},
|
|
64
64
|
"bugs": {
|
|
65
65
|
"url": "https://github.com/knowledgesdk/knowledgesdk-node/issues"
|