apinow-sdk 0.29.0 → 0.30.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
@@ -210,7 +210,6 @@ program
210
210
  .requiredOption('--description <desc>', 'Description')
211
211
  .option('--method <method>', 'HTTP method', 'POST')
212
212
  .option('--price <usdc>', 'USDC price per call', '0.01')
213
- .option('--splits <json>', 'Splits JSON array. Each entry: {address, [basisPoints|amount|percent], label?, tokenAddress?}. Resolved basisPoints must sum to 10000.')
214
213
  .option('-k, --key <privateKey>', 'Wallet private key')
215
214
  .action(async (opts) => {
216
215
  try {
@@ -223,8 +222,6 @@ program
223
222
  httpMethod: opts.method.toUpperCase(),
224
223
  paymentOptions: [{ usdAmount: opts.price, amount: opts.price }],
225
224
  };
226
- if (opts.splits)
227
- body.splits = JSON.parse(opts.splits);
228
225
  const data = await fetchJson(`${API_BASE}/api/endpoints`, {
229
226
  method: 'POST',
230
227
  headers: await walletHeaders(privateKey),
@@ -245,7 +242,6 @@ program
245
242
  .option('--url <url>', 'New URL')
246
243
  .option('--price <usdc>', 'New USDC price')
247
244
  .option('--status <status>', 'New status')
248
- .option('--splits <json>', 'Splits JSON array (entries accept basisPoints|amount|percent). Changing splits redeploys the splitter contract (V2 is immutable).')
249
245
  .option('-k, --key <privateKey>', 'Wallet private key')
250
246
  .action(async (id, opts) => {
251
247
  try {
@@ -259,8 +255,6 @@ program
259
255
  body.status = opts.status;
260
256
  if (opts.price)
261
257
  body.paymentOptions = [{ usdAmount: opts.price, amount: opts.price }];
262
- if (opts.splits)
263
- body.splits = JSON.parse(opts.splits);
264
258
  const data = await fetchJson(`${API_BASE}/api/endpoints/${id}`, {
265
259
  method: 'PUT',
266
260
  headers: await walletHeaders(privateKey),
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const APINOW_SDK_VERSION = "0.29.0";
1
+ export declare const APINOW_SDK_VERSION = "0.30.0";
2
2
  export interface CallOptions {
3
3
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
4
4
  body?: Record<string, any>;
@@ -61,17 +61,26 @@ export interface SplitConfig {
61
61
  * { address, amount: "0.05" } // USDC dollars
62
62
  * { address, percent: 30 } // 30.00 %
63
63
  *
64
- * The array as a whole must still sum to 10000 bps (100%). Mix and match
65
- * per entry; amount / percent are just convenience forms so you don't
66
- * have to compute bps manually.
64
+ * The array as a whole must still sum to 10000 bps (100%), with ±0.01
65
+ * bps tolerance. Mix and match per entry.
66
+ *
67
+ * Precision: `basisPoints` accepts fractional values up to 2 decimal
68
+ * places (e.g. `600.6`), matching the 4-decimal `percentAllocation`
69
+ * that 0xSplits V2 supports natively. This means amount inputs like
70
+ * `"0.02"` on a `"0.333"` total survive as 600.6 bps (6.006 %) instead
71
+ * of rounding to 601 bps. Use amount / percent inputs and let the
72
+ * backend compute the exact bps for you.
67
73
  */
68
74
  export interface SplitInput {
69
75
  address: string;
70
76
  label?: string;
71
77
  tokenAddress?: string;
72
78
  recipientAddress?: string;
79
+ /** 0–10000, up to 2 decimal places of bps (= 4 decimal places of %). */
73
80
  basisPoints?: number;
81
+ /** USDC dollars. Converted via `amount / totalPrice * 10000` at 2-decimal bps. */
74
82
  amount?: number | string;
83
+ /** 0–100, up to 4 decimal places. Converted via `percent * 100`. */
75
84
  percent?: number | string;
76
85
  }
77
86
  /**
@@ -141,13 +150,6 @@ export declare function createClient(config: ApinowConfig): {
141
150
  * Get public endpoint info (free, no payment).
142
151
  */
143
152
  info(namespace: string, endpointName: string): Promise<any>;
144
- /**
145
- * Create an endpoint. If `splits` are provided they must sum to exactly
146
- * `10000` basis points; the server deploys a 0xSplits V2 splitter after
147
- * creation and stores `splitterAddress` on the endpoint. Non-fatal if
148
- * the splitter deploy fails — endpoint will exist without one and can be
149
- * retried via `updateEndpoint({ splits })`.
150
- */
151
153
  createEndpoint(config: {
152
154
  namespace: string;
153
155
  endpointName: string;
@@ -166,15 +168,8 @@ export declare function createClient(config: ApinowConfig): {
166
168
  exampleQuery?: any;
167
169
  exampleOutput?: any;
168
170
  docsUrl?: string;
169
- splits?: SplitInput[];
170
171
  }): Promise<any>;
171
172
  getEndpoint(id: string): Promise<any>;
172
- /**
173
- * Update an endpoint. Changing `splits` (structurally) redeploys the
174
- * splitter contract (V2 is immutable); the old address is archived on
175
- * `previousSplitters[]` and the platform drains leftover USDC from it.
176
- * `splits` must sum to `10000` basis points when non-empty.
177
- */
178
173
  updateEndpoint(id: string, updates: {
179
174
  url?: string;
180
175
  description?: string;
@@ -186,7 +181,6 @@ export declare function createClient(config: ApinowConfig): {
186
181
  tokenSymbol?: string;
187
182
  }>;
188
183
  status?: string;
189
- splits?: SplitInput[];
190
184
  querySchema?: any;
191
185
  responseSchema?: any;
192
186
  exampleQuery?: any;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { x402Client, wrapFetchWithPayment } from '@x402/fetch';
2
2
  import { registerExactEvmScheme } from '@x402/evm/exact/client';
3
3
  import { privateKeyToAccount } from 'viem/accounts';
4
4
  const APINOW_BASE = 'https://www.apinow.fun';
5
- export const APINOW_SDK_VERSION = '0.29.0';
5
+ export const APINOW_SDK_VERSION = '0.30.0';
6
6
  /**
7
7
  * Default base URL. In a browser we prefer the current origin so that
8
8
  * signed-auth writes stay same-origin and don't hit a CORS preflight
@@ -226,13 +226,6 @@ export function createClient(config) {
226
226
  return res.json();
227
227
  },
228
228
  // ─── Endpoint CRUD ───
229
- /**
230
- * Create an endpoint. If `splits` are provided they must sum to exactly
231
- * `10000` basis points; the server deploys a 0xSplits V2 splitter after
232
- * creation and stores `splitterAddress` on the endpoint. Non-fatal if
233
- * the splitter deploy fails — endpoint will exist without one and can be
234
- * retried via `updateEndpoint({ splits })`.
235
- */
236
229
  async createEndpoint(config) {
237
230
  return authedJson(`${baseUrl}/api/endpoints`, {
238
231
  method: 'POST',
@@ -245,12 +238,6 @@ export function createClient(config) {
245
238
  throw new Error(`Failed to get endpoint: ${res.status}`);
246
239
  return res.json();
247
240
  },
248
- /**
249
- * Update an endpoint. Changing `splits` (structurally) redeploys the
250
- * splitter contract (V2 is immutable); the old address is archived on
251
- * `previousSplitters[]` and the platform drains leftover USDC from it.
252
- * `splits` must sum to `10000` basis points when non-empty.
253
- */
254
241
  async updateEndpoint(id, updates) {
255
242
  return authedJson(`${baseUrl}/api/endpoints/${id}`, {
256
243
  method: 'PUT',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apinow-sdk",
3
- "version": "0.29.0",
3
+ "version": "0.30.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",