기술 자료

​
​

Development

User Acquisition

Monetization

산업 분야

Friends API

v1

지원 가능
​

Friends API

v1

지원 가능
​

이 페이지는 선택한 언어로 제공되지 않습니다.
Unity Services Web APIs
​
​
Friends API
  • Overview
mdx:openapi:endpoints
  • Messaging
  • Notifications
  • Presence
  • Relationships

Friends API

Overview

The Friends Service provides an HTTP API to manage user relationships of different types, and manage user presence.
We currently support the following types of Relationships:
  • FRIEND_REQUEST - an incoming or outgoing friend request.
  • FRIEND - an active friendship between two users that has been mutually accepted.
  • BLOCK - a one-way relationship that allows a user to block a different user in order to avoid game experiences with them.
Friends makes it quick and easy to create and update relationships and provides the tools needed to efficiently integrate standard Friends functionality into your game. The Presence features provide your players with the ability to advertise their current status in the game to other players, and support for custom presence metadata allows games to easily support features like join-in-progress or spectating.
Built-in support for push notifications allows players to easily manage their friends lists and be quickly notified when the presence of any user changes.
Download OpenAPI specification:

Retrieve a list of relationships.


Retrieves a list of all relationships a given user is involved in. Relationships of all types are returned in a single array. It's up to the caller to use the
type
of the relationship object to determine the appropriate way to handle that relationship. For relationship types that allow it, additional presence and profile data will be provided for each member of the relationship (unless excluded using the
withPresence
and
withProfile
parameters).
By default, we limit the number of relationships that can be returned in a single request. You can make subsequent requests to this API using the
offset
parameter to paginate through the remaining relationships.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Query parameters for "{title}"

limit

integer
기본: 25
Maximum records to return per pagination. The default value is 25.

offset

integer
기본: 0
Maximum offset for pagination. The default value is 0.

withPresence

boolean
기본: true
Whether the response should return presence data.

withProfile

boolean
기본: true
Whether the response should return profiles data.

type

array
기본: FRIEND,BLOCK,FRIEND_REQUEST
The type of the relationship

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://social.services.api.unity.com/v1/relationships"

Response example

[ { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": null, "type": "FRIEND", "members": [ { "id": "ce7a03c4-78a3-4b93-ab8a-ef066f5388bf" } ] }, { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": null, "type": "FRIEND", "members": [ { "id": "89e04c88-7c08-4a46-abe9-5b2089083c5c" } ] }, { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": "2021-12-07T20:34:58Z", "type": "FRIEND_REQUEST", "members": [ { "id": "ebe7db33-ee81-4b5a-b5e1-24fdad5bae72", "role": "TARGET" } ] }, { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": "2021-12-07T20:34:58Z", "type": "FRIEND_REQUEST", "members": [ { "id": "ebe7db33-ee81-4b5a-b5e1-24fdad5bae73", "role": "SOURCE" } ] }, { "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": null, "type": "BLOCK", "members": [ { "id": "ebe7db33-ee81-4b5a-b5e1-24fdad5bae75" } ] }]

Create a new relationship.


Creates a relationship with one or more members. A relationship has a
type
and a list of
members
who are the users involved in the relationship. The requirements for creating a relationship are different depending on the
type
of the relationship.
Each member of the relationship can also be given an optional
role
which may indicate some semantic of the the relationship. A member can be identified by their user id or profile name.
For most relationships, if the caller is a user and is not included in the
members
list, that user's membership is inferred to exist using the appropriate role. For example, if you create a
FRIEND_REQUEST
relationship with one member, the caller is inferred to be the source of the relationship.

Relationship Types

FRIEND_REQUEST
Relationship

A
FRIEND_REQUEST
relationship indicates that a user would like to create a friendship with another user. If no
FRIEND
relationship (i.e. friendship) exists between the two users then the receiving game client will be notified that a
FRIEND_REQUEST
relationship has been created, and the game can choose to notify the user and provide a mechanism for them to accept the friend request. A friend request is accepted by creating a reciprocal
FRIEND_REQUEST
relationship targeting the originating user.
A
FRIEND_REQUEST
relationship can ONLY have two members. The members have a role of either
SOURCE
or
TARGET
to indicate the sender and the receiver of the request. If not provided the caller of the API will be inferred to be the
SOURCE
and the other member will be the
TARGET
. A user cannot create a relationship with themselves as the
TARGET
.

FRIEND
Relationship

A
FRIEND
relationship cannot be directly created by a user, but is implicitly created when both users have created
FRIEND_REQUEST
relationships with each other (i.e. sent and accepted a friend request).
A
FRIEND
relationship is not directed, so the
members
of the relationships do not have an assigned
role
.

BLOCK Relationship

A
BLOCK
relationship is a one-way relationship that enables a user to indicate that another user should be prevented from interacting with themselves for certain features and functionality (e.g. hiding presence, preventing the user from sending messages to them, etc.).
Presence blocking will be handled by the service to ensure that blocked users are unable to view the presence details of the blocker. For other functionality it is up to the developer to consume the
BLOCK
relationships data and provide additional functionality. For example, a game client could filter out lobbies created by users that have been blocked, or a game server could prevent a blocked user from joining a game instance.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Query parameters for "{title}"

withPresence

boolean
기본: true
Whether the response should return presence data.

withProfile

boolean
기본: true
Whether the response should return profiles data.

Request body for "{title}"

Media Type:
application/json

type

string
필수
No description

members

array[object]
필수
No description

profileName

string
No description

id

string
No description

role

string
No description

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "type": "FRIEND", "members": [ { "profileName": "string", "id": "string", "role": "TARGET" } ]}' \ "https://social.services.api.unity.com/v1/relationships"

Response example

{ "id": "<relationship_id>", "created": "2021-11-17T20:34:58Z", "expires": "2021-12-07T20:34:58Z", "type": "FRIEND_REQUEST", "members": [ { "id": "s89e04c88-7c08-4a46-abe9-5b2089083c5c", "profile": { "name": "ColorfulFlickeringHat#9" }, "role": "TARGET" } ]}

Delete a relationship.


Deletes a relationship with the given
relationshipId
.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

relationshipId

string
필수
The relationship ID.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X DELETE \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://social.services.api.unity.com/v1/relationships/{relationshipId}"

Response example

{ "type": "http://unity.com/relationships/invalid_relationship", "code": 24002, "requestID": "12345", "status": 400, "title": "Bad Request", "detail": "invalid relationship id"}

Send a message to a user.


Allows a user to send a message with a custom payload to another user. The Friends Service will only allow a user to send a message to a user that they have an active FRIEND relationship with.
The content of the payload can be customized entirely by the client. It is up to the client to determine how to best handle the message payload. For example, if the message payload contains a lobby ID, the client could show an Accept Invite toast. If the message contains a trade request, the client could enter a trading interface.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Request body for "{title}"

Media Type:
application/json

id

string
필수
No description

message

object
필수
The message to be sent to the target user. The maximum size of the message payload is 10 kilobytes.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "id": "string", "message": {}}' \ "https://social.services.api.unity.com/v1/message"

Response example

{ "type": "http://unity.com/relationships/invalid_relationship", "code": 24002, "requestID": "12345", "status": 400, "title": "Bad Request", "detail": "invalid relationship id"}

Get notification auth details.


Retrieves both a subscription token and a channel name that the user should use to subscribe to notifications. The Friends Service updates the notifications channel as changes to the user's relationships occur. This includes updates to the presence state of any friends, new friend requests (i.e.
FRIEND_REQUEST
relationships created), etc.
In general, the client should not depend on repeatedly polling the entire list of relationships to monitor for changes, but should instead fetch the entire list once and then register for notifications of any updates. This allows the client to keep the list up to date while minimizing overhead.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://social.services.api.unity.com/v1/notifications/auth"

Response example

{ "token": "<notification_auth_jwt>", "channel": "<notification_channel>"}

Set presence for a user.


Updates the presence data for a user. This can be either or both of the availability and the activity.
Updates to the presence for a user will be pushed to all users with active FRIEND relationships with that user.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Request body for "{title}"

Media Type:
application/json

availability

string
필수
The current availability of the user.

activity

object
The current activity data of the user. The maximum for the activity object is 10 kilobytes.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "availability": "ONLINE", "activity": {}}' \ "https://social.services.api.unity.com/v1/presence"

Response example

{ "availability": "ONLINE", "activity": { "location": "In Menu" }}

Get presence for a user.


Retrieves the presence data for a specific user. If the caller is a user, then the target user must be one that the caller has an active
FRIEND
relationship with.
Authorizations
Client
HTTP: Client
HTTP Authorization Scheme: bearer

Path parameters for "{title}"

userId

string
필수
The userID.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://social.services.api.unity.com/v1/presence/{userId}"

Response example

{ "availability": "ONLINE", "activity": { "location": "In Menu" }}

Copyright © 2026 Unity Technologies
법률 정보개인정보 처리방침쿠키Documentation Terms of Use개인 정보 판매 또는 공유 금지개인정보 보호 선택(쿠키 설정)

'Unity', Unity 로고 및 기타 Unity 상표는 미국 및 기타 지역 내 Unity Technologies 또는 그 계열사의 상표 또는 등록상표입니다(자세한 내용은 여기에서 확인하세요). 기타 명칭 또는 브랜드는 해당 소유자의 상표입니다.

일부 페이지는 편의를 위해 기계 번역되었으며 부정확한 내용이 있을 수 있습니다. 정보가 상충되는 경우, 영어 버전을 우선으로 참조하세요.