In this tutorial, you will learn how to connect the Linkedin API to Google Sheets in 7 steps:
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.
Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new
In your developer account, click the My Apps menu item, then click the +Create app button:
Complete all the required fields, such as App name, LinkedIn page and App logo:
Check the terms agreement checkbox and then click the Create app button:
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:
Check the terms and conditions box, then click the Request access button:
You’ll see a confirmation message at the bottom left corner and the product is added to your app:
We will repeat the same steps for the Sign in with LinkedIn product:
Click the Auth tab to find the Client ID and the Client Secret:
Copy and paste your Client ID and Client Secret to a safe location, because you’ll need them in the next steps.
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
Next, you will be asked for a list of required permission and you will have to click the Allow button:
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:
Note: This code is only valid for 20 seconds. Make sure you follow Step 4.) below, to exchange the token, within these 20 seconds.
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:
You should receive a response containing an access token, make sure to copy it and save it in a safe place.
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):
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:
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:
All endpoints should be appended to this base URL: https://api.linkedin.com/v2/
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.
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.
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.
Crypto API Tutorials: