Skip to content

Function: getRelationship()

ts
function getRelationship(client, parameters): Promise<{
[key: string]: unknown;
  _expandable?: {
   [key: string]: unknown;
     relationData?: string;
     source?: string;
     target?: string;
  };
  _links: {
   [key: string]: unknown;
     base?: string;
     byOperation?: string;
     collection?: string;
     context?: string;
     download?: string;
     editui?: string;
     edituiv2?: string;
     next?: string;
     prev?: string;
     self?: string;
     tinyui?: string;
     webui?: string;
  };
  name: string;
  relationData?: {
   [key: string]: unknown;
     createdBy?: User;
     createdDate?: Date;
     friendlyCreatedDate?: string;
  };
  source?:   | User
     | Content
     | Space;
  target?:   | User
     | Content
     | Space;
}>;

Defined in: src/v1/api/relation.ts:49

Find whether a particular type of relationship exists from a source entity to a target entity. Note, relationships are one way.

For example, you can use this method to find whether the current user has selected a particular page as a favorite (i.e. 'save for later'): GET /wiki/rest/api/relation/favourite/from/user/current/to/content/123

Permissions required: Permission to view both the target entity and source entity.

Parameters

ParameterTypeDescription
clientClient-
parameters{ expand?: ("source" | "target" | "relationData")[]; relationName: string; sourceKey: string; sourceStatus?: string; sourceType: "content" | "user" | "space"; sourceVersion?: number; targetKey: string; targetStatus?: string; targetType: "content" | "user" | "space"; targetVersion?: number; }-
parameters.expand?("source" | "target" | "relationData")[]A multi-value parameter indicating which properties of the response object to expand. - relationData returns information about the relationship, such as who created it and when it was created. - source returns the source entity. - target returns the target entity.
parameters.relationNamestringThe name of the relationship. This method supports the 'favourite' (i.e. 'save for later') relationship as well as any other relationship types created via Create relationship.
parameters.sourceKeystring- The identifier for the source entity: - If sourceType is user, then specify either current (logged-in user), the user key of the user, or the account ID of the user. Note that the user key has been deprecated in favor of the account ID for this parameter. See the migration guide for details. - If sourceType is 'content', then specify the content ID. - If sourceType is 'space', then specify the space key.
parameters.sourceStatus?stringThe status of the source. This parameter is only used when the sourceType is 'content'.
parameters.sourceType"content" | "user" | "space"The source entity type of the relationship. This must be 'user', if the relationName is 'favourite'.
parameters.sourceVersion?numberThe version of the source. This parameter is only used when the sourceType is 'content' and the sourceStatus is 'historical'.
parameters.targetKeystringThe identifier for the target entity: - If targetType is user, then specify either current (logged-in user), the user key of the user, or the account ID of the user. Note that the user key has been deprecated in favor of the account ID for this parameter. See the migration guide for details. - If targetType is 'content', then specify the content ID. - If targetType is 'space', then specify the space key.
parameters.targetStatus?stringThe status of the target. This parameter is only used when the targetType is 'content'.
parameters.targetType"content" | "user" | "space"The target entity type of the relationship. This must be 'space' or 'content', if the relationName is 'favourite'.
parameters.targetVersion?numberThe version of the target. This parameter is only used when the targetType is 'content' and the targetStatus is 'historical'.

Returns

Promise&lt;{ [key: string]: unknown; _expandable?: { [key: string]: unknown; relationData?: string; source?: string; target?: string; }; _links: { [key: string]: unknown; base?: string; byOperation?: string; collection?: string; context?: string; download?: string; editui?: string; edituiv2?: string; next?: string; prev?: string; self?: string; tinyui?: string; webui?: string; }; name: string; relationData?: { [key: string]: unknown; createdBy?: User; createdDate?: Date; friendlyCreatedDate?: string; }; source?: | User | Content | Space; target?: | User | Content | Space; }>