Nakama Friends API

Manage the friend graph.

OpenAPI Specification

nakama-friends-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: Nakama Account Friends API
  description: 'Representative OpenAPI description of the core REST API for Nakama, the open-source game and app backend server by Heroic Labs. Nakama''s public HTTP API is generated by the gRPC-gateway from `api/api.proto` and is published upstream as `apigrpc/apigrpc.swagger.json` in the heroiclabs/nakama repository. This document reconstructs the primary client-facing surface: authentication, accounts and identity linking, social (friends and groups), storage, leaderboards and tournaments, notifications, and custom RPCs.


    Authentication endpoints are guarded by the server key using HTTP Basic auth, where the server key is the username and the password is empty. All other endpoints are authorized with the JWT session token returned by an authenticate call, sent as `Authorization: Bearer <session_token>`. RPC endpoints may alternatively be called server-to-server with an `http_key` query parameter.'
  termsOfService: https://heroiclabs.com/terms/
  contact:
    name: Heroic Labs
    url: https://heroiclabs.com/
    email: support@heroiclabs.com
  license:
    name: Apache 2.0
    url: https://github.com/heroiclabs/nakama/blob/master/LICENSE
  version: '2.0'
servers:
- url: http://127.0.0.1:7350
  description: Default self-hosted Nakama server. Replace host/port with your Heroic Cloud project URL in production.
security:
- BearerAuth: []
tags:
- name: Friends
  description: Manage the friend graph.
paths:
  /v2/friend:
    get:
      operationId: listFriends
      tags:
      - Friends
      summary: List all friends for the current user.
      parameters:
      - in: query
        name: limit
        schema:
          type: integer
          format: int32
        description: Max number of records to return. Between 1 and 1000.
      - in: query
        name: state
        schema:
          type: integer
          format: int32
        description: The friend state to list - 0 friends, 1 invite sent, 2 invite received, 3 blocked.
      - in: query
        name: cursor
        schema:
          type: string
        description: An optional next page cursor.
      responses:
        '200':
          description: A collection of zero or more friends of the user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FriendList'
    post:
      operationId: addFriends
      tags:
      - Friends
      summary: Add friends by ids or usernames.
      parameters:
      - in: query
        name: ids
        schema:
          type: array
          items:
            type: string
        description: The account ids of the users to add as friends.
      - in: query
        name: usernames
        schema:
          type: array
          items:
            type: string
        description: The usernames of the users to add as friends.
      responses:
        '200':
          description: The friends were added or invited.
    delete:
      operationId: deleteFriends
      tags:
      - Friends
      summary: Delete one or more friends for the current user.
      parameters:
      - in: query
        name: ids
        schema:
          type: array
          items:
            type: string
      - in: query
        name: usernames
        schema:
          type: array
          items:
            type: string
      responses:
        '200':
          description: The friends were deleted.
components:
  schemas:
    FriendList:
      type: object
      properties:
        friends:
          type: array
          items:
            $ref: '#/components/schemas/Friend'
        cursor:
          type: string
    User:
      type: object
      description: A user in the system.
      properties:
        id:
          type: string
          description: The id of the user's account.
        username:
          type: string
        display_name:
          type: string
        avatar_url:
          type: string
        lang_tag:
          type: string
        location:
          type: string
        timezone:
          type: string
        metadata:
          type: string
          description: Additional information stored as a JSON-encoded string.
        facebook_id:
          type: string
        google_id:
          type: string
        apple_id:
          type: string
        steam_id:
          type: string
        online:
          type: boolean
        edge_count:
          type: integer
          format: int32
          description: Number of related edges to this user (friend count).
        create_time:
          type: string
          format: date-time
        update_time:
          type: string
          format: date-time
    Friend:
      type: object
      description: A friend of a user.
      properties:
        user:
          $ref: '#/components/schemas/User'
        state:
          type: integer
          format: int32
          description: The friend status - 0 mutual, 1 invite sent, 2 invite received, 3 blocked.
        update_time:
          type: string
          format: date-time
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
      description: HTTP Basic auth using the server key as the username and an empty password. Guards the authenticate endpoints.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'The JWT session token returned by an authenticate call, sent as `Authorization: Bearer <session_token>`.'
externalDocs:
  description: Nakama documentation
  url: https://heroiclabs.com/docs/nakama/