Pearson
Always Learning

API Group: 

This API returns a list of all the users that are enrolled in any of the same courses as the specified user. This was designed for social features allowing students to see who they share classes with (and which courses they share), or to find all their classmates from a single location.

Best Practice: Try to cache these results. Once courses are well underway a user's list of classmates will change very little, if at all (especially after the first couple of weeks). And because this API spans all courses by default, it can be slower to return unless filters are used (see below).

Caution: If the institution enrolls students in large orientation courses (hundreds or thousands of users), and those courses are not in a "Special" term type, this API can unintentionally act very slowly.



Supported Roles and Authentication Protocols

Type Supported Values
Authentication Protocols OAuth 1.0a, OAuth 2.0
Valid for Roles (OAuth 2): Professor, Teaching Assistant, Student, Administrator

API Request

API Endpoints

HTTP Verbs and URIs

GET /users/{userId}/classmates{.format}
  • Retrieves an array of user information for users enrolled in the same courses as the specified user.
GET /users/{userId}/classmates/{classmateId}{.format}
  • Retrieves an array of user information for the specified classmate of the specified user.

Parameters

Parameter Description Valid Values
{userId} LearningStudio User ID or relevant user overload.
  • Numeric ID issued by LearningStudio
  • loginid={clientString}|{username}
  • or replace /users/{userId} with /me
    (OAuth 2 only)
{classmateId} LearningStudio User ID. Numeric ID issued by LearningStudio.
{.format} Desired format of response data. See Response Formats. .json , .xml , or Blank

Query String Parameters

Query Parameter Name Description Valid Values
courseId By default the API will return the classmates from all courses a user is enrolled in, which can cause the API to be slower in response. Use this parameter to filter to a specific course. Numeric ID issued by LearningStudio
includeAllTerms By default the API will only return classmates from current terms & courses. This parameter allows you to include classmates from all LearningStudio courses the user has ever been enrolled in. Note that this may return users that are no longer active or enrolled at the institution. true , false , or Blank (defaults to False)

Request Body

None

API Response

Response Header

This API returns the standard HTTP Status Codes used by the LearningStudio APIs. There are no special headers returned by the API.

Response Body

Format

{
"classmates":[{
  "id":"{userId}",
  "personaId":"{userPersonaId}",
  "firstName":"{userFirstName}",
  "lastName":"{userLastName}",
  "sharedCourses":[{
    "course":{
      "id":"{courseId}",
      "displayCourseCode":"{displayCourseCode}",
      "title":"{courseTitle}",
      "role":{
        "id":"{roleId}",
        "type":"{roleType}",
        "name":"{roleName"}"
      }
    },{
    "course":{
      "id":"{courseId}",
      "displayCourseCode":"{displayCourseCode}",
      "title":"{courseTitle}",
      "role":{
        "id":"{roleId}",
        "type":"{roleType}",
        "name":"{roleName"}"
      }
    }
    }]
  },{
  "id":"{userId}",
  "personaId":"{userPersonaId}",
  "firstName":"{userFirstName}",
  "lastName":"{userLastName}",
  "sharedCourses":[{
    "course":{
      "id":"{courseId}",
      "displayCourseCode":"{displayCourseCode}",
      "title":"{courseTitle}",
      "role":{
        "id":"{roleId}",
        "type":"{roleType}",
        "name":"{roleName"}"
      }
    }
  }]
  }
}]}

Property Descriptions

Name Description Valid Values
{userId} LearningStudio user ID.
{userPersonaId} Alias or persona ID for the user that is displayed in the UI or social sites.
{userFirstName} First name of user.
{userLastName} Last name of user.
{courseId} LearningStudio course ID of the shared course.
{displayCourseCode} The vernacular course code for the course, such as MATH-101. This is determined by the institution and may be repeated between many courses.
{courseTitle} Title of the shared course.
{roleId} ID of the role for the user in the course. Note: The same user may have different roles for each enrolled course. For example, a user may be a Student in one course and a Teaching Assistant in another course.
{roleType} Type of the role.
  • PROF - Professor.
  • TAST - Teaching Assistant.
  • STUD - Student.
{roleName} Name of the role as defined by the Educational Partner.

Examples

Request

Endpoint

GET /users/12345/classmates

or

GET /me/classmates

Response

Body

{
"classmates":[{
  "id":"2120785",
  "personaId":"super_prof1",
  "firstName":"John",
  "lastName":"Smith",
  "sharedCourses":[{
    "course":{
      "id":"2026759",
      "displayCourseCode":"SELA1A1",
      "title":"Calculus 101",
      "role":{
        "id":"1",
        "type":"PROF",
        "name":"CIU Professor"
      }
    },{
    "course":{
      "id":"2026760",
      "displayCourseCode":"SELA1A2",
      "title":"Calculus 102",
      "role":{
        "id":"1",
        "type":"PROF",
        "name":"CIU Professor"
      }
    }
    }]
  },{
  "id":"2120788",
  "personaId":"Jane_J",
  "firstName":"Jane",
  "lastName":"Jones",
  "sharedCourses":[{
    "course":{
      "id":"2026759",
      "displayCourseCode":"SELA1A1",
      "title":"Calculus 101",
      "role":{
        "id":"2",
        "type":"STUD",
        "name":"CIU Student"
      }
    },{
    "course":{
      "id":"2026760",
      "displayCourseCode":"SELA1A2",
      "title":"Calculus 102",
      "role":{
        "id":"2",
        "type":"STUD",
        "name":"CIU Student"
      }
    }
    }]
  }
  },{
  "id":"2120791",
  "personaId":"Sam_S",
  "firstName":"Sam",
  "lastName":"Spade",
  "sharedCourses":{
    "course":{
      "id":"2026759",
      "displayCourseCode":"SELA1A1",
      "title":"Calculus 101",
      "role":{
        "id":"9",
        "type":"TAST",
        "name":"CIU Teaching Assistant"
      }
    }}
  }
  }
]}
3620 reads
Always Learning
Pearson