Quick Start Guide

After going through this quick start guide, you'll know how to register your application on LinkedIn and make an authenticated API call to retrieve your own profile.

Register Your Application

Register your application with LinkedIn on our developer portal to receive an API key. This key helps us identify your application and lets you make an API call. Once you've registered your LinkedIn app, a developer token and secret is provided to you along with your API key. To simplify things we give you the credentials necessary to make an API call.

Please ensure to keep the user access tokens and secret secure, as agreed upon in our APIs Terms of Use.

Retrieve Your Own LinkedIn Profile

Below is a simple example of how to retrieve your own LinkedIn profile using the Profile API. Be sure to replace the API and developer credentials with the ones you received after registering your application:

require 'oauth'

# Fill the keys and secrets you retrieved after registering your app
api_key = 'abcd123456'
api_secret = 'efgh987654'
user_token = 'abcd1234-efgh987-9988'
user_secret = '9876abcd-123asdf-1122'

# Specify LinkedIn API endpoint
configuration = { :site => 'https://api.linkedin.com' }

# Use your API key and secret to instantiate consumer object
consumer = OAuth::Consumer.new(api_key, api_secret, configuration)

# Use your developer token and secret to instantiate access token object
access_token = OAuth::AccessToken.new(consumer, user_token, user_secret)

# Make call to LinkedIn to retrieve your own profile
response = access_token.get("http://api.linkedin.com/v1/people/~")

# By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply specify the format in your call
# response = access_token.get("http://api.linkedin.com/v1/people/~?format=json")
import oauth2 as oauth
import httplib2
import time, os, simplejson

# Fill the keys and secrets you retrieved after registering your app
consumer_key      =   'abcd123456'
consumer_secret  =   'efgh987654'
user_token           =   'abcd1234-efgh987-9988'
user_secret          =   '9876abcd-123asdf-1122'

# Use your API key and secret to instantiate consumer object
consumer = oauth.Consumer(consumer_key, consumer_secret)

# Use the consumer object to initialize the client object
client = oauth.Client(consumer)

# Use your developer token and secret to instantiate access token object
access_token = oauth.Token(
			key=user_token,
			secret=user_secret)

client = oauth.Client(consumer, access_token)

# Make call to LinkedIn to retrieve your own profile
resp,content = client.request("http://api.linkedin.com/v1/people/~", "GET", "")

# By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply specify the format in your call
# resp,content = client.request("http://api.linkedin.com/v1/people/~?format=json", "GET", "")
// Fill the keys and secrets you retrieved after registering your app
$oauth = new OAuth("abcd123456", "efgh987654");
$oauth->setToken("abcd1234-efgh987-9988", "9876abcd-123asdf-1122");

$params = array();
$headers = array();
$method = OAUTH_HTTP_METHOD_GET;
 
// Specify LinkedIn API endpoint to retrieve your own profile
$url = "http://api.linkedin.com/v1/people/~";

// By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply specify the format in your call
// $url = "http://api.linkedin.com/v1/people/~?format=json";

// Make call to LinkedIn to retrieve your own profile
$oauth->fetch($url, $params, $method, $headers);
 
echo $oauth->getLastResponse();

And the response of your call:

<person>
  <first-name>Kamyar</first-name>
  <last-name>Mohager</last-name>
  <headline>Senior Partner Engineer at LinkedIn</headline>
  <site-standard-profile-request>
    <url>http://www.linkedin.com/profile?viewProfile=&key=8219502&authToken=SqI1&authType=name&trk=api*a108281*s116823*</url>
  </site-standard-profile-request>
</person>
{
  "firstName": "Kamyar",
  "headline": "Senior Partner Engineer at LinkedIn",
  "lastName": "Mohager",
  "siteStandardProfileRequest":  {
    "url": "http://www.linkedin.com/profile?viewProfile=&key=8219502&authToken=SqI1&authType=name&trk=api*a108281*s116823*"
  }
}

With a few lines of code you've made your first LinkedIn API call! As much fun as that was, you probably want to develop your application so that any LinkedIn user can be authenticated and use your app. Going through the Authentication section will give you the knowledge to do just that.