Skillhive Developers

User Relationships

Get user relationship data through the Skillhive API

List all user relationships in Skillhive

Endpoint: /api/v2/user-relationships

Method Action Parameters
GET List user relationships
  • offset: int fetch profiles starting from (optional, default: 0)
  • limit: int how many profiles to get (optional, default: 20, limit 0-50)
  • user: int userId for the user whose relationiships you want to list
  • target: int userId for the user who is the target of the relationship
  • relationship: string list only relationships of this type, e.g. subordinate

An example of a return response:

{
  "data": [ // The returned user relationship collection
    { // A relationship object
      "type": "user-relationships",
      "id": "12345",      // The user relationship id
      "attributes": {
        "relationship": "subordinate",
        "created-at": "Wed, 21 May 2014 10:11:24 +0300",
        "updated-at": "Tue, 03 Jun 2014 12:28:56 +0300"          
      },
      "relationships": {
        "target": {
          "data": {
            "type": "users",
            "id": "9876" // This is the user Id of the "target" of the relationship
          }
        }
      }
    },
    ... // More user relationships
  ],
  "meta": {
    "total-count": 5 // Number of user relationships.
  }
}

Delete a single user relationship

Endpoint: /api/v2/user-relationships/:user_relationship_id

Method Action Parameters
DELETE Delete the relationship defined by user_relationship_id N/A

Create a new user relationship

Endpoint: /api/v2/user-relationships

Method Action Parameters
POST Create user relationship

You can add new user relationships to Skillhive by doing a POST request to the api endpoint. Here's an example, to create a subordinate relationship between two users. In this example user 9876 is the supervisor of user 1234.

{
  "data": {
    "type": "user-relationships",
    "attributes": {
      "relationship": "subordinate",
    },
    "relationships": {
      "user": {
        "data": {          // This is the user ID of the "owner" of the
          "type": "users", // relationship. In this example this is the subordinate.
          "id": "1234"     // This is usually the loggedin user whos is creating
        }                  // the relationship.
      },
      "target": {
        "data": {
          "type": "users", // This is the user ID of the "target" of the
          "id": "9876"     // relationship. In this example this is the supervisor.
        }
      }
    }
  }
}

The API endpoint will return a 201 Created response with all the data for the newly created relationsip. If a non-admin user tries to create new relationship for someone else, they will get a 403 Forbidden response instead.