Skip to content

API Docs

Samuel Li edited this page Sep 11, 2023 · 1 revision

API (Last Updated 9/10/2023)

Categories

Chats

POST: /api/chats

Creates a new chat with request parameters

type Request = {
  name?: string;
  users?: string[]; // user ids
  color?: string;
}
type Response = {
  _id: string;
  name?: string;
  users?: string[]; // user ids
  color?: string;
}

POST: /api/:chatId

Fetch a chat with id chatId

type Response = {
  _id: string;
  name?: string;
  users?: string[]; // user ids
  color?: string;
}

TODO socket behavior

Users

GET: /api/users

Get all users

type Response = {
  _id: string;
  email: string; // unique
  username: string;
  tag: string;
  bio: string;
  status: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
  friends: string[]; // ids
  games: string[]; // id
  pronouns: Pronouns; // HE_HIM (he-him), SHE_HER (she-her), THEY_THEM (they-them)
  birthday?: {
    day?: number;
    month?: number;
    year?: number;
  };
  language: string;
  timezone: string;
  avatarColor: string;
  lobby?: string; // id
  onboarded: boolean;
}[]

GET: /api/current

Get user information of the user that made the request (when signed in)

type Response = {
  _id: string;
  email: string; // unique
  username: string;
  tag: string;
  bio: string;
  status: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
  friends: string[]; // ids
  games: string[]; // id
  pronouns: Pronouns; // HE_HIM (he-him), SHE_HER (she-her), THEY_THEM (they-them)
  birthday?: {
    day?: number;
    month?: number;
    year?: number;
  };
  language: string;
  timezone: string;
  avatarColor: string;
  lobby?: string; // id
  onboarded: boolean;
}

GET: /api/:userId/status

Get status of user with id userId

type Response = {
  status: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
}

GET: /api/status

Get status of current user (this may no longer work)

type Response = {
  status: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
}

POST: /api/status

Set status of current user

type Request = {
  status: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
}
type Response = {
  status: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
}

GET: /api/friends

Get friends of current user

type Response = {
  _id: string;
  username?: string;
  tag?: string;
  pronouns: Pronouns; // HE_HIM (he-him), SHE_HER (she-her), THEY_THEM (they-them)
  status?: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
  bio?: string;
}[]

POST: /api/friends

type Request = {
  friendId: string;
}
type Response = {
  _id: string;
  email: string; // unique
  username: string;
  tag: string;
  bio: string;
  status: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
  friends: string[]; // ids
  games: string[]; // id
  pronouns: Pronouns; // HE_HIM (he-him), SHE_HER (she-her), THEY_THEM (they-them)
  birthday?: {
    day?: number;
    month?: number;
    year?: number;
  };
  language: string;
  timezone: string;
  avatarColor: string;
  lobby?: string; // id
  onboarded: boolean;
}

POST: /api/onboard

Onboard a user

type Request = {
  username: string;
  games: string[]; // id
  pronouns: Pronouns; // HE_HIM (he-him), SHE_HER (she-her), THEY_THEM (they-them)
  birthday?: {
    day?: number;
    month?: number;
    year?: number;
  };
  language: string;
  timezone: string;
  avatarColor: string;
}
type Response = {
  _id: string;
  email: string; // unique
  username: string;
  tag: string;
  bio: string;
  status: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
  friends: string[]; // ids
  games: string[]; // id
  pronouns: Pronouns; // HE_HIM (he-him), SHE_HER (she-her), THEY_THEM (they-them)
  birthday?: {
    day?: number;
    month?: number;
    year?: number;
  };
  language: string;
  timezone: string;
  avatarColor: string;
  lobby?: string; // id
  onboarded: boolean;
}

Lobbies

GET: /api/lobbies

Get all lobbies

type Response = {
  _id: string;
  name: string;
  game: string;
  hostId: string;
  tags: string[];
  numPlayers: number;
  description: string;
  requests: string[]; // ids
  users: string[]; // ids
  chat: string; // id
}[]

POST: /api/lobbies

Create new lobby

type Request = {
  _id: string;
  name: string;
  game: string;
  hostId: string;
  tags: string[];
  numPlayers: number;
  description: string;
  requests: string[]; // ids
  users: string[]; // ids
  chat: string; // id
}[]
type Response = {
  name: string;
  game: string;
  tags: string[];
  numPlayers: number;
  description: string;
  requests: string[]; // ids
  chat: string; // id
}

GET: /api/lobbies/:lobbyId

Get lobby details with id lobbyId (this may be inaccurate)

type Response = {
  _id: string;
  name: string;
  game: string;
  hostId: string;
  tags: string[];
  numPlayers: number;
  description: string;
  requests: {
    _id: string;
    sender: {
      _id: string;
      username?: string;
      tag?: string;
      pronouns: Pronouns; // HE_HIM (he-him), SHE_HER (she-her), THEY_THEM (they-them)
      status?: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
      bio?: string;
    },
    message: string
  }[]; // ids
  users: {
    _id: string;
    username?: string;
    tag?: string;
    pronouns: Pronouns; // HE_HIM (he-him), SHE_HER (she-her), THEY_THEM (they-them)
    status?: UserStatus; // ACTIVE (0), IDLE (1), DO_NOT_DISTRUB (2), OFFLINE (3)
    bio?: string;
  }[];
  chat: string; // id
}

DELETE: /api/lobbies/:lobbyId

Delete lobby with id lobbyId

type Response = "Successful"

POST: /api/lobbies/:lobbyId/request

Create a lobby request with the sender id set as the user who made this request for a specific lobby with id lobbyId

type Request = {
  message: string
}
type Response = { // updated lobby
  _id: string;
  name: string;
  game: string;
  hostId: string;
  tags: string[];
  numPlayers: number;
  description: string;
  requests: string[]; // ids
  users: string[]; // ids
  chat: string; // id
}

POST: /api/lobbies/:lobbyId/request/:requestId/accept

Host accepts request with request id requestId for lobby with id lobbyId

type Response = { // updated lobby
  _id: string;
  name: string;
  game: string;
  hostId: string;
  tags: string[];
  numPlayers: number;
  description: string;
  requests: string[]; // ids
  users: string[]; // ids
  chat: string; // id
}

POST: /api/lobbies/:lobbyId/request/:requestId/deny

Host denies request with request id requestId for lobby with id lobbyId

type Response = { // updated lobby
  _id: string;
  name: string;
  game: string;
  hostId: string;
  tags: string[];
  numPlayers: number;
  description: string;
  requests: string[]; // ids
  users: string[]; // ids
  chat: string; // id
}

Tags

GET: /api/tags

Get all tags

type Response = {
  _id: string;
  name: string;
  rainbow: boolean;
}[]

POST: /api/tags

Create tag

type Request = {
  name: string;
  rainbow: boolean;
}
type Response = {
  _id: string;
  name: string;
  rainbow: boolean;
}

DELETE: /api/tags/:tagId

Delete tag with id tagId

type Response = "Successful"

Games

GET: /api/games

Get all tags

type Response = {
  _id: string;
  name: string;
  image: string;
  numPlayers: number[];
}[]

POST: /api/games

Create game

type Request = {
  name: string;
  image: string;
  numPlayers: number[];
}
type Response = {
  _id: string;
  name: string;
  image: string;
  numPlayers: number[];
}

DELETE: /api/games/:gameId

Delete tag with id gameId

type Response = "Successful"

Template

``: /api/

type Request = {}
type Response = {}