File size: 7,471 Bytes
4406729
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# LinkedIn Data Integration Guide

## πŸš€ Quick Setup (5 Minutes)

This guide shows you how to integrate LinkedIn profile data into StrategyStack using RapidAPI's free tier.

---

## Step 1: Get Your Free API Key

1. **Sign up on RapidAPI** (free, no credit card): https://rapidapi.com
2. **Search for** "Fresh LinkedIn Profile Data"
3. **Subscribe to FREE tier** (50 requests/month)
4. **Copy your API key** from the dashboard

---

## Step 2: Add API Key to Spaces

1. Go to **Settings** tab in this Space
2. Scroll to **Variables and secrets**
3. Click **New secret**
4. Name: `RAPIDAPI_KEY`
5. Value: Paste your API key
6. Click **Save**

---

## Step 3: What You Get

### Free Tier (No Credit Card Required)
- βœ… 50 requests per month
- βœ… 1000 requests per hour rate limit
- βœ… Full profile data access
- βœ… 1-2 second response time

### Profile Data Includes:
- Full name, profile photo URL
- Current title & company
- Complete work history
- Education background
- Skills & endorsements
- Location, connections count
- Profile summary/bio
- LinkedIn profile URL

---

## Implementation Details

The integration is already built into the app via `linkedin_data.py`:

```python
import requests
import os

def fetch_linkedin_profile(profile_url: str) -> dict:
    """Fetch LinkedIn profile data using RapidAPI"""
    api_key = os.getenv('RAPIDAPI_KEY')
    
    url = "https://fresh-linkedin-profile-data.p.rapidapi.com/get-linkedin-profile"
    
    headers = {
        "x-rapidapi-key": api_key,
        "x-rapidapi-host": "fresh-linkedin-profile-data.p.rapidapi.com"
    }
    
    response = requests.get(url, headers=headers, params={"linkedin_url": profile_url})
    
    if response.status_code == 200:
        return response.json()
    return None
```

---

## Usage in Dashboard

Once configured, the dashboard automatically enriches lead data:

### Before Enrichment:
```python
lead = {
    "contact_id": "c123",
    "linkedin_url": "https://linkedin.com/in/username"
}
```

### After Enrichment:
```python
lead = {
    "contact_id": "c123",
    "linkedin_url": "https://linkedin.com/in/username",
    "full_name": "John Doe",
    "headline": "CEO at Tech Company",
    "location": "San Francisco, CA",
    "current_company": "Tech Company",
    "current_title": "Chief Executive Officer",
    "experience": [...],
    "education": [...],
    "skills": ["Leadership", "Strategy", ...]
}
```

---

## Cost & Scaling

### Free Tier Strategy
**50 requests/month is perfect for:**
- Initial demo and testing
- 1-2 pilot customers
- Enriching your "hottest" leads only
- Development environment

**Best Practices:**
- Cache enriched profiles (stored in user's `/data` directory)
- Only enrich leads with high engagement
- Don't re-fetch same profile repeatedly
- Use strategically for key decision-makers

### When to Upgrade

**Pro Plan: $50/month**
- 20,000 requests/month (~650/day)
- Perfect for 5-10 active customers
- Small-medium outreach campaigns

**Ultra Plan: $200/month**
- 100,000 requests/month (~3,300/day)
- 10-20 active customers
- Large-scale campaigns

**Mega Plan: $500/month**
- 500,000 requests/month (~16,600/day)
- Enterprise scale
- Unlimited customers

---

## Legal & Compliance

### What's Legal βœ…
- Scraping **public** LinkedIn data (hiQ Labs v. LinkedIn precedent)
- Using for B2B lead enrichment
- Caching data for business purposes
- Providing value-added services to customers

### Best Practices ⚠️
- Use only for legitimate business purposes
- Don't resell raw LinkedIn data
- Respect privacy laws (GDPR, CCPA)
- Provide data opt-out mechanisms
- Be transparent with customers about data sources

### What to Avoid ❌
- Selling scraped data to third parties
- Storing sensitive personal data unnecessarily
- Excessive scraping (respect rate limits)
- Mixing with breached/unauthorized data

---

## Testing Your Integration

### Test Profile URLs:
```
https://linkedin.com/in/williamhgates
https://linkedin.com/in/jeffweiner08
https://linkedin.com/in/satyanadella
```

### Quick Test:
1. Add your `RAPIDAPI_KEY` to Spaces Secrets
2. Restart the Space
3. Go to "Consent/Event Audit" tab
4. Add a contact with a LinkedIn URL
5. Click "Refresh Data"
6. See enriched profile information!

---

## Troubleshooting

### "API Key Not Found" Error
**Solution:** 
- Verify `RAPIDAPI_KEY` is in Spaces Secrets
- Check spelling (case-sensitive)
- Restart Space after adding secret

### "Rate Limit Exceeded" Error
**Solution:**
- You've used your 50 free requests this month
- Wait until next month or upgrade plan
- Implement caching to reduce requests

### "Invalid Profile URL" Error
**Solution:**
- Use full LinkedIn URL: `https://linkedin.com/in/username`
- Remove trailing slashes
- Ensure profile is public

### Slow Response Times
**Solution:**
- First request may take 2-3 seconds (normal)
- Implement local caching for repeat requests
- Consider background job queue for bulk enrichment

---

## Alternative Options

### If You Need More Than 50/Month:

**Option 1: User OAuth**
- Have users connect their own LinkedIn
- Zero API costs
- Legal and compliant
- Already supported in this app!

**Option 2: Multiple RapidAPI Accounts**
- Rotate between 2-3 free accounts
- 150 requests/month total
- Good for early stage

**Option 3: Upgrade to Paid**
- $50/month gets you 20,000 requests
- Worth it once you have 3+ paying customers

---

## Advanced Features

### Caching Implementation
```python
def get_cached_or_fetch(linkedin_url: str) -> dict:
    cache_file = f"/data/linkedin_cache/{hash(linkedin_url)}.json"
    
    if os.path.exists(cache_file):
        with open(cache_file, 'r') as f:
            return json.load(f)
    
    profile = fetch_linkedin_profile(linkedin_url)
    
    if profile:
        os.makedirs(os.path.dirname(cache_file), exist_ok=True)
        with open(cache_file, 'w') as f:
            json.dump(profile, f)
    
    return profile
```

### Bulk Enrichment
```python
def enrich_lead_list(leads: list) -> list:
    enriched = []
    for lead in leads:
        if 'linkedin_url' in lead:
            profile = fetch_linkedin_profile(lead['linkedin_url'])
            if profile:
                lead.update(profile)
        enriched.append(lead)
    return enriched
```

---

## Support & Resources

**RapidAPI Documentation:**
- https://rapidapi.com/freshdata-freshdata-default/api/fresh-linkedin-profile-data

**API Response Format:**
```json
{
  "full_name": "John Doe",
  "headline": "CEO at Company",
  "location": "San Francisco, CA",
  "summary": "Experienced leader...",
  "experiences": [
    {
      "title": "CEO",
      "company": "Company Name",
      "start_date": "2020-01",
      "end_date": null,
      "description": "..."
    }
  ],
  "education": [...],
  "skills": [...]
}
```

**Need Help?**
- Check RapidAPI support: https://rapidapi.com/support
- Review HF Spaces docs: https://huggingface.co/docs/hub/spaces
- Contact StrategyStack support via Space discussions

---

## Summary

βœ… **Free tier available** (50 requests/month, no credit card)
βœ… **5-minute setup** (sign up, get key, add to Secrets)
βœ… **Already integrated** into the app (just add API key)
βœ… **Legal & compliant** (public data only)
βœ… **Scales with you** (upgrade when ready)

**Get started now:** https://rapidapi.com

---

**Last Updated:** November 6, 2025
**Integration Status:** βœ… Ready to use - just add API key!
**Free Tier:** 50 requests/month | **Paid:** From $50/month