apinow-sdk 0.17.0 → 0.18.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/dist/cli.js CHANGED
@@ -194,6 +194,92 @@ program
194
194
  process.exit(1);
195
195
  }
196
196
  });
197
+ // ─── endpoint-create ───
198
+ program
199
+ .command('endpoint-create')
200
+ .description('Create an endpoint (raw CRUD)')
201
+ .requiredOption('--namespace <ns>', 'Namespace')
202
+ .requiredOption('--name <name>', 'Endpoint name')
203
+ .requiredOption('--url <url>', 'Upstream URL')
204
+ .requiredOption('--description <desc>', 'Description')
205
+ .option('--method <method>', 'HTTP method', 'POST')
206
+ .option('--price <usdc>', 'USDC price per call', '0.01')
207
+ .option('-k, --key <privateKey>', 'Wallet private key')
208
+ .action(async (opts) => {
209
+ try {
210
+ const { address } = getWallet(opts);
211
+ const body = {
212
+ namespace: opts.namespace,
213
+ endpointName: opts.name,
214
+ url: opts.url,
215
+ description: opts.description,
216
+ httpMethod: opts.method.toUpperCase(),
217
+ paymentOptions: [{ usdAmount: opts.price, amount: opts.price }],
218
+ };
219
+ const data = await fetchJson(`${API_BASE}/api/endpoints`, {
220
+ method: 'POST',
221
+ headers: walletHeaders(address),
222
+ body: JSON.stringify(body),
223
+ });
224
+ console.log(JSON.stringify(data, null, 2));
225
+ }
226
+ catch (err) {
227
+ console.error(`Error: ${err.message}`);
228
+ process.exit(1);
229
+ }
230
+ });
231
+ // ─── endpoint-update ───
232
+ program
233
+ .command('endpoint-update <id>')
234
+ .description('Update an endpoint by ID')
235
+ .option('--description <desc>', 'New description')
236
+ .option('--url <url>', 'New URL')
237
+ .option('--price <usdc>', 'New USDC price')
238
+ .option('--status <status>', 'New status')
239
+ .option('-k, --key <privateKey>', 'Wallet private key')
240
+ .action(async (id, opts) => {
241
+ try {
242
+ const { address } = getWallet(opts);
243
+ const body = {};
244
+ if (opts.description)
245
+ body.description = opts.description;
246
+ if (opts.url)
247
+ body.url = opts.url;
248
+ if (opts.status)
249
+ body.status = opts.status;
250
+ if (opts.price)
251
+ body.paymentOptions = [{ usdAmount: opts.price, amount: opts.price }];
252
+ const data = await fetchJson(`${API_BASE}/api/endpoints/${id}`, {
253
+ method: 'PUT',
254
+ headers: walletHeaders(address),
255
+ body: JSON.stringify(body),
256
+ });
257
+ console.log(JSON.stringify(data, null, 2));
258
+ }
259
+ catch (err) {
260
+ console.error(`Error: ${err.message}`);
261
+ process.exit(1);
262
+ }
263
+ });
264
+ // ─── endpoint-delete ───
265
+ program
266
+ .command('endpoint-delete <id>')
267
+ .description('Delete an endpoint by ID')
268
+ .option('-k, --key <privateKey>', 'Wallet private key')
269
+ .action(async (id, opts) => {
270
+ try {
271
+ const { address } = getWallet(opts);
272
+ const data = await fetchJson(`${API_BASE}/api/endpoints/${id}`, {
273
+ method: 'DELETE',
274
+ headers: walletHeaders(address),
275
+ });
276
+ console.log(JSON.stringify(data, null, 2));
277
+ }
278
+ catch (err) {
279
+ console.error(`Error: ${err.message}`);
280
+ process.exit(1);
281
+ }
282
+ });
197
283
  // ─── call ───
198
284
  program
199
285
  .command('call <endpoint>')
@@ -321,6 +407,90 @@ program
321
407
  process.exit(1);
322
408
  }
323
409
  });
410
+ // ─── workflow-create ───
411
+ program
412
+ .command('workflow-create')
413
+ .description('Create a workflow (raw CRUD)')
414
+ .requiredOption('--name <name>', 'Workflow name')
415
+ .option('--description <desc>', 'Description')
416
+ .option('--graph <json>', 'Graph JSON (nodes + outputNode)')
417
+ .option('--prompt <prompt>', 'AI prompt to generate workflow')
418
+ .option('--price <usdc>', 'Total price', '0.10')
419
+ .option('-k, --key <privateKey>', 'Wallet private key')
420
+ .action(async (opts) => {
421
+ try {
422
+ const { address } = getWallet(opts);
423
+ const body = { name: opts.name, totalPrice: opts.price };
424
+ if (opts.description)
425
+ body.description = opts.description;
426
+ if (opts.graph)
427
+ body.graph = JSON.parse(opts.graph);
428
+ if (opts.prompt)
429
+ body.prompt = opts.prompt;
430
+ const data = await fetchJson(`${API_BASE}/api/workflows`, {
431
+ method: 'POST',
432
+ headers: walletHeaders(address),
433
+ body: JSON.stringify(body),
434
+ });
435
+ console.log(JSON.stringify(data, null, 2));
436
+ }
437
+ catch (err) {
438
+ console.error(`Error: ${err.message}`);
439
+ process.exit(1);
440
+ }
441
+ });
442
+ // ─── workflow-update ───
443
+ program
444
+ .command('workflow-update <id>')
445
+ .description('Update a workflow by ID')
446
+ .option('--name <name>', 'New name')
447
+ .option('--description <desc>', 'New description')
448
+ .option('--status <status>', 'New status')
449
+ .option('--price <usdc>', 'New total price')
450
+ .option('-k, --key <privateKey>', 'Wallet private key')
451
+ .action(async (id, opts) => {
452
+ try {
453
+ const { address } = getWallet(opts);
454
+ const body = {};
455
+ if (opts.name)
456
+ body.name = opts.name;
457
+ if (opts.description)
458
+ body.description = opts.description;
459
+ if (opts.status)
460
+ body.status = opts.status;
461
+ if (opts.price)
462
+ body.totalPrice = opts.price;
463
+ const data = await fetchJson(`${API_BASE}/api/workflows/${id}`, {
464
+ method: 'PUT',
465
+ headers: walletHeaders(address),
466
+ body: JSON.stringify(body),
467
+ });
468
+ console.log(JSON.stringify(data, null, 2));
469
+ }
470
+ catch (err) {
471
+ console.error(`Error: ${err.message}`);
472
+ process.exit(1);
473
+ }
474
+ });
475
+ // ─── workflow-delete ───
476
+ program
477
+ .command('workflow-delete <id>')
478
+ .description('Delete a workflow by ID')
479
+ .option('-k, --key <privateKey>', 'Wallet private key')
480
+ .action(async (id, opts) => {
481
+ try {
482
+ const { address } = getWallet(opts);
483
+ const data = await fetchJson(`${API_BASE}/api/workflows/${id}`, {
484
+ method: 'DELETE',
485
+ headers: walletHeaders(address),
486
+ });
487
+ console.log(JSON.stringify(data, null, 2));
488
+ }
489
+ catch (err) {
490
+ console.error(`Error: ${err.message}`);
491
+ process.exit(1);
492
+ }
493
+ });
324
494
  // ─── factory-balance ───
325
495
  program
326
496
  .command('factory-balance')
package/dist/index.d.ts CHANGED
@@ -27,6 +27,34 @@ export declare function createClient(config: ApinowConfig): {
27
27
  * Get public endpoint info (free, no payment).
28
28
  */
29
29
  info(namespace: string, endpointName: string): Promise<any>;
30
+ createEndpoint(config: {
31
+ namespace: string;
32
+ endpointName: string;
33
+ url: string;
34
+ description: string;
35
+ httpMethod: "GET" | "POST";
36
+ paymentOptions: Array<{
37
+ amount?: string;
38
+ usdAmount?: string;
39
+ tokenAddress?: string;
40
+ tokenSymbol?: string;
41
+ }>;
42
+ chain?: string;
43
+ querySchema?: any;
44
+ responseSchema?: any;
45
+ exampleQuery?: any;
46
+ exampleOutput?: any;
47
+ docsUrl?: string;
48
+ }): Promise<any>;
49
+ getEndpoint(id: string): Promise<any>;
50
+ updateEndpoint(id: string, updates: Record<string, any>): Promise<any>;
51
+ deleteEndpoint(id: string): Promise<any>;
52
+ listEndpoints(opts?: {
53
+ limit?: number;
54
+ sortBy?: string;
55
+ namespace?: string;
56
+ search?: string;
57
+ }): Promise<any>;
30
58
  /**
31
59
  * List workflows. Optionally filter by creator or status.
32
60
  */
@@ -39,6 +67,30 @@ export declare function createClient(config: ApinowConfig): {
39
67
  * Get workflow details by ID.
40
68
  */
41
69
  getWorkflow(workflowId: string): Promise<any>;
70
+ createWorkflow(config: {
71
+ name?: string;
72
+ description?: string;
73
+ graph?: {
74
+ nodes: Array<{
75
+ id: string;
76
+ endpoint: string;
77
+ inputMapping: any;
78
+ dependsOn: string[];
79
+ }>;
80
+ outputNode: string;
81
+ outputMapping?: any;
82
+ };
83
+ prompt?: string;
84
+ totalPrice?: string;
85
+ splits?: Array<{
86
+ address: string;
87
+ basisPoints: number;
88
+ label?: string;
89
+ }>;
90
+ chain?: string;
91
+ }): Promise<any>;
92
+ updateWorkflow(workflowId: string, updates: Record<string, any>): Promise<any>;
93
+ deleteWorkflow(workflowId: string): Promise<any>;
42
94
  /**
43
95
  * Run a workflow. Handles x402 payment automatically.
44
96
  *
package/dist/index.js CHANGED
@@ -58,6 +58,63 @@ export function createClient(config) {
58
58
  throw new Error(`Failed to fetch info: ${res.status}`);
59
59
  return res.json();
60
60
  },
61
+ // ─── Endpoint CRUD ───
62
+ async createEndpoint(config) {
63
+ const res = await fetch(`${baseUrl}/api/endpoints`, {
64
+ method: 'POST',
65
+ headers: { 'Content-Type': 'application/json', 'x-wallet-address': account.address },
66
+ body: JSON.stringify(config),
67
+ });
68
+ if (!res.ok) {
69
+ const text = await res.text();
70
+ throw new Error(`Failed to create endpoint: ${res.status} ${text}`);
71
+ }
72
+ return res.json();
73
+ },
74
+ async getEndpoint(id) {
75
+ const res = await fetch(`${baseUrl}/api/endpoints/${id}`);
76
+ if (!res.ok)
77
+ throw new Error(`Failed to get endpoint: ${res.status}`);
78
+ return res.json();
79
+ },
80
+ async updateEndpoint(id, updates) {
81
+ const res = await fetch(`${baseUrl}/api/endpoints/${id}`, {
82
+ method: 'PUT',
83
+ headers: { 'Content-Type': 'application/json', 'x-wallet-address': account.address },
84
+ body: JSON.stringify(updates),
85
+ });
86
+ if (!res.ok) {
87
+ const text = await res.text();
88
+ throw new Error(`Failed to update endpoint: ${res.status} ${text}`);
89
+ }
90
+ return res.json();
91
+ },
92
+ async deleteEndpoint(id) {
93
+ const res = await fetch(`${baseUrl}/api/endpoints/${id}`, {
94
+ method: 'DELETE',
95
+ headers: { 'x-wallet-address': account.address },
96
+ });
97
+ if (!res.ok) {
98
+ const text = await res.text();
99
+ throw new Error(`Failed to delete endpoint: ${res.status} ${text}`);
100
+ }
101
+ return res.json();
102
+ },
103
+ async listEndpoints(opts = {}) {
104
+ const params = new URLSearchParams();
105
+ if (opts.limit)
106
+ params.set('limit', String(opts.limit));
107
+ if (opts.sortBy)
108
+ params.set('sortBy', opts.sortBy);
109
+ if (opts.namespace)
110
+ params.set('namespace', opts.namespace);
111
+ if (opts.search)
112
+ params.set('search', opts.search);
113
+ const res = await fetch(`${baseUrl}/api/endpoints?${params}`);
114
+ if (!res.ok)
115
+ throw new Error(`Failed to list endpoints: ${res.status}`);
116
+ return res.json();
117
+ },
61
118
  // ─── Workflows ───
62
119
  /**
63
120
  * List workflows. Optionally filter by creator or status.
@@ -84,6 +141,41 @@ export function createClient(config) {
84
141
  throw new Error(`Failed to get workflow: ${res.status}`);
85
142
  return res.json();
86
143
  },
144
+ async createWorkflow(config) {
145
+ const res = await fetch(`${baseUrl}/api/workflows`, {
146
+ method: 'POST',
147
+ headers: { 'Content-Type': 'application/json', 'x-wallet-address': account.address },
148
+ body: JSON.stringify(config),
149
+ });
150
+ if (!res.ok) {
151
+ const text = await res.text();
152
+ throw new Error(`Failed to create workflow: ${res.status} ${text}`);
153
+ }
154
+ return res.json();
155
+ },
156
+ async updateWorkflow(workflowId, updates) {
157
+ const res = await fetch(`${baseUrl}/api/workflows/${workflowId}`, {
158
+ method: 'PUT',
159
+ headers: { 'Content-Type': 'application/json', 'x-wallet-address': account.address },
160
+ body: JSON.stringify(updates),
161
+ });
162
+ if (!res.ok) {
163
+ const text = await res.text();
164
+ throw new Error(`Failed to update workflow: ${res.status} ${text}`);
165
+ }
166
+ return res.json();
167
+ },
168
+ async deleteWorkflow(workflowId) {
169
+ const res = await fetch(`${baseUrl}/api/workflows/${workflowId}`, {
170
+ method: 'DELETE',
171
+ headers: { 'x-wallet-address': account.address },
172
+ });
173
+ if (!res.ok) {
174
+ const text = await res.text();
175
+ throw new Error(`Failed to delete workflow: ${res.status} ${text}`);
176
+ }
177
+ return res.json();
178
+ },
87
179
  /**
88
180
  * Run a workflow. Handles x402 payment automatically.
89
181
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apinow-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Pay-per-call API SDK & CLI for APINow.fun — endpoints + workflows, wraps x402 so you don't have to",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",