Spaces:
Sleeping
Sleeping
Create LINKEDIN_INTEGRATION.md
Browse filesComplete LinkedIn integration documentation with RapidAPI setup.
Includes:
- Free tier setup (50 requests/month, no credit card)
- Step-by-step configuration guide
- API key integration with HF Spaces Secrets
- Usage examples and code snippets
- Cost analysis and scaling options
- Legal compliance information
- Troubleshooting guide
- Testing instructions
Ready to use - just sign up for RapidAPI and add the API key to Spaces Secrets.
- LINKEDIN_INTEGRATION.md +315 -0
LINKEDIN_INTEGRATION.md
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LinkedIn Data Integration Guide
|
| 2 |
+
|
| 3 |
+
## π Quick Setup (5 Minutes)
|
| 4 |
+
|
| 5 |
+
This guide shows you how to integrate LinkedIn profile data into StrategyStack using RapidAPI's free tier.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Step 1: Get Your Free API Key
|
| 10 |
+
|
| 11 |
+
1. **Sign up on RapidAPI** (free, no credit card): https://rapidapi.com
|
| 12 |
+
2. **Search for** "Fresh LinkedIn Profile Data"
|
| 13 |
+
3. **Subscribe to FREE tier** (50 requests/month)
|
| 14 |
+
4. **Copy your API key** from the dashboard
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## Step 2: Add API Key to Spaces
|
| 19 |
+
|
| 20 |
+
1. Go to **Settings** tab in this Space
|
| 21 |
+
2. Scroll to **Variables and secrets**
|
| 22 |
+
3. Click **New secret**
|
| 23 |
+
4. Name: `RAPIDAPI_KEY`
|
| 24 |
+
5. Value: Paste your API key
|
| 25 |
+
6. Click **Save**
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## Step 3: What You Get
|
| 30 |
+
|
| 31 |
+
### Free Tier (No Credit Card Required)
|
| 32 |
+
- β
50 requests per month
|
| 33 |
+
- β
1000 requests per hour rate limit
|
| 34 |
+
- β
Full profile data access
|
| 35 |
+
- β
1-2 second response time
|
| 36 |
+
|
| 37 |
+
### Profile Data Includes:
|
| 38 |
+
- Full name, profile photo URL
|
| 39 |
+
- Current title & company
|
| 40 |
+
- Complete work history
|
| 41 |
+
- Education background
|
| 42 |
+
- Skills & endorsements
|
| 43 |
+
- Location, connections count
|
| 44 |
+
- Profile summary/bio
|
| 45 |
+
- LinkedIn profile URL
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## Implementation Details
|
| 50 |
+
|
| 51 |
+
The integration is already built into the app via `linkedin_data.py`:
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
import requests
|
| 55 |
+
import os
|
| 56 |
+
|
| 57 |
+
def fetch_linkedin_profile(profile_url: str) -> dict:
|
| 58 |
+
"""Fetch LinkedIn profile data using RapidAPI"""
|
| 59 |
+
api_key = os.getenv('RAPIDAPI_KEY')
|
| 60 |
+
|
| 61 |
+
url = "https://fresh-linkedin-profile-data.p.rapidapi.com/get-linkedin-profile"
|
| 62 |
+
|
| 63 |
+
headers = {
|
| 64 |
+
"x-rapidapi-key": api_key,
|
| 65 |
+
"x-rapidapi-host": "fresh-linkedin-profile-data.p.rapidapi.com"
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
response = requests.get(url, headers=headers, params={"linkedin_url": profile_url})
|
| 69 |
+
|
| 70 |
+
if response.status_code == 200:
|
| 71 |
+
return response.json()
|
| 72 |
+
return None
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## Usage in Dashboard
|
| 78 |
+
|
| 79 |
+
Once configured, the dashboard automatically enriches lead data:
|
| 80 |
+
|
| 81 |
+
### Before Enrichment:
|
| 82 |
+
```python
|
| 83 |
+
lead = {
|
| 84 |
+
"contact_id": "c123",
|
| 85 |
+
"linkedin_url": "https://linkedin.com/in/username"
|
| 86 |
+
}
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
### After Enrichment:
|
| 90 |
+
```python
|
| 91 |
+
lead = {
|
| 92 |
+
"contact_id": "c123",
|
| 93 |
+
"linkedin_url": "https://linkedin.com/in/username",
|
| 94 |
+
"full_name": "John Doe",
|
| 95 |
+
"headline": "CEO at Tech Company",
|
| 96 |
+
"location": "San Francisco, CA",
|
| 97 |
+
"current_company": "Tech Company",
|
| 98 |
+
"current_title": "Chief Executive Officer",
|
| 99 |
+
"experience": [...],
|
| 100 |
+
"education": [...],
|
| 101 |
+
"skills": ["Leadership", "Strategy", ...]
|
| 102 |
+
}
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## Cost & Scaling
|
| 108 |
+
|
| 109 |
+
### Free Tier Strategy
|
| 110 |
+
**50 requests/month is perfect for:**
|
| 111 |
+
- Initial demo and testing
|
| 112 |
+
- 1-2 pilot customers
|
| 113 |
+
- Enriching your "hottest" leads only
|
| 114 |
+
- Development environment
|
| 115 |
+
|
| 116 |
+
**Best Practices:**
|
| 117 |
+
- Cache enriched profiles (stored in user's `/data` directory)
|
| 118 |
+
- Only enrich leads with high engagement
|
| 119 |
+
- Don't re-fetch same profile repeatedly
|
| 120 |
+
- Use strategically for key decision-makers
|
| 121 |
+
|
| 122 |
+
### When to Upgrade
|
| 123 |
+
|
| 124 |
+
**Pro Plan: $50/month**
|
| 125 |
+
- 20,000 requests/month (~650/day)
|
| 126 |
+
- Perfect for 5-10 active customers
|
| 127 |
+
- Small-medium outreach campaigns
|
| 128 |
+
|
| 129 |
+
**Ultra Plan: $200/month**
|
| 130 |
+
- 100,000 requests/month (~3,300/day)
|
| 131 |
+
- 10-20 active customers
|
| 132 |
+
- Large-scale campaigns
|
| 133 |
+
|
| 134 |
+
**Mega Plan: $500/month**
|
| 135 |
+
- 500,000 requests/month (~16,600/day)
|
| 136 |
+
- Enterprise scale
|
| 137 |
+
- Unlimited customers
|
| 138 |
+
|
| 139 |
+
---
|
| 140 |
+
|
| 141 |
+
## Legal & Compliance
|
| 142 |
+
|
| 143 |
+
### What's Legal β
|
| 144 |
+
- Scraping **public** LinkedIn data (hiQ Labs v. LinkedIn precedent)
|
| 145 |
+
- Using for B2B lead enrichment
|
| 146 |
+
- Caching data for business purposes
|
| 147 |
+
- Providing value-added services to customers
|
| 148 |
+
|
| 149 |
+
### Best Practices β οΈ
|
| 150 |
+
- Use only for legitimate business purposes
|
| 151 |
+
- Don't resell raw LinkedIn data
|
| 152 |
+
- Respect privacy laws (GDPR, CCPA)
|
| 153 |
+
- Provide data opt-out mechanisms
|
| 154 |
+
- Be transparent with customers about data sources
|
| 155 |
+
|
| 156 |
+
### What to Avoid β
|
| 157 |
+
- Selling scraped data to third parties
|
| 158 |
+
- Storing sensitive personal data unnecessarily
|
| 159 |
+
- Excessive scraping (respect rate limits)
|
| 160 |
+
- Mixing with breached/unauthorized data
|
| 161 |
+
|
| 162 |
+
---
|
| 163 |
+
|
| 164 |
+
## Testing Your Integration
|
| 165 |
+
|
| 166 |
+
### Test Profile URLs:
|
| 167 |
+
```
|
| 168 |
+
https://linkedin.com/in/williamhgates
|
| 169 |
+
https://linkedin.com/in/jeffweiner08
|
| 170 |
+
https://linkedin.com/in/satyanadella
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
### Quick Test:
|
| 174 |
+
1. Add your `RAPIDAPI_KEY` to Spaces Secrets
|
| 175 |
+
2. Restart the Space
|
| 176 |
+
3. Go to "Consent/Event Audit" tab
|
| 177 |
+
4. Add a contact with a LinkedIn URL
|
| 178 |
+
5. Click "Refresh Data"
|
| 179 |
+
6. See enriched profile information!
|
| 180 |
+
|
| 181 |
+
---
|
| 182 |
+
|
| 183 |
+
## Troubleshooting
|
| 184 |
+
|
| 185 |
+
### "API Key Not Found" Error
|
| 186 |
+
**Solution:**
|
| 187 |
+
- Verify `RAPIDAPI_KEY` is in Spaces Secrets
|
| 188 |
+
- Check spelling (case-sensitive)
|
| 189 |
+
- Restart Space after adding secret
|
| 190 |
+
|
| 191 |
+
### "Rate Limit Exceeded" Error
|
| 192 |
+
**Solution:**
|
| 193 |
+
- You've used your 50 free requests this month
|
| 194 |
+
- Wait until next month or upgrade plan
|
| 195 |
+
- Implement caching to reduce requests
|
| 196 |
+
|
| 197 |
+
### "Invalid Profile URL" Error
|
| 198 |
+
**Solution:**
|
| 199 |
+
- Use full LinkedIn URL: `https://linkedin.com/in/username`
|
| 200 |
+
- Remove trailing slashes
|
| 201 |
+
- Ensure profile is public
|
| 202 |
+
|
| 203 |
+
### Slow Response Times
|
| 204 |
+
**Solution:**
|
| 205 |
+
- First request may take 2-3 seconds (normal)
|
| 206 |
+
- Implement local caching for repeat requests
|
| 207 |
+
- Consider background job queue for bulk enrichment
|
| 208 |
+
|
| 209 |
+
---
|
| 210 |
+
|
| 211 |
+
## Alternative Options
|
| 212 |
+
|
| 213 |
+
### If You Need More Than 50/Month:
|
| 214 |
+
|
| 215 |
+
**Option 1: User OAuth**
|
| 216 |
+
- Have users connect their own LinkedIn
|
| 217 |
+
- Zero API costs
|
| 218 |
+
- Legal and compliant
|
| 219 |
+
- Already supported in this app!
|
| 220 |
+
|
| 221 |
+
**Option 2: Multiple RapidAPI Accounts**
|
| 222 |
+
- Rotate between 2-3 free accounts
|
| 223 |
+
- 150 requests/month total
|
| 224 |
+
- Good for early stage
|
| 225 |
+
|
| 226 |
+
**Option 3: Upgrade to Paid**
|
| 227 |
+
- $50/month gets you 20,000 requests
|
| 228 |
+
- Worth it once you have 3+ paying customers
|
| 229 |
+
|
| 230 |
+
---
|
| 231 |
+
|
| 232 |
+
## Advanced Features
|
| 233 |
+
|
| 234 |
+
### Caching Implementation
|
| 235 |
+
```python
|
| 236 |
+
def get_cached_or_fetch(linkedin_url: str) -> dict:
|
| 237 |
+
cache_file = f"/data/linkedin_cache/{hash(linkedin_url)}.json"
|
| 238 |
+
|
| 239 |
+
if os.path.exists(cache_file):
|
| 240 |
+
with open(cache_file, 'r') as f:
|
| 241 |
+
return json.load(f)
|
| 242 |
+
|
| 243 |
+
profile = fetch_linkedin_profile(linkedin_url)
|
| 244 |
+
|
| 245 |
+
if profile:
|
| 246 |
+
os.makedirs(os.path.dirname(cache_file), exist_ok=True)
|
| 247 |
+
with open(cache_file, 'w') as f:
|
| 248 |
+
json.dump(profile, f)
|
| 249 |
+
|
| 250 |
+
return profile
|
| 251 |
+
```
|
| 252 |
+
|
| 253 |
+
### Bulk Enrichment
|
| 254 |
+
```python
|
| 255 |
+
def enrich_lead_list(leads: list) -> list:
|
| 256 |
+
enriched = []
|
| 257 |
+
for lead in leads:
|
| 258 |
+
if 'linkedin_url' in lead:
|
| 259 |
+
profile = fetch_linkedin_profile(lead['linkedin_url'])
|
| 260 |
+
if profile:
|
| 261 |
+
lead.update(profile)
|
| 262 |
+
enriched.append(lead)
|
| 263 |
+
return enriched
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
---
|
| 267 |
+
|
| 268 |
+
## Support & Resources
|
| 269 |
+
|
| 270 |
+
**RapidAPI Documentation:**
|
| 271 |
+
- https://rapidapi.com/freshdata-freshdata-default/api/fresh-linkedin-profile-data
|
| 272 |
+
|
| 273 |
+
**API Response Format:**
|
| 274 |
+
```json
|
| 275 |
+
{
|
| 276 |
+
"full_name": "John Doe",
|
| 277 |
+
"headline": "CEO at Company",
|
| 278 |
+
"location": "San Francisco, CA",
|
| 279 |
+
"summary": "Experienced leader...",
|
| 280 |
+
"experiences": [
|
| 281 |
+
{
|
| 282 |
+
"title": "CEO",
|
| 283 |
+
"company": "Company Name",
|
| 284 |
+
"start_date": "2020-01",
|
| 285 |
+
"end_date": null,
|
| 286 |
+
"description": "..."
|
| 287 |
+
}
|
| 288 |
+
],
|
| 289 |
+
"education": [...],
|
| 290 |
+
"skills": [...]
|
| 291 |
+
}
|
| 292 |
+
```
|
| 293 |
+
|
| 294 |
+
**Need Help?**
|
| 295 |
+
- Check RapidAPI support: https://rapidapi.com/support
|
| 296 |
+
- Review HF Spaces docs: https://huggingface.co/docs/hub/spaces
|
| 297 |
+
- Contact StrategyStack support via Space discussions
|
| 298 |
+
|
| 299 |
+
---
|
| 300 |
+
|
| 301 |
+
## Summary
|
| 302 |
+
|
| 303 |
+
β
**Free tier available** (50 requests/month, no credit card)
|
| 304 |
+
β
**5-minute setup** (sign up, get key, add to Secrets)
|
| 305 |
+
β
**Already integrated** into the app (just add API key)
|
| 306 |
+
β
**Legal & compliant** (public data only)
|
| 307 |
+
β
**Scales with you** (upgrade when ready)
|
| 308 |
+
|
| 309 |
+
**Get started now:** https://rapidapi.com
|
| 310 |
+
|
| 311 |
+
---
|
| 312 |
+
|
| 313 |
+
**Last Updated:** November 6, 2025
|
| 314 |
+
**Integration Status:** β
Ready to use - just add API key!
|
| 315 |
+
**Free Tier:** 50 requests/month | **Paid:** From $50/month
|