@agenttoll/sdk 1.0.1 → 1.0.2

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 (2) hide show
  1. package/README.md +56 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,45 +4,81 @@ One-line micropayment integration for AI agents.
4
4
 
5
5
  ## Installation
6
6
 
7
- ### From npm (recommended)
8
7
  ```bash
9
8
  npm install @agenttoll/sdk
10
9
  ```
11
10
 
12
- ### From GitHub (if npm is unavailable)
13
- ```bash
14
- npm install github:agenttoll/sdk
11
+ ## Quick Start
12
+
13
+ ### 1. Get Your API Key
14
+
15
+ ```javascript
16
+ // Via API
17
+ const response = await fetch('https://toll.agenttoll.io/api/publisher/register', {
18
+ method: 'POST',
19
+ headers: { 'Content-Type': 'application/json' },
20
+ body: JSON.stringify({
21
+ name: 'My API',
22
+ email: 'you@example.com',
23
+ wallet_address: 'YourSolanaWallet'
24
+ })
25
+ });
26
+ const { api_key } = await response.json();
15
27
  ```
16
28
 
17
- ### Direct download
18
- Copy [tollbooth.js](./tollbooth.js) into your project.
29
+ Or use the web form at [toll.agenttoll.io](https://toll.agenttoll.io)
19
30
 
20
- ## Usage
31
+ ### 2. Add to Your Server
21
32
 
22
- ### Express
23
33
  ```javascript
24
34
  import tollbooth from '@agenttoll/sdk';
25
- // or if installed locally:
26
- // import tollbooth from './tollbooth.js';
27
35
 
28
- app.use(tollbooth('pk_live_xxx'));
36
+ // Toll all agents, let humans through free
37
+ app.use(tollbooth(process.env.AGENTTOLL_KEY, {
38
+ amount: 0.005, // USDC per request
39
+ freeForHumans: true // Browsers pass free
40
+ }));
41
+
42
+ // Or use the convenience method
43
+ app.use(tollbooth.agentsOnly(process.env.AGENTTOLL_KEY));
29
44
  ```
30
45
 
31
- ### Cloudflare Workers
46
+ ## SDK Options
47
+
32
48
  ```javascript
33
- import { tollgate } from '@agenttoll/sdk/edge';
49
+ tollbooth(apiKey, {
50
+ amount: 0.005, // USDC to charge (default: 0.005)
51
+ freeForHumans: false, // Let browsers through free
52
+ paths: ['*'], // Routes to toll (glob patterns)
53
+ walletAddress: null, // Override default wallet
54
+ bypassHeader: null // Header for internal bypass
55
+ });
56
+ ```
34
57
 
35
- export default tollgate('pk_live_xxx', { amount: 0.005 });
58
+ ## Convenience Methods
59
+
60
+ ```javascript
61
+ // Toll only AI agents
62
+ tollbooth.agentsOnly(apiKey, options)
63
+
64
+ // Protect single route
65
+ tollbooth.protect(apiKey, options)
66
+
67
+ // Check if paid
68
+ tollbooth.hasPaid(req) // boolean
69
+
70
+ // Check if AI agent
71
+ tollbooth.isAgent(req) // boolean
36
72
  ```
37
73
 
38
- ### Agent Tool (for AI agents)
74
+ ## Cloudflare Workers / Edge
75
+
39
76
  ```javascript
40
- import { payTollTool } from '@agenttoll/sdk/tool';
77
+ import { tollgate } from '@agenttoll/sdk/edge';
41
78
 
42
- // Add to your agent's tools
43
- tools: [payTollTool]
79
+ export default tollgate(PUBLISHER_KEY, { amount: 0.01 });
44
80
  ```
45
81
 
46
- ## API Reference
82
+ ## Full Documentation
47
83
 
48
- See [https://agenttoll.io/docs](https://agenttoll.io/docs) for full documentation.
84
+ See [toll.agenttoll.io/docs](https://toll.agenttoll.io/docs)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenttoll/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "One-line micropayment integration for AI agents - Express, Cloudflare Workers, Vercel Edge",
5
5
  "main": "tollbooth.js",
6
6
  "exports": {