Overview
LinkedIn integration provides:- Auto-population: Fetch name, headline, summary, and career positions
- Career timelines: Generate isometric 3D timeline graphics via Kie.ai
- Caching: Store scraped data in Sanity to avoid repeated API calls
- Manual refresh: Re-scrape when profile data is outdated
How It Works
Scraped Data
Profile Fields
Career Positions
RapidAPI Integration
API Endpoint
All LinkedIn requests go through server-side proxy:The RapidAPI key is stored server-side as an environment variable and never exposed to the client.
Error Handling
Common Errors:404- Profile not found or private429- Rate limit exceeded500- RapidAPI service error
- Display error message to user
- Option to retry or manually enter data
- Fall back to cached data if available
Caching Strategy
Cache Layers
1. In-Memory Cache (Session-Scoped)- Fastest retrieval (no network call)
- Cleared on page refresh
- Key: Normalized LinkedIn URL
- Stored in guest document
- Includes
scrapedAttimestamp - Persists across sessions
Cache Freshness
Fresh: Data less than 24 hours old Stale: Data older than 24 hours Strategy:- Check in-memory cache (instant)
- Check Sanity cache if fresh (less than 24h)
- Scrape from LinkedIn if stale or missing
Manual Refresh
Force re-scrape withforceRefresh option:
- Guest updates their LinkedIn profile
- Scraped data appears incorrect
- Periodic refresh for accuracy
URL Normalization
All LinkedIn URLs are normalized for consistent caching: Input Examples:- Always HTTPS with
www. - Lowercase username
- Trailing slash
- Extract username from full URLs
Career Timeline Generation
Timeline graphics are generated via Kie.ai’s Nano Banana Pro model.Prompt Template
Timeline generation is triggered manually from the guest profile or automatically during brand kit creation.
Generated Image Storage
Sanity Field:careerTimeline.imageUrl
URL Format: Kie.ai CDN URL (permanent)
Brand Kit Integration: Automatically included in visual assets section
UI Workflows
Adding LinkedIn to Guest
From Guest Profile:- Click “Edit” button
- Enter LinkedIn URL in field
- Save changes
- System validates URL format
- Option to scrape immediately or save URL only
Viewing Scraped Data
Guest Profile Display:- Position/company (from headline)
- LinkedIn icon with external link
- “Scraped X hours ago” timestamp
- “Refresh” button to re-scrape
Generating Timeline
Trigger Options:- Manual: Click “Generate Career Timeline” in guest profile
- Automatic: Triggered when creating brand kit if timeline missing
- Scrape LinkedIn (if needed)
- Generate prompt from career data
- Submit to Kie.ai API
- Poll for completion (or use callback)
- Store image URL in Sanity
- Display in brand kit
Data Validation
Required Fields
Minimum for Timeline:- Guest name
- At least 2 career positions
- Position title and company
- Start dates
- Headline (for context)
- Summary (for bio)
- Position descriptions
- End dates (to show progression)
Quality Checks
Before Scraping:- Validate URL format
- Confirm profile is public
- Check rate limit availability
- Verify non-empty name
- At least 1 position returned
- Dates in valid format
API Reference
Service Functions
scrapeLinkedInProfile(url, options?)
Scrape profile with caching.
Parameters:
url: string- LinkedIn profile URLoptions.cachedProfile?: GuestProfile- Sanity cached dataoptions.forceRefresh?: boolean- Skip cache
Promise<LinkedInProfile>
normalizeLinkedInUrl(url)
Normalize URL for consistent caching.
Parameters:
url: string- Raw LinkedIn URL
string - Normalized URL
isValidLinkedInUrl(url)
Validate URL format.
Parameters:
url: string- URL to check
boolean
generateCareerTimelinePrompt(profile)
Generate Kie.ai prompt from profile data.
Parameters:
profile: LinkedInProfile
string - Formatted prompt
clearProfileCache(url?)
Clear in-memory cache.
Parameters:
url?: string- Specific URL or all if omitted
void
Rate Limits
RapidAPI Plan: Depends on subscription tier Typical Limits:- 100 requests/day (free tier)
- 1000 requests/day (basic)
- 10000 requests/month (pro)
- Cache aggressively (24h freshness)
- Batch scraping for multiple guests
- Use Sanity as fallback
- Display clear error messages when limit reached
If rate limit is exceeded, system falls back to cached data or allows manual data entry.
Privacy and Compliance
Public Data Only: Scraper only accesses public LinkedIn profile data User Consent: Guests implicitly consent by providing their public profile URL Data Retention: Profile data stored indefinitely in Sanity for operational use Right to Deletion: Guests can request removal of their dataTroubleshooting
Profile Not Found
Causes:- Private profile
- Invalid URL
- Profile deleted or suspended
Incomplete Data
Causes:- Guest has minimal LinkedIn profile
- Career positions missing dates
- No headline or summary
Timeline Generation Fails
Causes:- Insufficient career data (< 2 positions)
- Kie.ai API error
- Invalid prompt formatting
Related Features
Guest Management
Manage guest profiles and contact info
Brand Kit Sharing
Share career timelines in guest brand kits