/ profile api

The Ultimate Guide to the Professional Social Network API: People Profile API (with Python Example)

In this first chapter of the "Ultimate Guide to the Professional Social Network API" series, my goal is to get your product integrated with Professional Social Network API without the need to be approved as a Professional Social Network Partner.

This guide is intended for software engineers comfortable making API calls who would like to short-circuit the business problems that come with the official Professional Social Network API and to get productive immediately.

What Professional Social Network APIs exist?

Professional Social Network is a powerful professional social network. It's a treasure trove of data for professionals and job listings, data that a recruitment tech startup or a sales automation product would love to integrate into their offering. Professional Social Network is aware of this value and have turned off public access to their API since 2015. To gain access to the official Professional Social Network API, you would need to be a Professional Social Network Partner.

Getting approved as a Professional Social Network Partner

The Professional Social Network 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 Professional Social Network Sales Navigator
  4. Professional Social Network Learning Integration, for content companies

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

Most of the cool Professional Social Network API features also require a paid subscription to Professional Social Network Developer Enterprise Products.

Using an unofficial Professional Social Network API without being a Professional Social Network Partner

It makes business sense for Professional Social Network 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 Professional Social Network Partner.

Thankfully, you can achieve the same effects of Professional Social Network API with Proxycurl's Professional Social Network API. Even better, Proxycurl's Professional Social Network API has a generous rate limit of 300 requests per minute, and you can get an API key immediately.

In the rest of this guide, we will go over two code examples:

  1. One with the official Professional Social Network API.
  2. One using Proxycurl's Professional Social Network API, designed for developers in your situation.

While you are waiting to be approved (or not) as Professional Social Network Partner, do head over to Proxycurl and get yourself a trial API key so you can get started immediately.

Get Started With Professional Social Network Consumer Solutions Platform (CSP)

Most companies will want to start with Professional Social Network's Consumer Solutions Platform (CSP). When you think of Professional Social Network, 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 allow you to exfiltrate data out of Professional Social Network:

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

Sign In with Professional Social Network

Sign In with Professional Social Network is an OAuth provider for your application. Most people assume that if you use Sign In with Professional Social Network, Professional Social Network will tell you every user's Professional Social Network 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 Professional Social Network serves very little utility for most applications because the key data you want to extract is the user's Professional Social Network profile and not generic information.

Proxycurl is currently looking into replicating an alternative to Sign In with Professional Social Network. An alternative that serves similarly as an authentication layer will provide the user's identity in the form of structured data from their Professional Social Network profile.

In the meantime, do subscribe to our mailing list so we can send you an update when we have a replacement for Sign In with Professional Social Network.

People API

The People API is the meat of this chapter.

To orient you to the People API, we will start with this problem:

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

Fetch profile data via the official Professional Social Network Profile API

There are two ways to fetch the data of a profile via the official Professional Social Network API:

  1. 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.
  2. The second method is available only for approved developers on a paid subscription to Professional Social Network's Consumer Solution Platform. It allows you to fetch profile data from any profile ID.

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, Professional Social Network 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 at the Professional Social Network 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 Professional Social Network so they can permit your application to download their profile.

In this case, you must provide a REDIRECT_URI, the web page for which Professional Social Network will send the user back after they have finished granting the permission.

def generate_authorization_url():
    """
    Generate an authorization URL for a user to give permission to extract their Professional Social Network Profile.

    The genereated URL will take the user to a Professional Social Network page where the user will be asked to give explicit
    permission to share their profile with you (the application creator).

    Should the user agree, they will be redirected to `Professional Social Network_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.professionalsocialnetwork.com/oauth/v2/authorization'
    url = requests.Request('GET', LI_AUTH_URL,
                           params={
                               'response_type': 'code',
                               'client_id': Professional Social Network_CLIENT_ID,
                               'redirect_uri': Professional Social Network_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 their profile. With this code, you will exchange it for an access_token to access the 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 Professional Social Network profile.
    """
    LI_ACCESS_TOKEN_EXCHANGE_URL = 'https://www.professionalsocialnetwork.com/oauth/v2/accessToken'
    access_token = requests.post(LI_ACCESS_TOKEN_EXCHANGE_URL, params={
        'grant_type': 'authorization_code',
        'code': authorization_code,
        'redirect_uri': Professional Social Network_REDIRECT_URI,
        'client_id': Professional Social Network_CLIENT_ID,
        'client_secret': Professional Social Network_CLIENT_SECRET,
    }).json()['access_token']
    return access_token

Step 3: Fetch the user's profile.

def get_profile(access_token):
    """
    Fetches the profile of a Professional Social Network user who has given you their permission to view their profile
    """
    LI_PROFILE_API_ENDPOINT = 'https://api.professionalsocialnetwork.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 Professional Social Network-api-python3-examples GitHub repository.

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 Professional Social Network 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 Professional Social Network 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.professionalsocialnetwork.com/oauth/v2/accessToken'
    access_token = requests.post(LI_ACCESS_TOKEN_EXCHANGE_URL, params={
        'grant_type': 'client_credentials',
        'client_id': Professional Social Network_CLIENT_ID,
        'client_secret': Professional Social Network_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.professionalsocialnetwork.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 Professional Social Network-api-python3-examples GitHub repository.

Fetch profile data via Proxycurl's Professional Social Network Profile API Endpoint

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

There's 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.

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/Professional Social Network'
    header_dic = {'Authorization': 'Bearer ' + PROXYCURL_API_KEY}
    params = {
        'url': f'https://www.professionalsocialnetwork.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 Professional Social Network-api-python3-examples Github repository.

Summarizing the state of the Professional Social Network Profile API

Professional Social Network has made it extremely difficult for developers to integrate Professional Social Network 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 Professional Social Network subscription.

Proxycurl offers an unbridled equivalent to Professional Social Network'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.

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

I want to tell you when I post my next follow-up article to Professional Social Network API. Subscribe to our mailing list so I can ping you when it is ready!

Steven Goh | CEO
Share:

Subscribe to our newsletter

Get the latest news from Proxycurl

Featured Articles

Here’s what we’ve been up to recently.