In this tutorial, you will learn how to connect the Linkedin API to Google Sheets in 7 steps:

  1. Install the Apipheny Add-on
  2. Create a Linkedin API App
  3. Obtain a Linkedin authorization code
  4. Generate a Linkedin API Access Token
  5. Choose a LinkedIn API Endpoint URL
  6. Enter the LinkedIn API Request into the Apipheny add-on
  7. Run the Linkedin API request

Step 1.) Install and open the Apipheny add-on for Google Sheets

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install

2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.

In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Create a Linkedin App

In your developer account, click the My Apps menu item, then click the +Create app button:

Creating a LinkedIn app
Creating a LinkedIn app

Complete all the required fields, such as App name, LinkedIn page and App logo:

Entering LinkedIn app details
Entering LinkedIn app details

Check the terms agreement checkbox and then click the Create app button:

Click the create app button to create the LinkedIn app
Click the create app button to create the LinkedIn app

Your app will then be created and the Products tab will be displayed. Click the Request access button corresponding to the Share on LinkedIn product:

Products tab
Products tab

Check the terms and conditions box, then click the Request access button:

Request access pop-up
Request access pop-up

You’ll see a confirmation message at the bottom left corner and the product is added to your app:

Confirmation message
Confirmation message

We will repeat the same steps for the Sign in with LinkedIn product:

Products tab
Products tab
Request access pop-up
Request access pop-up
Confirmation message
Confirmation message

Click the Auth tab to find the Client ID and the Client Secret:

LinkedIn Client ID and Client Secret
LinkedIn Client ID and Client Secret

Copy and paste your Client ID and Client Secret to a safe location, because you’ll need them in the next steps.

Step 3.) Obtain a Linkedin authorization code

To get your Linkedin authorization code, copy the following link, then go to your browser’s address bar, paste it, and press Enter:

https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=your_client_id&redirect_uri=your_redirect_uri&state=abcd&scope=r_liteprofile%20r_emailaddress%20w_member_social
  • Replace your_client_id with the client id value that you obtained in the previous step
  • Replace your_redirect_uri with any valid URI string (you can use https://www.apipheny.io/ as your redirect uri, for example)

Next, you will be asked for a list of required permission and you will have to click the Allow button:

Enabling permissions for LinkedIn app
Enabling permissions for LinkedIn app

After you allow access to the app, your code will be displayed in the address bar, as a value for the code parameter of your API URL:

LinkedIn API app code
LinkedIn API app code

Note: This code is only valid for 20 seconds. Make sure you follow Step 4.) below, to exchange the token, within these 20 seconds.

Step 4.) Generate a Linkedin API Access Token

To generate a Linkedin API access token, you’ll need to issue an HTTP POST request to the accessToken endpoint, with both your Client ID and Client Secret values.

Open up a terminal window and compose the following curl command:

curl -X POST https://www.linkedin.com/oauth/v2/accessToken \\
-d "grant_type=authorization_code&code=CODE&redirect_uri=REDIRECT_URI&
client_id=CLIENT_ID&client_secret=CLIENT_SECRET"  \\
-H "Content-Type: application/x-www-form-urlencoded"

You’ll need to replace 4 of the values in this command:

  • CLIENT_ID – This should be the client ID you obtained earlier, after creating your developer application
  • CLIENT_SECRET – This should be the application secret you obtained earlier, also after creating your developer application
  • CODE – This should be the value of the code query parameter from the previous step
  • REDIRECT_URI – This should be the redirect URI that you entered while creating your developer application
Obtaining LinkedIn API access token
Obtaining LinkedIn API access token

You should receive a response containing an access token, make sure to copy it and save it in a safe place.

Step 5.) Choose a LinkedIn API endpoint

In this section, I’ll show you how to browse the LinkedIn API documentation to find an API endpoint URL that retrieves the specific information you need from your LinkedIn account.

If you already know your API URL, or you want to use the same example URL as us, just skip to Step 6.

First, open the LinkedIn API documentation page: https://learn.microsoft.com/en-us/linkedin/

The menu on the left contains a list of available API solutions (Compliance, Consumer, Learning, Marketing, Sales, and Talent):

LinkedIn API Documentation
LinkedIn API Documentation

Clicking one of the available Linkedin APIs (e.g Compliance) will open a dedicated page, with more details about the concepts and operations provided by that solution.

These are organized using a menu on the left of the page, from which you can access more information about Development, Integrations or API References.

For instance, in the Compliance Snapshot API solution’s Integrations section, you’ll find a list of concepts used by this API:

LinkedIn API endpoints
LinkedIn API endpoints

An example Compliance integration concept is People Guide. This concept’s menu lists multiple supported objects and operations, grouped under Profile API, Find Profile by VanityName API, Profile Edit API, Primary Contact API, Connections API, Member Rich Content API.

The Connections API menu item, in the People Guide group, lists multiple supported operation endpoints. One of them is Total Number of Connections, which allows the user to identify and retrieve a Member’s total number of 1st-degree connections is returned along with the paging response:

https://api.linkedin.com/v2/connections?q=viewer&projection=(paging)

The documentation for this endpoint contains a short description of the endpoint’s purpose, the HTTP method and URL, a table of the accepted parameters, as well as a sample request and its associated sample response:

LinkedIn API "Total Number of Connections" endpoint documentation
LinkedIn API “Total Number of Connections” endpoint documentation

All endpoints should be appended to this base URL: https://api.linkedin.com/v2/

Step 6.) Enter your LinkedIn API Request into the Apipheny add-on

Okay, we’re in the home stretch. Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import Tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) as required by your LinkedIn API endpoint. For this example, we are using the GET method.

API URL: In Step 5, I explained how you can find the LinkedIn API endpoint that you need. Now copy the complete API URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.

For this example, we are using the “Me” endpoint, that gets information about the current user’s account. The corresponding URL for this endpoint is:

https://api.linkedin.com/v2/me

In the Headers section of the Apipheny add-on panel, add one row, with the following key and value:

Header
Key:
Authorization
Value:
Bearer your_token

Replace your_token with the value of the token you obtained previously, in Step 4. There should be a literal space between Bearer and your_token.

LinkedIn API request entered into the Apipheny add-on
LinkedIn API request entered into the Apipheny add-on

Step 7.) Run the LinkedIn API Request in your Google Sheets

The last step is to click the Run button at the bottom of the Apipheny add-on and then your LinkedIn data will be imported into your Google Sheet.

LinkedIn API data imported into Google Sheets using the Apipheny add-on
LinkedIn API data imported into Google Sheets using the Apipheny add-on

After making a successful request to the LinkedIn API, try querying a different LinkedIn API endpoint, or try using one of the more advanced features in the Apipheny add-on.

Import API data into Google Sheets tutorial

Crypto API Tutorials:


API Tutorials


API Knowledge

What is an API?

What is an API URL?

What are parameters?

What is an endpoint?

What is an API key/token?

What is basic authentication?

What are headers?

What is a GET request?

What is a POST request?