Skip to Content
Pindown.ai is in early alpha - features may change
Client SDKOverview

Client SDK

The @pindownai/client-js SDK provides a type-safe, easy-to-use interface for interacting with the Pindown.ai API.

Installation

npm install @pindownai/client-js

Quick Start

import { PindownClient } from '@pindownai/client-js' const client = new PindownClient({ apiKey: process.env.PINDOWN_API_KEY }) // Your tier is auto-detected from the server!

Configuration

Basic Configuration

const client = new PindownClient({ apiKey: 'pk_live_...' // Required: Your API key })

Advanced Configuration

const client = new PindownClient({ apiKey: 'pk_live_...', // Optional: Custom base URL (defaults to production) baseURL: 'https://api.pindown.ai/v1', // Optional: Enable/disable rate limiting (default: true) enableRateLimitTracking: true, // Optional: Max retry attempts (default: 3) maxRetries: 3, // Optional: Request timeout in ms (default: 30000) timeout: 30000 })

Available APIs

The client provides organized access to all Pindown APIs:

Pins API

// Access pins methods client.pins.create(...) client.pins.get(...) client.pins.list(...) client.pins.update(...) client.pins.delete(...) client.pins.share(...)

View full Pins API documentation →

Pinboards API

// Access pinboards methods client.pinboards.create(...) client.pinboards.get(...) client.pinboards.list(...) client.pinboards.addPin(...) client.pinboards.removePin(...) client.pinboards.updateLayout(...)

View full Pinboards API documentation →

Pages API

// Access pages methods client.pages.create(...) client.pages.get(...) client.pages.list(...) client.pages.update(...) client.pages.delete(...) client.pages.addPin(...) client.pages.removePin(...) client.pages.listPins(...)

View full Pages API documentation →

Rate Limiting

The client automatically tracks your rate limits and throws errors before hitting them:

try { await client.pins.create({ ... }) } catch (error) { if (error instanceof RateLimitError) { console.log(`Rate limit hit! Wait ${error.retryAfter}ms`) console.log(`Used: ${error.used}/${error.limit} tokens`) } }

Get Rate Limit Info

const info = client.getRateLimitInfo() if (info) { console.log('Minute:', `${info.minute.used}/${info.minute.limit}`) console.log('Hour:', `${info.hour.used}/${info.hour.limit}`) }

Get Your Tier

const tier = client.getTier() console.log(`Your tier: ${tier}`) // 'starter', 'hobby', 'pro', etc.

Error Handling

The client provides specific error types for different scenarios:

import { AuthenticationError, ForbiddenError, NotFoundError, ValidationError, RateLimitError, ServerError, NetworkError } from '@pindownai/client-js' try { const pin = await client.pins.get('p-invalid') } catch (error) { if (error instanceof NotFoundError) { console.log('Pin not found') } else if (error instanceof AuthenticationError) { console.log('Invalid API key') } else if (error instanceof ForbiddenError) { console.log('Insufficient permissions') } else if (error instanceof RateLimitError) { console.log('Rate limit exceeded') } }

TypeScript Support

The client is fully typed with TypeScript:

import type { Pin, Page, Pinboard, CreatePinRequest, UpdatePinRequest, CreatePageRequest, // ... all types available } from '@pindownai/client-js' const pin: Pin = await client.pins.create({ pin_type: 'stat-cards', pin_config: { cards: [{ title: 'Revenue', value: '$125,430', change: '+23.5%', trend: 'up' }] }, pin_layout: '1x1', metadata: { title: 'Sales Dashboard', tags: ['sales', 'kpi'] } })

Next Steps