@pindownai/client-js 0.3.4 → 0.3.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.
Files changed (2) hide show
  1. package/README.md +95 -103
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -29,7 +29,13 @@ const client = new PindownClient({
29
29
  })
30
30
 
31
31
  // Create a pin
32
- const pin = await client.pins.createMarkdown('# Hello World')
32
+ const pin = await client.pins.create({
33
+ metadata: {
34
+ title: 'My First Pin'
35
+ }
36
+ })
37
+
38
+ console.log(`Pin created: ${pin.id}`)
33
39
 
34
40
  // Check your tier
35
41
  console.log(`Your tier: ${client.getTier()}`)
@@ -46,55 +52,125 @@ if (info) {
46
52
  ### Pins API (`client.pins`)
47
53
 
48
54
  ```typescript
49
- // Create pins
50
- await client.pins.create({ data_type: 'markdown', content: '# Hello' })
51
- await client.pins.createMarkdown('# Hello')
52
- await client.pins.createStatCard({ title: 'Users', value: 1250 })
53
- await client.pins.createTable({ columns: [...], rows: [...] })
54
- await client.pins.createEmbed('https://youtube.com/watch?v=...')
55
+ // Create pin
56
+ await client.pins.create({
57
+ metadata: {
58
+ title: 'My Pin'
59
+ }
60
+ })
61
+
62
+ // Create with permissions
63
+ await client.pins.create({
64
+ is_public: true,
65
+ allow_comments: true,
66
+ metadata: {
67
+ title: 'Public Pin',
68
+ tags: ['docs']
69
+ }
70
+ })
55
71
 
56
72
  // CRUD operations
57
73
  await client.pins.get(pinId)
58
- await client.pins.list({ limit: 10, offset: 0 })
59
- await client.pins.update(pinId, { content: '# Updated' })
74
+ await client.pins.list()
75
+ await client.pins.update(pinId, {
76
+ metadata: { title: 'Updated Title' }
77
+ })
60
78
  await client.pins.delete(pinId)
61
- await client.pins.share(pinId, { is_public: true })
79
+ await client.pins.share(pinId, {
80
+ is_public: true,
81
+ allow_comments: true
82
+ })
62
83
  ```
63
84
 
64
85
  ### Pinboards API (`client.pinboards`)
65
86
 
66
87
  ```typescript
67
88
  // Create & manage pinboards
68
- await client.pinboards.create({ title: 'Dashboard' })
89
+ await client.pinboards.create({
90
+ title: 'Dashboard',
91
+ tags: ['analytics']
92
+ })
69
93
  await client.pinboards.get(boardId)
70
94
  await client.pinboards.list()
71
- await client.pinboards.update(boardId, { title: 'New Title' })
95
+ await client.pinboards.update(boardId, {
96
+ title: 'New Title'
97
+ })
72
98
  await client.pinboards.delete(boardId)
73
99
 
74
100
  // Manage pins in pinboard
75
- await client.pinboards.addPin(boardId, { pin_id: pinId })
101
+ await client.pinboards.addPin(boardId, {
102
+ pin_id: pinId
103
+ })
76
104
  await client.pinboards.removePin(boardId, pinId)
77
- await client.pinboards.updateLayout(boardId, { layout: {...} })
78
- await client.pinboards.share(boardId, { is_public: true })
105
+ await client.pinboards.updateLayout(boardId, {
106
+ layout: { [pinId]: { x: 0, y: 0, w: 2, h: 1 } }
107
+ })
108
+ await client.pinboards.share(boardId, {
109
+ is_public: true,
110
+ allow_comments: true
111
+ })
112
+
113
+ // Custom roles
114
+ await client.pinboards.createRole(boardId, {
115
+ name: 'VIP',
116
+ color: '#FFD700'
117
+ })
118
+ await client.pinboards.listRoles(boardId)
119
+ await client.pinboards.assignUserRoles(boardId, userId, {
120
+ roleIds: ['role-123']
121
+ })
122
+ await client.pinboards.setPinRoleRequirements(boardId, pinId, {
123
+ roleIds: ['role-123']
124
+ })
79
125
  ```
80
126
 
81
127
  ### Datasets API (`client.datasets`)
82
128
 
83
129
  ```typescript
84
- await client.datasets.create({ name: 'Sales', type: 'json', data: {...} })
130
+ // Create JSON dataset
131
+ await client.datasets.create({
132
+ name: 'Sales',
133
+ type: 'json',
134
+ data: { revenue: 125000, customers: 450 }
135
+ })
136
+
137
+ // Create markdown dataset
138
+ await client.datasets.create({
139
+ name: 'Config',
140
+ type: 'markdown',
141
+ data: '# Company\nAcme Corp'
142
+ })
143
+
144
+ // CRUD operations
85
145
  await client.datasets.get(datasetId)
86
146
  await client.datasets.list()
87
- await client.datasets.update(datasetId, { data: {...} })
147
+ await client.datasets.update(datasetId, {
148
+ data: { revenue: 150000 }
149
+ })
88
150
  await client.datasets.delete(datasetId)
151
+
152
+ // Share dataset
153
+ await client.datasets.inviteCollaborator(datasetId, {
154
+ email: 'user@example.com',
155
+ role: 'editor'
156
+ })
89
157
  ```
90
158
 
91
159
  ### Blocks API (`client.blocks`)
92
160
 
93
161
  ```typescript
94
- await client.blocks.create(pinId, { name: 'Header', type: 'markdown', template: '# Title' })
162
+ await client.blocks.create(pinId, {
163
+ title: 'Header',
164
+ type: 'markdown',
165
+ template: '# Title',
166
+ order: 1
167
+ })
95
168
  await client.blocks.get(pinId, blockId)
96
169
  await client.blocks.list(pinId)
97
- await client.blocks.update(pinId, blockId, { template: '# Updated' })
170
+ await client.blocks.update(pinId, blockId, {
171
+ title: 'Updated Header',
172
+ template: '# Updated'
173
+ })
98
174
  await client.blocks.delete(pinId, blockId)
99
175
  ```
100
176
 
@@ -116,90 +192,6 @@ await client.collaborators.removeFromPinboard(boardId, userId)
116
192
  await client.collaborators.getPinboardPermissions(boardId)
117
193
  ```
118
194
 
119
- ## Rate Limiting
120
-
121
- Your tier is **automatically detected** from the API server via the `X-RateLimit-Tier` header. The client tracks rate limits client-side and throws a `RateLimitError` **before** making requests that would exceed your tier's limits.
122
-
123
- ```typescript
124
- // First request auto-detects your tier
125
- await client.pins.list()
126
-
127
- // Now you can check your tier
128
- console.log(`Your tier: ${client.getTier()}`) // e.g., "hobby"
129
-
130
- // Check current usage
131
- const info = client.getRateLimitInfo()
132
- if (info) {
133
- console.log(`Minute: ${info.minute.used}/${info.minute.limit}`)
134
- console.log(`Hour: ${info.hour.used}/${info.hour.limit}`)
135
- }
136
-
137
- // Client blocks requests that would exceed limits
138
- try {
139
- await client.pins.create({...})
140
- } catch (error) {
141
- if (error instanceof RateLimitError) {
142
- console.log(`Rate limit exceeded: ${error.used}/${error.limit}`)
143
- console.log(`Reset at: ${error.resetAt}`)
144
- }
145
- }
146
- ```
147
-
148
- ### Tier Limits
149
-
150
- | Tier | Tokens/Minute | Tokens/Hour |
151
- |------|---------------|-------------|
152
- | Starter | - | 16 |
153
- | Hobby | 100 | 6,000 |
154
- | Pro | 400 | 24,000 |
155
- | Teams | 1,000 | 60,000 |
156
- | Agency | 4,000 | 240,000 |
157
-
158
- **Token Costs:**
159
- - Standard requests (GET, POST, PUT, DELETE): **1 token**
160
- - Invite/Share requests: **3 tokens** (email costs)
161
- - Batch operations: **3-10 tokens** (based on size)
162
-
163
- ## Error Handling
164
-
165
- ```typescript
166
- import {
167
- AuthenticationError,
168
- ForbiddenError,
169
- NotFoundError,
170
- ValidationError,
171
- RateLimitError,
172
- ServerError,
173
- NetworkError
174
- } from '@pindown/api-client'
175
-
176
- try {
177
- await client.pins.create({...})
178
- } catch (error) {
179
- if (error instanceof RateLimitError) {
180
- // Handle rate limit
181
- } else if (error instanceof AuthenticationError) {
182
- // Invalid API key
183
- } else if (error instanceof ValidationError) {
184
- // Invalid request data
185
- }
186
- }
187
- ```
188
-
189
- ## Configuration
190
-
191
- ```typescript
192
- const client = new PindownClient({
193
- apiKey: 'pk_live_...', // Required
194
- tier: 'hobby', // Optional - auto-detected from server
195
- baseURL: 'https://api.pindown.ai/v1', // Optional
196
- enableRateLimitTracking: true, // Optional (default: true)
197
- maxRetries: 3, // Optional (default: 3)
198
- timeout: 30000 // Optional (default: 30s)
199
- })
200
- ```
201
-
202
- **Note:** The `tier` parameter is optional and only for testing. In production, your tier is automatically detected from the server based on your API key.
203
195
 
204
196
  ## Documentation
205
197
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pindownai/client-js",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Official TypeScript/JavaScript client for the Pindown.ai API with built-in rate limiting",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",