Api - Raghav-Sao/literature GitHub Wiki


[GET] http://www.literature.dev/game

Gets game which is currently active in session.

Response:

{
  "success": true,
  "response": {
    "game": {
      "id": "g_9f2df7473ba4aeb782c3ce1fe1d6a609",
      "createdAt": 1481646985,
      "status": "active",
      "prevTurn": null,
      "prevTurnTime": 1481647021,
      "nextTurn": "4p8a29tg90qm4a5atrebbetpt1",
      "usersCount": 4,
      "users": [
        "4p8a29tg90qm4a5atrebbetpt1",
        "76dp78ll61tk1i9j0nqmbdshp6",
        "9k2mr6i1n6kro861amoi5519q6",
        "8rf2vdjbbrfv9luq5u549q0la6"
      ],
      "team0": [
        "4p8a29tg90qm4a5atrebbetpt1",
        "8rf2vdjbbrfv9luq5u549q0la6"
      ],
      "team1": [
        "76dp78ll61tk1i9j0nqmbdshp6",
        "9k2mr6i1n6kro861amoi5519q6"
      ],
      "points": {
        "4p8a29tg90qm4a5atrebbetpt1": 0,
        "76dp78ll61tk1i9j0nqmbdshp6": 0,
        "9k2mr6i1n6kro861amoi5519q6": 0,
        "8rf2vdjbbrfv9luq5u549q0la6": 0
      }
    },
    "user": {
      "id": "8rf2vdjbbrfv9luq5u549q0la6",
      "cards": [
        "c1",
        "c4",
        "c10",
        "d1",
        "d9",
        "h1",
        "h2",
        "h6",
        "h9",
        "s5",
        "s8",
        "s13"
      ]
    }
  }
}

[POST] http://www.literature.dev/game/start

Starts a new game in initialized state.

Response:

{
  "success": true,
  "response": {
    "game": {
      "id": "g_7e0a937356d3d9c615baf4c248dd3eab",
      "createdAt": 1481646805,
      "status": "initialized",
      "prevTurn": null,
      "prevTurnTime": 0,
      "nextTurn": "l047n2ilpargesmacelnh3re26",
      "usersCount": 1,
      "users": [
        "l047n2ilpargesmacelnh3re26"
      ],
      "team0": [
        "l047n2ilpargesmacelnh3re26"
      ],
      "team1": [],
      "points": {
        "l047n2ilpargesmacelnh3re26": 0
      }
    },
    "user": {
      "id": "l047n2ilpargesmacelnh3re26",
      "cards": [
        "c1",
        "c9",
        "c12",
        "d3",
        "d6",
        "d8",
        "d10",
        "h1",
        "h11",
        "s1",
        "s8",
        "s12"
      ]
    }
  }
}

[POST] http://www.literature.dev/game/{id}/join/{team}

Join a game in given team.

Response:

{
  "success": true,
  "response": {
    "game": {
      "id": "g_9f2df7473ba4aeb782c3ce1fe1d6a609",
      "createdAt": 1481646985,
      "status": "active",
      "prevTurn": null,
      "prevTurnTime": 1481647021,
      "nextTurn": "4p8a29tg90qm4a5atrebbetpt1",
      "usersCount": 4,
      "users": [
        "4p8a29tg90qm4a5atrebbetpt1",
        "76dp78ll61tk1i9j0nqmbdshp6",
        "9k2mr6i1n6kro861amoi5519q6",
        "8rf2vdjbbrfv9luq5u549q0la6"
      ],
      "team0": [
        "4p8a29tg90qm4a5atrebbetpt1",
        "8rf2vdjbbrfv9luq5u549q0la6"
      ],
      "team1": [
        "76dp78ll61tk1i9j0nqmbdshp6",
        "9k2mr6i1n6kro861amoi5519q6"
      ],
      "points": {
        "9k2mr6i1n6kro861amoi5519q6": 0,
        "4p8a29tg90qm4a5atrebbetpt1": 0,
        "76dp78ll61tk1i9j0nqmbdshp6": 0,
        "8rf2vdjbbrfv9luq5u549q0la6": 0
      }
    },
    "user": {
      "id": "8rf2vdjbbrfv9luq5u549q0la6",
      "cards": [
        "c1",
        "c4",
        "c10",
        "d1",
        "d9",
        "h1",
        "h2",
        "h6",
        "h9",
        "s5",
        "s8",
        "s13"
      ]
    }
  }
}

[POST] http://www.literature.dev/game/move/{card}/from/{user}

Request a card from another user.

Response:

{
  "success": true,
  "response": {
    "success": true,
    "game": {
      "id": "g_9f2df7473ba4aeb782c3ce1fe1d6a609",
      "createdAt": 1481646985,
      "status": "active",
      "prevTurn": "8rf2vdjbbrfv9luq5u549q0la6",
      "prevTurnTime": 1481647195,
      "nextTurn": "8rf2vdjbbrfv9luq5u549q0la6",
      "usersCount": 4,
      "users": [
        "4p8a29tg90qm4a5atrebbetpt1",
        "76dp78ll61tk1i9j0nqmbdshp6",
        "9k2mr6i1n6kro861amoi5519q6",
        "8rf2vdjbbrfv9luq5u549q0la6"
      ],
      "team0": [
        "4p8a29tg90qm4a5atrebbetpt1",
        "8rf2vdjbbrfv9luq5u549q0la6"
      ],
      "team1": [
        "76dp78ll61tk1i9j0nqmbdshp6",
        "9k2mr6i1n6kro861amoi5519q6"
      ],
      "points": {
        "9k2mr6i1n6kro861amoi5519q6": 0,
        "8rf2vdjbbrfv9luq5u549q0la6": 0,
        "4p8a29tg90qm4a5atrebbetpt1": 0,
        "76dp78ll61tk1i9j0nqmbdshp6": 0
      }
    },
    "user": {
      "id": "8rf2vdjbbrfv9luq5u549q0la6",
      "cards": [
        "c1",
        "c4",
        "c9",
        "c10",
        "d1",
        "d9",
        "h1",
        "h2",
        "h6",
        "h9",
        "s5",
        "s8",
        "s13"
      ]
    }
  }
}

[POST] http://www.literature.dev/game/show/{card}/{range}

Show cards of type and range.

Response:

{
  "success": true,
  "response": {
    "success": true,
    "game": {
      "id": "g_9f2df7473ba4aeb782c3ce1fe1d6a609",
      "createdAt": 1481646985,
      "status": "active",
      "prevTurn": "8rf2vdjbbrfv9luq5u549q0la6",
      "prevTurnTime": 1481647290,
      "nextTurn": "8rf2vdjbbrfv9luq5u549q0la6",
      "usersCount": 4,
      "users": [
        "4p8a29tg90qm4a5atrebbetpt1",
        "76dp78ll61tk1i9j0nqmbdshp6",
        "9k2mr6i1n6kro861amoi5519q6",
        "8rf2vdjbbrfv9luq5u549q0la6"
      ],
      "team0": [
        "4p8a29tg90qm4a5atrebbetpt1",
        "8rf2vdjbbrfv9luq5u549q0la6"
      ],
      "team1": [
        "76dp78ll61tk1i9j0nqmbdshp6",
        "9k2mr6i1n6kro861amoi5519q6"
      ],
      "points": {
        "9k2mr6i1n6kro861amoi5519q6": 0,
        "8rf2vdjbbrfv9luq5u549q0la6": 3,
        "4p8a29tg90qm4a5atrebbetpt1": 4,
        "76dp78ll61tk1i9j0nqmbdshp6": 0
      }
    },
    "user": {
      "id": "8rf2vdjbbrfv9luq5u549q0la6",
      "cards": [
        "c9",
        "c10",
        "d1",
        "d9",
        "h1",
        "h2",
        "h6",
        "h9",
        "s5",
        "s8",
        "s13"
      ]
    },
    "showResult": [
      {
        "id": "4p8a29tg90qm4a5atrebbetpt1",
        "cardsShown": [
          "c3",
          "c5",
          "c2",
          "c1"
        ],
        "points": 4
      },
      {
        "id": "8rf2vdjbbrfv9luq5u549q0la6",
        "cardsShown": [
          "c4",
          "c6",
          "c1"
        ],
        "points": 3
      }
    ]
  }
}

[DELETE] http://www.literature.dev/game/delete

Deletes the game in session.

Response:

{
  "success": true,
  "response": {
    "success": true
  }
}

[POST] http://www.literature.dev/chat

Post new chat message in game.

Request:

{
	"message": "Sample message"
}

Response:

{
  "success": true,
  "response": {
    "message": "Sample message"
  }
}

Fail Response Format

All fail responses will have the same following structure:

{
  "success": false,
  "errorCode": "BAD_REQUEST",
  "errorMessage": "A game exists in session already.",
  "extra": {
    "gameId": "g_7e0a937356d3d9c615baf4c248dd3eab"
  }
}