@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
- Create a Pinterest developer account at https://developers.pinterest.com/
- Create a new app in the Pinterest Developers portal
- Use OAuth 2.0 flow to obtain an access token
- 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 dateendDate: Filter content created before this dateincludeComments: Include comments on pins (default: false)includeLikes: Include liked pins (default: false)includeBoards: Include user boards (default: true)maxPins: Maximum number of pins to fetchmaxBoards: Maximum number of boards to fetchmaxComments: Maximum number of comments to fetchmaxLikes: 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 windowmaxRequests: Maximum requests allowed per windowremaining: Remaining requests in current windowresetsAt: 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 identifiertitle: Pin titledescription: Pin descriptionlink: Source URLmedia: Media information (images, video)created_at: Creation timestampmetrics: Engagement metrics (saves, comments)
Board
Represents a curated collection with:
id: Unique identifiername: Board namedescription: Board descriptioncategory: Board categorypin_count: Number of pins in boardfollower_count: Number of followersprivacy: Privacy setting (PUBLIC, SECRET, etc.)
Comment
Represents a discussion on a pin with:
id: Unique identifiertext: Comment textcreated_at: Creation timestamplikes: Number of likesreply_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