How to Scrape LinkedIn Profile Data with Node.js
Scrape LinkedIn public profile data using Node.js. This comprehensive guide will walk you through the entire process, from setup to implementation.
Overview
What You'll Learn
- Setting up your Node.js environment
- Installing the required HTTP client
- Authenticating with SociaVault API
- Making requests to LinkedIn
- Handling responses and errors
What You'll Get
- Access to profile data
- JSON formatted responses
- Real-time data access
- Scalable solution
- Error handling patterns
Prerequisites
1. API Key
First, you'll need a SociaVault API key to authenticate your requests.
2. Development Environment
Make sure you have the following installed:
- Node.js installed
- A code editor (VS Code, Sublime, etc.)
- Command line interface access
Implementation
Step 1: Install HTTP Client
We'll use axios to make HTTP requests.
npm install axiosStep 2: API Implementation
Now let's make a request to the LinkedIn API using Node.js. Replace YOUR_API_KEY with your actual API key.
import axios from 'axios';
const API_KEY = 'YOUR_API_KEY';
async function scrape() {
try {
const response = await axios.get(`https://api.sociavault.com/linkedin/profile?url=https%3A%2F%2Fwww.linkedin.com%2Fin%2Fwilliamhgates%2F`, {
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
}
});
console.log('Response:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
// Usage
scrape();Testing Your Code
API Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Example: https://www.linkedin.com/in/williamhgates/ |
Expected Response
You should receive a structured JSON response containing the profile data.
{
"success": true,
"name": "Sam Parr",
"image": "https://media.licdn.com/dms/image/v2/C4E03AQH3Vz1qV_rNVQ/profile-displayphoto-shrink_200_200/profile-displayphoto-shrink_200_200/0/1633389534107?e=2147483647&v=beta&t=8x4PIfTIYFOvpI1QRCDyAhNprZv0NY9kAp4EOdvUxLQ",
"location": "Westport, Connecticut, United States",
"followers": 64803,
"connections": "",
"about": "I founded The Hustle, a business news media company with $12 when I was around 25 years…",
"recentPosts": [
{
"title": "Super excited to watch the success of a company built by a Gauntlet AI grad: One missed contract renewal can cost your company $100k, $250k or more.…",
"activityType": "Posted by Austen Allred",
"link": "https://www.linkedin.com/posts/austenallred_super-excited-to-watch-the-success-of-a-company-activity-7333305862695919617-zTPI",
"image": "https://static.licdn.com/aero-v1/sc/h/53n89ecoxpr1qrki1do3alazb"
}
],
"experience": [
{
"@type": "Organization",
"name": "Hampton",
"url": "https://www.linkedin.com/company/myhampton",
"location": "Austin, Texas Metropolitan Area",
"member": {
"@type": "OrganizationRole",
"description": "******* ** * ****** ****** ********** ********* *** *************, ******** *** ****. <**><**>**'** ** * *** ****, *** ***...* *****.<**><**>*****://***.***********.***/"
}
}
],
"articles": [
{
"headline": "RANT: How to PROPERLY analyze risk",
"author": "Sam Parr",
"datePublished": "2017-09-17T13:08:55.000+00:00",
"image": "https://media.licdn.com/dms/image/v2/C5612AQG9YbLJodxr8g/article-cover_image-shrink_720_1280/article-cover_image-shrink_720_1280/0/1520096757452?e=2147483647&v=beta&t=USPma8tkR65yot8_Ye0zDfH2llLpTrZdZGHtbzmPjQ0",
"articleBody": "I've been talking to a few people who want to leave...."
}
],
"activity": [
{
"title": "Othership is this cool suana place in NYC. The founder is hosting a bunch of Hampton members for a special session + a talk on how he built the…",
"activityType": "Shared by Sam Parr",
"link": "https://www.linkedin.com/posts/parrsam_exclusive-othership-session-qa-with-founder-activity-7328134812047704064-4NUL",
"image": "https://media.licdn.com/dms/image/sync/v2/D4D27AQGJaeiyu-gbrA/articleshare-shrink_1280_800/B4DZbLDrHUHsAU-/0/1747163460743?e=2147483647&v=beta&t=rZtGF2kjhFfLy-TZil0d_bakH4UfHnK-dcxEsrZSl5s"
}
],
"education": [
{
"@type": "EducationalOrganization",
"name": "Belmont University",
"url": "https://www.linkedin.com/school/belmont-university/",
"member": {
"@type": "OrganizationRole",
"startDate": 2008,
"endDate": 2012
}
}
],
"publications": [
{
"name": "How my partner and I created a unique company in tough times",
"url": "http://online.wsj.com/article/SB10001424127887324694904578602013087282582.html&urlhash=SvYD"
}
],
"projects": [
{
"name": "Hustle Con 2015",
"url": "https://www.linkedin.com/in/elizabethyin",
"dateRange": "2015",
"description": "",
"contributors": [
{
"name": "Elizabeth Yin",
"link": "https://www.linkedin.com/in/elizabethyin",
"image": "https://media.licdn.com/dms/image/v2/C5603AQFFdhmfyyiZig/profile-displayphoto-shrink_400_400/profile-displayphoto-shrink_400_400/0/1581292451105?e=2147483647&v=beta&t=IwghMTQZZjJzIGbN6e1IYfWVBDAkgLP_kSJJPOkzQDg"
}
]
}
],
"recommendations": [
{
"name": "Jackie M.",
"link": "https://www.linkedin.com/in/jackiemooney",
"image": "https://static.licdn.com/aero-v1/sc/h/9c8pery4andzj6ohjkjp54ma2",
"text": "“I got to know Sam over 2 years of working at The Hustle. We grew from a company of 4 to 15 in that time and there was never a dull moment- anyone who knows Sam knows that he adds tons of energy to the workplace. This guy figures out what he wants to accomplish and makes it happen. He remains wildly driven and goal-oriented while constantly focused on both his personal and professional growth.”"
}
],
"similarProfiles": [
{
"link": "https://ca.linkedin.com/in/stevemcody",
"name": "Steve Cody",
"image": "https://media.licdn.com/dms/image/v2/D5603AQEl17hna0u1ew/profile-displayphoto-shrink_400_400/profile-displayphoto-shrink_400_400/0/1673387873184?e=2147483647&v=beta&t=pN-Y2CS1AQ8AOKbTo_2_B0AXjof4nGLKBdhNZTfFYJA"
}
]
}Best Practices
Error Handling
Implement comprehensive error handling and retry logic for failed requests. Log errors properly for debugging.
Caching
Cache responses when possible to reduce API calls and improve performance. Consider data freshness requirements.
Security
Never expose your API key in client-side code. Use environment variables and secure key management practices.
Troubleshooting
Unauthorized
Check your API key is correct and properly formatted in the x-api-key header.
Payment Required
You ran out of credits and need to buy more.
Not Found
The resource (user, video, etc.) might not exist or be private.
Too Many Requests
You have exceeded your rate limit. Slow down your requests.
Frequently Asked Questions
How much does it cost to scrape LinkedIn?
SociaVault offers 50 free API calls to get started. After that, pricing starts at $10 for 5k requests with volume discounts available.
Is it legal to scrape LinkedIn data?
Scraping publicly available data is generally considered legal. We only collect public data that is accessible without logging in.
How fast can I scrape LinkedIn?
Our API handles the rate limiting for you. You can make requests as fast as your plan allows.
What data format does the API return?
All API responses are returned in JSON format, making it easy to integrate with any programming language or application.
Related Tutorials
Profile Data in Other Languages
Profile Data with JavaScriptProfile Data with PythonProfile Data with PHPProfile Data with RubyMore Node.js Tutorials
TikTok Profile DataTikTok Profile DemographicsTikTok Profile VideosTikTok Video DetailsReady to Start Scraping?
Get started with 50 free API calls. No credit card required. Stop worrying about proxies and captchas.