Skip to main content

@idiomark/adapter-pinterest

Pinterest adapter for Idiomark (Personality & Communication Protocol) extraction.

Features​

  • Pins: Visual bookmarks with descriptions, links, and metadata
  • Boards: Organized collections showing interests and organizational patterns
  • Board Sections: Sub-collections within boards
  • Comments: Discussion on pins
  • User Profile: Account information and statistics
  • Personality Signals: Analysis of aesthetic preferences, interests, and communication patterns

Authentication​

Uses OAuth 2.0 with access token from Pinterest API v5.

Getting an Access Token​

  1. Create a Pinterest developer account at https://developers.pinterest.com/
  2. Create a new app in the Pinterest Developers portal
  3. Use OAuth 2.0 flow to obtain an access token
  4. Pass the access token to the adapter

Rate Limits​

Pinterest v5 API allows:

  • 1000 requests per hour for authenticated requests
  • Rate limiter automatically handles waiting when limits are approached
  • Use getRateLimitStats() to check current rate limit status

Documentation: https://developers.pinterest.com/docs/api/v5/

Usage​

Basic Usage​

import { PinterestAdapter } from '@idiomark/adapter-pinterest'

const adapter = new PinterestAdapter({
accessToken: 'your_access_token'
})

// Authenticate
await adapter.authenticate()

// Fetch data
const result = await adapter.fetchData({ limit: 100 })

// Get structured output with personality signals
const structured = await adapter.getStructuredOutput({
limit: 100,
includeComments: true,
includeLikes: true
})

console.log(structured.metadata)
console.log(structured.personalitySignals)

Using Factory Function​

import { createPinterestAdapter } from '@idiomark/adapter-pinterest'

const adapter = createPinterestAdapter('your_access_token', {
userId: 'optional_user_id',
username: 'optional_username'
})

const data = await adapter.fetchData({ limit: 50 })

Quick Data Fetch​

import { fetchUserPinterestData } from '@idiomark/adapter-pinterest'

const result = await fetchUserPinterestData('your_access_token', {
limit: 100,
startDate: new Date('2024-01-01'),
endDate: new Date('2024-12-31'),
includeComments: true,
includeBoards: true
})

Methods​

authenticate(): Promise<boolean>​

Authenticates with Pinterest API and fetches user profile.

fetchData(options): Promise<RawContent[]>​

Fetches all relevant data for personality analysis.

Options:

  • limit: Maximum number of items to fetch (default: 100)
  • startDate: Filter content created after this date
  • endDate: Filter content created before this date
  • includeComments: Include comments on pins (default: false)
  • includeLikes: Include liked pins (default: false)
  • includeBoards: Include user boards (default: true)
  • maxPins: Maximum number of pins to fetch
  • maxBoards: Maximum number of boards to fetch
  • maxComments: Maximum number of comments to fetch
  • maxLikes: Maximum number of likes to fetch

fetchPins(options): Promise<PinterestPin[]>​

Fetches pins from the user's profile with pagination support.

fetchBoards(options): Promise<PinterestBoard[]>​

Fetches boards from the user's profile with pagination support.

fetchBoardSections(boardId, options): Promise<PinterestBoardSection[]>​

Fetches sections within a specific board.

fetchBoardPins(boardId, options): Promise<PinterestPin[]>​

Fetches pins from a specific board.

fetchComments(options): Promise<PinterestComment[]>​

Fetches comments on user's pins.

fetchLikes(options): Promise<PinterestLike[]>​

Fetches pins liked/saved by the user.

fetchUser(): Promise<PinterestUser>​

Fetches user profile information.

getStructuredOutput(options): Promise<PinterestAdapterOutput>​

Fetches data and returns structured output with personality signals.

getRateLimitStats()​

Returns current rate limit statistics:

  • requestsMade: Number of requests made in current window
  • maxRequests: Maximum requests allowed per window
  • remaining: Remaining requests in current window
  • resetsAt: When the rate limit window resets

normalize(raw): NormalizedContent​

Normalizes raw Pinterest content to standard Idiomark format.

Data Types​

Pin​

Represents a visual bookmark with:

  • id: Unique identifier
  • title: Pin title
  • description: Pin description
  • link: Source URL
  • media: Media information (images, video)
  • created_at: Creation timestamp
  • metrics: Engagement metrics (saves, comments)

Board​

Represents a curated collection with:

  • id: Unique identifier
  • name: Board name
  • description: Board description
  • category: Board category
  • pin_count: Number of pins in board
  • follower_count: Number of followers
  • privacy: Privacy setting (PUBLIC, SECRET, etc.)

Comment​

Represents a discussion on a pin with:

  • id: Unique identifier
  • text: Comment text
  • created_at: Creation timestamp
  • likes: Number of likes
  • reply_count: Number of replies

Personality Signals​

The adapter extracts personality signals including:

  • Voice: Common phrases, description length, categories
  • Interests: Board names, pin domains, categories
  • Aesthetic: Pin/board counts, rich media usage, favorite colors
  • Communication: Comment patterns, sentiment analysis

Error Handling​

The adapter provides specific error types:

import {
PinterestAdapterError,
PinterestRateLimitError,
PinterestAuthError,
PinterestFetchError
} from '@idiomark/adapter-pinterest'

try {
await adapter.fetchData({ limit: 100 })
} catch (error) {
if (error instanceof PinterestRateLimitError) {
console.log('Rate limit exceeded, please wait')
} else if (error instanceof PinterestAuthError) {
console.log('Authentication failed, check your token')
} else if (error instanceof PinterestFetchError) {
console.log('Fetch error:', error.message)
}
}

License​

MIT