In this first chapter in the Ultimate Guide to Linkedin API series, my goal is to get your product integrated with Linkedin API by the end of this guide, without the need to be approved as a Linkedin Partner.

This guide is intended for software engineers with no problems making API calls and will like to short-circuit the business problems that come with Linkedin API and get productive immediately.

Let's get you started with making API requests to Linkedin API right now.

LinkedIn API

LinkedIn is a powerful professional social network. It is a treasure trove of data for professionals and job listings. Data that a recruitment tech startup or a sales automation product will love to integrate into their offering. Linkedin is aware of its data value and turned off public access to their API since 2015. To gain access to the official Linkedin API, you will need to be a Linkedin Partner.

Getting approved as a LinkedIn Partner

The Linkedin Partner Program is open to four segments of businesses, namely

  1. Talent Solutions, for HR tech companies
  2. Marketing Solutions, for marketing automation companies
  3. Sales Navigator Application Development, for startups looking to enhance Linkedin Sales Navigator
  4. LinkedIn Learning Integration, for content companies

I understand that it is a long and laborious process to get a company approved as a LinkedIn Partner. Your best bet is to pick the category that best fits your company's offering and apply to be a LinkedIn Partner.

Most of the cool Linkedin API features also require a paid subscription to LinkedIn Developer Enterprise Products.

Using LinkedIn API without the Linkedin Partner

It makes business sense for Linkedin to be selective in picking partners because why should they give away their data? The chances are that most companies that apply will not be approved as a Linkedin Partner.

Thankfully, you can achieve the same effects of Linkedin API with Proxycurl's Linkedin API. Even better, Proxycurl's Linkedin API has no rate limits, and you can get an API key immediately.

For the rest of this guide, I will provide two code snippets:

  1. One code snippet for Proxycurl's Linkedin API and
  2. the other for the official Linkedin API.

While you are waiting to be approved as Linkedin Partner, do head over to Proxycurl and get yourself a trial API key so you can get started immediately.

Getting started with the LinkedIn Consumer Solutions Platform (CSP)

Most companies will want to start with Linkedin's Consumer Solutions Platform (CSP). When you think of Linkedin, you are thinking of the rich and bountiful profiles. And the CSP is how you can access these juicy profiles.

There are only two features of the CSP that allows you to exfiltrate data out of Linkedin:

  1. Sign in with LinkedIn provides the authentication layer to your product by letting users sign in with their professional Linkedin profile.
  2. Profile API returns structured data of a profile programmatically.

Sign in with LinkedIn

Sign in with LinkedIn is an OAuth provider for your application. Most people assume that if you use Sign in with LinkedIn, LinkedIn will tell you every user's Linkedin profile. It turns out that they do not. What can be returned are:

  1. First/Last name
  2. Email address
  3. Profile Picture

Also, there is a rate limit of 500 requests per day.

In my opinion, Sign in with LinkedIn serves very little utility for most applications because the key data you want to extract is the user's LinkedIn profile and not generic information.

Proxycurl is currently looking into replicating an alternative to Sign in with Linkedin. An alternative that serves similarly as an authentication layer will provide the user's identity in the form of structured data from his or her LinkedIn profile.

In the meantime, do subscribe to our mailing list to send you an update when we have a replacement for Sign in with LinkedIn.

People's Profile API

The Profile API is the meat of this chapter.

To orientate you through the Profile API. We will start with this problem:

Given a profile ID, how can I get structured data of this profile into my application?

Fetching profile data via the official Linkedin Profile API

There are two ways to fetch the data of a profile via the official Linkedin API.

The first method is free and available for most developers. The caveat is that you have to get permission from each profile you wish to extract into your application.

The second method is available only for approved developers on a paid subscription to LinkedIn's Consumer Solution Platform. It allows you to fetch profile data from any profile ID.

Method 1: Seeking permission and getting structured data profile from a user

The first method requires you, the developer, to seek permission from the user that owns the profile. To do that, Linkedin requires you to fetch an access_token via 3-legged OAuth. A fancy term to describe a two-step process to get an access token.

Step 0: Get a CLIENT_ID and CLIENT_SECRET by creating an app over at the Linkedin Developers page. (You can Google the link for this page)

Step 1: To get permission from a user, you will generate an authorization URL to send your user to LinkedIn so he/she can permit your application to download his profile.

In this case, you must provide a REDIRECT_URI, the web page for which Linkedin will send the user back after he/she has finished granting the permission.

def generate_authorization_url():
    """
    Generate an authorization URL for a user to give permission to extract his/her Linkedin Profile.

    The genereated URL will take the user to a Linkedin page for which the user will be asked to give an explicit
    permission to share his profile with you (the application creator).

    Should the user agree, he/she will be redirected to `LINKEDIN_REDIRECT_URI`.
    In the redirect, two fields will appear in the URL parameter, namely `code` and `state`.

    * `state` is generated below using `secrets.token_hex(8).upper()`. This is as a form of identifier for this user.
    * `code` is the authorization_code, and can be used in `get_access_token()` to exchange for an `access_token`.

    """
    LI_AUTH_URL = 'https://www.linkedin.com/oauth/v2/authorization'
    url = requests.Request('GET', LI_AUTH_URL,
                           params={
                               'response_type': 'code',
                               'client_id': LINKEDIN_CLIENT_ID,
                               'redirect_uri': LINKEDIN_REDIRECT_URI,
                               'state': secrets.token_hex(8).upper(),
                               'scope': '%20'.join(['r_liteprofile', 'r_emailaddress', 'w_member_social']),
                           }).prepare().url
    return url

Step 2: You get an authorization code when a user permits you to access his profile. With this code, you will exchange it for an access_token to access this user's profile.

def get_access_token(authorization_code):
    """
    Given a authorization `code`, this function will return you `access_token` which can then be used to access a user's Linkedin profile.
    """
    LI_ACCESS_TOKEN_EXCHANGE_URL = 'https://www.linkedin.com/oauth/v2/accessToken'
    access_token = requests.post(LI_ACCESS_TOKEN_EXCHANGE_URL, params={
        'grant_type': 'authorization_code',
        'code': authorization_code,
        'redirect_uri': LINKEDIN_REDIRECT_URI,
        'client_id': LINKEDIN_CLIENT_ID,
        'client_secret': LINKEDIN_CLIENT_SECRET,
    }).json()['access_token']
    return access_token

Step 3: Fetch this user's profile.

def get_profile(access_token):
    """
    Fetches the profile of a Linkedin user who has given you his permission to view his profile
    """
    LI_PROFILE_API_ENDPOINT = 'https://api.linkedin.com/v2/me'
    r = requests.get(LI_PROFILE_API_ENDPOINT, headers={
                     'Authorization': 'Bearer ' + access_token})
    return r.json()

The working Python code for this method can be found on in our linkedin-api-python3-examples Github repository.

Method 2: Querying a profile from any profile ID

The second method does not require you to seek permission from the user. But your application must be approved to use the People's Profile API endpoint with a 2-legged OAuth

Step 0: In your pre-approved Linkedin App, get the CLIENT_ID and CLIENT_SECRET fields.

Step 1: Using your application's CLIENT_ID and CLIENT_SECRET, exchange for access_token.

def get_access_token():
    """
    If you are

    1. an approved Linkedin developer
    2. on a paid subscription to their Consumer Product

    You can use this function to fetch an `access_token` to access the API.
    """
    LI_ACCESS_TOKEN_EXCHANGE_URL = 'https://www.linkedin.com/oauth/v2/accessToken'
    access_token = requests.post(LI_ACCESS_TOKEN_EXCHANGE_URL, params={
        'grant_type': 'client_credentials',
        'client_id': LINKEDIN_CLIENT_ID,
        'client_secret': LINKEDIN_CLIENT_SECRET,
    }).json()['access_token']
    return access_token

Step 2: Fetch any profile with profile_id

def get_profile(access_token, profile_id):
    """
    Given an `access_token`, fetch structured data of any profile.
    """
    LI_PROFILE_API_ENDPOINT = f'https://api.linkedin.com/v2/people/{profile_id}'
    r = requests.get(LI_PROFILE_API_ENDPOINT, headers={
                     'Authorization': 'Bearer ' + access_token,
                     'X-RestLi-Protocol-Version': '2.0.0'})
    return r.json()

The working Python code for this method can be found in our linkedin-api-python3-examples Github repository.

Fetching profile data via Proxycurl's Linkedin Profile API Endpoint

It is bothersome jumping through the hoops for Linkedin's API. For the rest of us, there is Proxycurl, which provides their Linkedin API insofar that you can get everything that LinkedIn's official Profile API offers, and a whole lot more. Check out Proxycurl's Profile API documentation to see what data fields are supported.

There is just one method to get profile data from any profile ID.

Step 0: Get a Proxycurl API key by signing into Proxycurl with your work email address here. https://nubela.co/proxycurl/login

Step 1: Query the Profile API endpoint with profile_id

import requests

PROXYCURL_API_KEY = ''  # todo - fill this field up


def get_profile(profile_id):
    api_endpoint = 'https://nubela.co/proxycurl/api/v2/linkedin'
    header_dic = {'Authorization': 'Bearer ' + PROXYCURL_API_KEY}
    params = {
        'url': f'https://www.linkedin.com/in/{profile_id}',
    }
    response = requests.get(api_endpoint,
                            params=params,
                            headers=header_dic)
    return response.json()

The working Python code for this method can be found in our linkedin-api-python3-examples Github repository.

Summarizing the state of Linkedin Profile API

LinkedIn has made it extremely difficult for developers to integrate Linkedin Profile export into their system. The Profile API that is free and requires little approval is throttled with rate limits and explicit and cumbersome per-user permission granting. The Profile API with 2-legged OAuth that lets you query any profile ID requires explicit approvals and a hefty amount of money to be paid via a LinkedIn subscription.

Proxycurl offers an unbridled equivalent to Linkedin's Profile API. The key difference lies in latency. Proxycurl's People Profile API Endpoint performs a live scrape of a profile on each API call, so each call might take a few seconds to complete. To overcome throughput, a developer can launch requests to Proxycurl's API in parallel.

Do you know that when a user signs in with LinkedIn, the application developer does not get the user's Linkedin profile? In the next update, we will discuss the Sign in with Linkedin feature and how you might use Proxycurl's equivalent solution to sign in with Linkedin and get the user's Linkedin profile back.

I want to tell you when I post my next follow-up article to Linkedin API. Click here to subscribe to our mailing list so I can ping you when it is ready!