LinkedIn is the world’s largest professional network with over 800 million members. As a professional networking site, LinkedIn contains a wealth of information about its members including profile details, skills, education history, work experience, connections, and more. Luckily, LinkedIn provides APIs that allow you to access this data programatically.
The LinkedIn API allows you to retrieve profile data for LinkedIn members who have granted permission for their data to be shared. This allows you to build applications that can pull profile data, analyze skills and connections, and more. Here is a guide on how to get started accessing LinkedIn profile data using the LinkedIn API.
Prerequisites
Before you can start fetching LinkedIn profile data, you need to:
- Register as a LinkedIn developer and create a LinkedIn app to get API keys
- Understand the permissions model and request necessary permissions from users
- Have the LinkedIn member ID of the profiles you want to retrieve data for
Register as a LinkedIn Developer
To use the LinkedIn APIs, you first need to register as a LinkedIn developer. Here are the steps:
- Go to https://www.linkedin.com/developers/ and click ‘Get Started’
- Sign in with your LinkedIn account credentials
- Accept the API Terms of Use and click ‘Create App’
- Fill in details for your app including name, description, logo, app website etc.
- Agree to the API Policy and click ‘Submit’
Once you submit, you will get a Client ID and Client Secret for your app. These will be used to authenticate when making API calls. You can find them on the Auth tab of your app.
Understand Permissions
LinkedIn uses an OAuth 2.0 based permissions model to grant access to member data. There are different levels of permissions a member can grant to an app:
- r_liteprofile: Read-only access to basic profile data
- r_emailaddress: Read access to primary email address
- w_member_social: Write access to post shares on member’s behalf
To retrieve full profile data, you need to request the r_fullprofile permission from users. This provides read access to the full member profile including contact info, work history, education etc. The full list of scopes is available in the LinkedIn docs.
Get LinkedIn Member IDs
To retrieve profile data for a LinkedIn member, you need their member ID. This is a unique numeric identifier for each member. There are a couple ways to get a LinkedIn member’s ID:
- Parse it from their public profile URL. The id is the numeric portion at the end e.g. www.linkedin.com/in/123456/
- Use the LinkedIn Sign In to retrieve the member’s profile on your app’s backend. The ID will be included.
- Make an API call to retrieve profile data and extract the id from the response.
Once you have the member IDs, you can use them to make API calls to get profile data.
Authentication
To make API calls, you first need to authenticate with LinkedIn and get an access token. LinkedIn uses the OAuth 2.0 protocol for authentication.
Here are the steps to authenticate:
- Redirect users to LinkedIn’s OAuth 2.0 authorization URL including your client ID, redirect URL and requested scopes.
- LinkedIn will prompt users to sign in and authorize your app.
- On approval, LinkedIn will redirect back to your app with a
code
query parameter. - Make a POST request to LinkedIn’s OAuth 2.0 token endpoint with the code, client ID, client secret to generate an access token.
- Use this access token in subsequent API calls by passing it in the
Authorization
header.
This access token is short lived (expires in 2 months), so you need to refresh it periodically. The detailed OAuth 2.0 authentication steps can be found in the LinkedIn docs.
Calling the Profile API
Once you have obtained the access token, you can start making calls to the Profile API to retrieve member data. The LinkedIn Profile API exposes a REST endpoint that can be called to get full profile data:
GET https://api.linkedin.com/v2/me
To retrieve profile data for a specific member, pass their id using the id
query parameter:
GET https://api.linkedin.com/v2/me?id=MEMBER_ID
Here is sample code to call this API in Python:
import requests api_url = f"https://api.linkedin.com/v2/me?id={member_id}" headers = { 'Authorization': f"Bearer {access_token}" } response = requests.get(api_url, headers=headers) print(response.json())
The API returns a JSON response containing the member’s full profile data. This includes:
- Basic info – name, headline, location etc.
- Email addresses
- Phone numbers
- Skills
- Education history
- Work experience
- Accomplishments
- Recommendations
- Connections
- And more…
You can filter the fields returned using the projection
query parameter. This allows you to return only the profile data you need.
For example, to return just the work experience, skills and education history:
GET https://api.linkedin.com/v2/me?projection=(elements*(skills,educations,positions))&id=MEMBER_ID
The Profile API reference provides the full details on all the available profile fields that can be returned.
Handling Paginated Data
Some profile data like skills, education history and positions can be quite large. To limit response size, the API paginates large data fields. For example, only the first 10 skills may be returned by default.
To return the next page of results, you need to pass the start
query parameter with a value from the _page
object returned in the previous response.
For example, if the initial response contains:
"_page": { "count": 10, "start": 0 }
To get the next page, call the API again passing start=10
:
GET https://api.linkedin.com/v2/me?projection=(elements*(skills))&start=10&id=MEMBER_ID
This paginates through the results 10 at a time. You need to make multiple calls, incrementing the start
parameter to retrieve all paginated fields.
Field Projection
As mentioned earlier, you can use field projection to filter down to specific profile fields using the projection
query parameter.
Some key points on how field projection works:
- Use the
(elements)
wildcard to return all fields at that level - Nested fields are denoted using dot notation e.g.
educations.schoolName
- Use an asterisk
*
to retrieve the full object including all fields - Surround each projection with parentheses e.g.
(positions*,educations,skills)
Here are some examples of useful profile projections:
# Get just name and headline (firstName,lastName,headline) # Get contact info (emailAddress,phoneNumbers) # Get positions (positions*) # Get education history (educations.schoolName,educations.fieldOfStudy) # Get skills (skills) # Get recommendations (recommendations*)
Refer to the Profile API reference for the full list of available profile fields that can be projected.
Limiting API Calls
The LinkedIn API has rate limits in place to prevent abuse. Here are the current limits as per the docs:
- 200,000 calls per day
- 20 calls per second
The returned HTTP response headers contain the status of your current rate limit including:
X-RateLimit-Limit
– Total limitX-RateLimit-Remaining
– Calls remaining in current windowX-RateLimit-Reset
– Epoch time when the rate limit resets
It’s important to check these headers and throttle your calls if approaching the limit:
limit = int(response.headers['X-RateLimit-Limit']) remaining = int(response.headers['X-RateLimit-Remaining']) if remaining < 100: time.sleep(60) # Throttle calls
If you exceed the rate limits, further calls will be blocked and you will get a 429 Too Many Requests
response status code.
Member Share Settings
Keep in mind users can change their profile visibility and API share settings on LinkedIn. This controls what profile data is visible and accessible via the API.
For example, members can configure their profile to only be visible to 1st degree connections. In this case, accessing their full profile via the API would require an access token from one of their 1st degree connections.
Similarly, members can disable share settings for skills, education etc. This would prevent those fields from being returned by the API.
Be sure to handle cases where profile data is not returned due to member visibility settings. The API response will indicate which fields are visible and shareable.
Conclusion
Here are some key takeaways:
- Register as a LinkedIn developer and create an app to get API access
- Implement OAuth 2.0 authentication to get access tokens
- Call the Profile API endpoint with member IDs to get profile data
- Use field projection to return specific profile fields
- Handle pagination for large datasets
- Respect member visibility settings and API rate limits
With the steps covered in this guide, you should be able to get up and running with the LinkedIn Profile API to access member data. The possibilities are endless in terms of building personalized experiences leveraging LinkedIn's professional profile data.
Some ideas:
- Resume builder pulling data from LinkedIn
- Job search site filtering candidates based on skills
- Expert finder site ranking professionals by skills and experience
- Business intelligence tools analyzing hiring trends
So grab your API keys and start building something impactful with LinkedIn's rich member profile datasets!