LinkedIn API

From Q
Jump to navigation Jump to search
This page is currently under construction, or it refers to features which are under development and not yet available for use.
This page is under construction. Its contents are only visible to developers!

Overview of the LinkedIn API

This page explains how to use R with LinkedIn API's to extract information and insights from LinkedIn accounts, including XXX and more. The data obtained using the LinkedIn API can be used to create analysis and charting to track your social activity as well as mining content from public pages.

The basic process required to access and utilize the LinkedIn API is:

  1. Generate OAuth token.
  2. Create an R output to call Twitter APIs which will generate the dataframes used in the analysis.
  3. Create charts and analysis in Q.

App Setup and Configuration

A LinkedIn app must be setup to generate an Access Token and Access Token Secret which are needed to generate the authentication token used for the API calls.


Required R Packages

The XXX packages must first be installed and can be acquired from the CRAN site or from GitHub.

Authentication token

To use direct authentication, enter the following R code and insert the required values from your app dashboard (Keys and Tokens tab) to store your authentication parameters"

Run the authorization script passing your token parameters to the OAuth API:

LinkedIn API Calls

For a full list of the LinkedIn package API's, visit the [1] page.

Search API

The Search API is used to search Twitter based on a supplied search string.

An R list is returned with the search results which can then be converted into an R dataframe.


API 2

LinkedIn data is extracted using the the userTimeline API.

The following R data frame containing the details is returned.


API 3

The resulting R data frame is returned.


Using LinkedIn API with Q

Creating an R output

To create an R Output in Q, select Create > R Output. Enter the following R code to generate a data frame using the API. Note that the consumer_key, consumer_secret, access_token and access_secret values are stored in separate R Outputs so that they can be referenced by all other R Outputs.


The following data frame is generated in Q.


Data manipulation

The data can be aggregated by the date field to generate a new data frame that can be charted to display the number of Tweets made each day. The following code will



Charting

Using the R plotly package, a column chart of the aggregated data can be generated in Q to view the number of Tweets made per day on the @realDonaldTrump Twitter account.

library(plotly)

plot_ly(
  y = aggdata$x,
  x = aggdata$Group.1,
  type = 'bar',
  name = 'Link'
)%>%

layout(title = "Daily Views",
         xaxis = list(title = ""),
         yaxis = list(title = "# of Tweets"),
         annotations = list(x = aggdata$Group.1, 
                            y = aggdata$x, 
                            text = "",
                            xanchor = 'center', 
                            yanchor = 'bottom', 
                            showarrow = FALSE)
    )



API Limits

Rate Limits

LinkedIn imposes API rate limiting on a per-user (per access token) basis and are divided into 15 minute intervals.

  • Application-only authentication rate limit: 15 calls per 15 minutes window
  • Search API rate limit: 180 calls per 15-minute window

More details regarding LinkedIn API rate limiting can be found on the LinkedIn API Rate Limiting page.

Displayr and Q (R Server) Limits

When making API calls from within Q or Displayr, the R server has a timeout limit of approximately 2 minutes. Under normal circumstances, the Twitter API will return approximately 1500 records within this timeframe. The number of records that will be returned will vary depending on the type of API call being made (for example, searching Twitter versus querying Tweet data from a specific user). Therefore, it is generally good practice to split larger data sets into multiple API calls so as to work within the R server timeout limits.

See also