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:

Linkedin app successfully created
Linkedin app successfully created

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://docs.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 Marketing) 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 Marketing solution’s Integrations section, you’ll find a list of concepts used by this API:

Linkedin API endpoints
Linkedin API endpoints

An example Marketing integration concept is Ads. This concept’s menu lists multiple supported objects and operations, grouped under Account Structure and Advertising & Targeting.

The Ad Accounts menu item, in the Account Structure group, lists multiple supported operation endpoints. One of them is Search for Accounts, which allows the user to search for accounts by multiple criteria, such as their IDs, names, references, types and statuses:

https://api.linkedin.com/v2/adAccountsV2?q=search&search.{searchCriteria}.values[0]={searchValue}

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 "Search for Accounts" endpoint documentation
Linkedin API “Search for Accounts” endpoint documentation

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 and more:


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?