@builtwith/sdk 1.1.0 → 1.3.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.
Files changed (3) hide show
  1. package/README.md +25 -0
  2. package/package.json +1 -1
  3. package/src/index.js +36 -2
package/README.md CHANGED
@@ -59,6 +59,10 @@ if (result.ok) {
59
59
  | `trust({ lookup })` | Root domain | Trust scoring |
60
60
  | `financial({ lookup })` | Root domain | Financial data |
61
61
  | `social({ lookup })` | Root domain | Social profile related domains |
62
+ | `vector_search({ query, limit? })` | Search query | Semantic technology/category search |
63
+ | `payment_discovery()` | — | Agent Payment API: credit balance |
64
+ | `payment_configuration()` | — | Agent Payment API: spending limits |
65
+ | `payment_purchase({ credits })` | Integer ≥ 2000 | Agent Payment API: purchase credits |
62
66
 
63
67
  ### Response Format
64
68
 
@@ -124,6 +128,10 @@ All methods accept a `CancellationToken` as an optional last parameter.
124
128
  | `trust(lookup)` | `string` | Trust scoring |
125
129
  | `financial(lookup)` | `string` | Financial data |
126
130
  | `social(lookup)` | `string` | Social profile related domains |
131
+ | `vector_search(query, limit?)` | `string`, `int?` | Semantic technology/category search |
132
+ | `payment_discovery()` | — | Agent Payment API: credit balance |
133
+ | `payment_configuration()` | — | Agent Payment API: spending limits |
134
+ | `payment_purchase(credits)` | `int` ≥ 2000 | Agent Payment API: purchase credits |
127
135
 
128
136
  ### Response Format
129
137
 
@@ -146,6 +154,23 @@ BUILTWITH_API_KEY=your-key dotnet run
146
154
 
147
155
  ---
148
156
 
157
+ ## Agent Payment API
158
+
159
+ The payment methods let AI agents check credit balances, view spending configuration, and purchase credits. They route through the standard MCP endpoint using your existing API key. Configure billing at [payments.builtwith.com/agent-payment-api-config](https://payments.builtwith.com/agent-payment-api-config).
160
+
161
+ ```js
162
+ // Node.js
163
+ const result = await client.payment_discovery();
164
+ // result.data => { credits_total, credits_used, credits_available }
165
+ ```
166
+
167
+ ```csharp
168
+ // C#
169
+ var result = await client.payment_discovery();
170
+ ```
171
+
172
+ ---
173
+
149
174
  ## Prompt Helpers
150
175
 
151
176
  Both SDKs include prompt helper methods for use with AI agents:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builtwith/sdk",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "BuiltWith AI-first SDK for Node.js",
5
5
  "main": "src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const https = require('https');
4
+ const http = require('http');
4
5
  const { URL } = require('url');
5
6
 
6
7
  // ── Constants ──────────────────────────────────────────────────────────────────
@@ -100,10 +101,11 @@ function _parse_sse_body(raw_body) {
100
101
  function _http_post(url_str, body, headers, timeout_ms) {
101
102
  return new Promise((resolve, reject) => {
102
103
  const parsed = new URL(url_str);
104
+ const transport = parsed.protocol === 'http:' ? http : https;
103
105
  const payload = JSON.stringify(body);
104
106
  const opts = {
105
107
  hostname: parsed.hostname,
106
- port: parsed.port || 443,
108
+ port: parsed.port || (parsed.protocol === 'http:' ? 80 : 443),
107
109
  path: parsed.pathname + parsed.search,
108
110
  method: 'POST',
109
111
  headers: {
@@ -115,7 +117,7 @@ function _http_post(url_str, body, headers, timeout_ms) {
115
117
  timeout: timeout_ms,
116
118
  };
117
119
 
118
- const req = https.request(opts, (res) => {
120
+ const req = transport.request(opts, (res) => {
119
121
  const chunks = [];
120
122
  res.on('data', chunk => chunks.push(chunk));
121
123
  res.on('end', () => {
@@ -328,6 +330,38 @@ class BuiltWithClient {
328
330
  return this._request('vector-search', { query, ...(limit != null ? { limit } : {}) });
329
331
  }
330
332
 
333
+ async keyword_search(params) {
334
+ const { keyword, limit, offset } = params || {};
335
+ _validate_string('keyword', keyword);
336
+ return this._request('keyword-search-api', {
337
+ keyword,
338
+ ...(limit != null ? { limit } : {}),
339
+ ...(offset != null ? { offset } : {}),
340
+ });
341
+ }
342
+
343
+ async payment_discovery() {
344
+ return this._request('payment-balance', {});
345
+ }
346
+
347
+ async payment_configuration() {
348
+ return this._request('payment-config', {});
349
+ }
350
+
351
+ async payment_purchase(params) {
352
+ const { credits } = params || {};
353
+ if (credits === undefined || credits === null) {
354
+ throw new BuiltWithError('VALIDATION_ERROR', 'credits is required.', 0, null, 'Provide a credits value (minimum 2000).');
355
+ }
356
+ if (typeof credits !== 'number' || !Number.isInteger(credits)) {
357
+ throw new BuiltWithError('VALIDATION_ERROR', 'credits must be an integer.', 0, null, 'Provide a whole number of credits.');
358
+ }
359
+ if (credits < 2000) {
360
+ throw new BuiltWithError('VALIDATION_ERROR', 'credits must be at least 2000.', 0, null, 'Minimum purchase is 2000 credits.');
361
+ }
362
+ return this._request('payment-purchase', { credits });
363
+ }
364
+
331
365
  // ── Prompt helpers ─────────────────────────────────────────────────────────
332
366
 
333
367
  prompt_analyze_tech_stack(params) {