-
Notifications
You must be signed in to change notification settings - Fork 1
/
apiary.apib
188 lines (117 loc) · 3.52 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
FORMAT: 1A
HOST: http://localhost:3000/
# TicTacToe
TicTacToe is an API, made with node.js, which allows users to play this game with other users.
## Users [/users]
### List All Users [GET]
+ Response 200 (application/json)
+ Body
{
"users": [
{
"name": "Spiderman",
"played": "0",
"winnings": "0"
},
{
"name": "Batman",
"played": "0",
"winnings": "0"
},
{
"name": "Daredevil",
"played": "0",
"winnings": "0"
}
]
}
### Create a New User [POST]
You may create a new user. It takes a user name, which has to be unique, and a password in oder to login.
+ Request (application/json)
+ Body
{
"name": "Wolverine",
"password": "wolvie123"
}
+ Response 201
+ Response 403 (text)
+ Body
User already exists
## User [/users/{name}]
+ Parameters
+ name (string) - Name of the User in the form of a string
### Get Users Stats [GET]
+ Response 200 (application/json)
+ Body
{
"name": "Spiderman",
"played": "0",
"winnings": "0"
}
+ Response 404 (text)
+ Body
User does not exist
## Login [/login]
### User Login [GET]
+ Request (application/json)
+ Body
{
"name": "Wolverine",
"password": "wolvie123"
}
+ Response 200 (application/json)
+ Body
{
"session_id": "..."
}
+ Response 403 (text)
+ Body
Wrong username or password
## Games [/games/{name}]
### List All Users Engaged [GET]
For a particular user, you may get all other users sharing a started game.
+ Response 200 (application/json)
+ Body
{
"users": [
{
"name": "Spiderman",
"played": "0",
"winnings": "0"
}
{
"name": "Daredevil",
"played": "0",
"winnings": "0"
}
]
}
+ Response 404 (text)
+ Body
User does not exist
## Game [/games/{name_player_x}/{name_player_o}{?tile}]
You may access a game through the names of its two players.
### Start New Game [POST]
+ Response 201
+ Response 403 (text)
+ Body
Game already exists
### Get Game Grid [GET]
You may get a game's grid in form of an array of 9 strings. Each string has a value of "x", "o" or null depending on whether an user has marked a tile or not.
+ Response 200 (application/json)
+ Body
["x", null, "x", null, "o", null, null, null, null]
+ Response 404 (text)
+ Body
Game does not exists
### Move [PUT]
+ Response 201
+ Response 401 (text)
+ Body
User is not a player in this game
+ Response 403 (text)
+ Body
Wait for your opponent's to move
+ Response 404 (text)
+ Body
Game does not exists