IN.API.Connections()

JavaScript SDK

At present, you are only permitted to retrieve connections data for the currently signed-in member. A .ids() method exists, but is redundant in this SDK.

JavaScript
IN.API.Connections("me")
    .fields(fields)
    .result(resultCallback)

IN.API.Connections.ids("me")
    .fields([field1, field2])
    .params({param1:value, param2:value})
    .result(resultCallback)

IN.API.Connections("me")
    .fields([field1, field2])
    .result(resultCallback)
  • default ids() - Array {String}, Argument List {String}
    Can only be called with the parameter "me".
  • fields() (optional) - Array {String}, Argument List {String}
    Specifies the profile fields to retrieve. If not specified, the default fields will be the server supplied defaults, subject to change.  See Profile Fields for information about supported fields.
  • params() (optional) Object with parameters to pass to the backend call.  See the Connections API documentation for information about supported parameters.

Basic Example

JavaScript
IN.API.Connections("me")
    .result(doMyThing)

This is the most basic call. Get the connections for the currently signed-in member and send the results to the doMyThing() function for processing.

No fields are included, so the results include the standard fields (currently headline, id, firstName, lastName,, location, siteStandardProfileRequest, apiStandardProfileRequest, pictureUrl, url, industry). An example result would then a Javascript object which is a list of person objects.  An example of the person object looks like this:

Sample response
{  
   "headline":"President of the United States",
   "id":"NhZXBl_O6f",
   "lastName":"Obama",
 "pictureUrl":"http://media.linkedin.com/mpr/mprx/0_fsPnURNRhLhk_Ue2fjKLUZkB2FL6TOe2S4bdUZz61GA9Ysxu_y_sz4THGW5JGJWhaMleN0F61-Dg",
   "location":{
       "name":"Washington, DC","country":{"code":"us"}
   },
   "siteStandardProfileRequest":{
      "url":"http://www.linkedin.com/profile?viewProfile=&key=11554268&authToken=3KMh&authType=name&trk=api*a124520*s132954*"
   },
   "apiStandardProfileRequest":{
      "headers":{
         "values":[{
            "name":"x-li-auth-token",
            "value":"name:3KMh"}
         ],"_total":1},
      "url":"http://api.linkedin.com/v1/people/NhZXBl_O6f"
    },
    "industry":"Executive Branch",
    "firstName":"Barack"
}

More Specific Fields

The Connections call supports a .fields() method which allows you to specify which fields you want returned, instead of just getting the default fields. To see the fields available for the Connections resource, refer to the Connections API documentation.  Additionally, each connection object can have one or more people associated with it, and you can select which fields you want for those people. To understand what fields are available for each person, see the Profile Fields documentation, as well as the Field Selector information to understand how to express your request correctly.

JavaScript
IN.API.Connections("me")
    .fields("headline","first-name")
    .result(function(result) { 
        alert JSON.stringify(result)) 
    }

In this example we're asking for two specific fields.  Once you start specifying Profile Fields, your return is limited to just the fields you have asked for.  The defaults are overriden entirely.  In addition, instead of calling a separate function, an inline function has been created for the results.  The results for this case would be much smaller, and the results would be shown in an alert window to the user.

Sample response
{  
   "headline":"President of the United States",
   "firstName":"Barack"
}

Adding Parameters

The Connections method also supports the use of a .params() field to send parameters to the server along with the call.  You can see which parameters are meaningful for this resource in the REST documentation for the Connections API.

JavaScript
IN.API.Connections("me")
      .params({"count":1})
      .result(function(result) { alert JSON.stringify(result))

In this case, the result is similar to the first example, but the results have been limited to a count of 1.