api.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <?php
  2. $API = [
  3. "version" => 2,
  4. "category" => [
  5. [ // BEGIN CATEGORY Profile
  6. "name" => "Profile",
  7. "command" => [
  8. [ // BEGIN COMMAND UploadProfile
  9. "name" => "profile",
  10. "method" => [
  11. [
  12. "id" => "GET",
  13. "url" => "/profile/{id}/",
  14. "description" => "Retrieves player profile.",
  15. "parameters" => [
  16. [
  17. "key" => "{id}",
  18. "via" => "query",
  19. "type" => "string",
  20. "description" => "Player ID or name.",
  21. "optional" => false
  22. ],
  23. [
  24. "key" => "key",
  25. "via" => "body",
  26. "type" => "string",
  27. "description" => "API key. Required for private profiles.",
  28. "optional" => true
  29. ]
  30. ],
  31. "responses" => [
  32. [
  33. "status" => "200",
  34. "message" => "Success.",
  35. "description" => null,
  36. "example" => json_encode('{"username":"IValentin","level":50,"public":"1"}', JSON_PRETTY_PRINT),
  37. ],
  38. [
  39. "status" => "403",
  40. "message" => "A list of profiles cant be retrieved. Please specify a profile ID or player name.",
  41. "description" => "No player ID or name has been supplied. A full list of profiles is not available.",
  42. "example" => null
  43. ],
  44. [
  45. "status" => "403",
  46. "message" => "The profile is not public.",
  47. "description" => "The requestd player profile is private, and the API key has not been sent or it's invalid.",
  48. "example" => null
  49. ],
  50. [
  51. "status" => "404",
  52. "message" => "Player not found.",
  53. "description" => "The requestd player is not registered in SWDB.",
  54. "example" => null
  55. ]
  56. ]
  57. ],
  58. [
  59. "id" => "POST",
  60. "url" => "/profile/{id}/",
  61. "description" => "Creates a new player profile.",
  62. "parameters" => [
  63. [
  64. "key" => "{id}",
  65. "via" => "query",
  66. "type" => "string",
  67. "description" => "Player ID.",
  68. "optional" => false
  69. ],
  70. [
  71. "key" => "email",
  72. "via" => "body",
  73. "type" => "string",
  74. "description" => "User email. Must be a valid address.",
  75. "optional" => false
  76. ],
  77. [
  78. "key" => "password",
  79. "via" => "body",
  80. "type" => "string",
  81. "description" => "New user password.",
  82. "optional" => false
  83. ],
  84. [
  85. "key" => "name",
  86. "via" => "body",
  87. "type" => "string",
  88. "description" => "New username. If not supplied, it will default to 'player_[id]'. Will be overriden on the next PUT request.",
  89. "optional" => true
  90. ],
  91. [
  92. "key" => "public",
  93. "via" => "body",
  94. "type" => "int",
  95. "description" => "1 to make the profile public, 0 to keep it private. Default to 0.",
  96. "optional" => true
  97. ],
  98. ],
  99. "responses" => [
  100. [
  101. "status" => "201",
  102. "message" => "Created.",
  103. "description" => null,
  104. "example" => json_encode('{"username":"IValentin","email":example@example.com,"api_key":"0123456789012345","public":"0"}', JSON_PRETTY_PRINT),
  105. ],
  106. [
  107. "status" => "400",
  108. "message" => "User ID not received.",
  109. "description" => "The ID of the player to create is not in the query.",
  110. "example" => null
  111. ],
  112. [
  113. "status" => "400",
  114. "message" => "User email not received.",
  115. "description" => "The email of the player to create has not ben passed in the request.",
  116. "example" => null
  117. ],
  118. [
  119. "status" => "400",
  120. "message" => "Invalid email.",
  121. "description" => "The 'mail' parameter must be a valid email address.",
  122. "example" => null
  123. ],
  124. [
  125. "status" => "400",
  126. "message" => "User password not received.",
  127. "description" => "The password of the player to create has not ben passed in the request.",
  128. "example" => null
  129. ],
  130. [
  131. "status" => "400",
  132. "message" => "Existing user.",
  133. "description" => "A player with the same ID is already registered in SWDB.",
  134. "example" => null
  135. ]
  136. ]
  137. ],
  138. [
  139. "id" => "PUT",
  140. "url" => "/profile/{id}/",
  141. "description" => "Updates a player profile with data received from the game.",
  142. "parameters" => [
  143. [
  144. "key" => "{id}",
  145. "via" => "query",
  146. "type" => "string",
  147. "description" => "Player ID.",
  148. "optional" => false
  149. ],
  150. [
  151. "key" => "key",
  152. "via" => "body",
  153. "type" => "string",
  154. "description" => "API key.",
  155. "optional" => false
  156. ],
  157. [
  158. "key" => "response",
  159. "via" => "body",
  160. "type" => "string",
  161. "description" => "JSON received from game server on HubUserLogin command.",
  162. "optional" => false
  163. ]
  164. ],
  165. "responses" => [
  166. [
  167. "status" => "204",
  168. "message" => "Profile imported.",
  169. "description" => null,
  170. "example" => null,
  171. ],
  172. [
  173. "status" => "400",
  174. "message" => "API key not received.",
  175. "description" => "No API key was suplied in the request.",
  176. "example" => null
  177. ],
  178. [
  179. "status" => "400",
  180. "message" => "No data received.",
  181. "description" => "Game JSON response not received from request",
  182. "example" => null
  183. ],
  184. [
  185. "status" => "400",
  186. "message" => "Data is no valid JSON.",
  187. "description" => "The parameter 'response' contains information, but it's not valid JSON data.",
  188. "example" => null
  189. ],
  190. [
  191. "status" => "401",
  192. "message" => "Invalid credentials",
  193. "description" => "The API key is not valid for the profile being updated.",
  194. "example" => null
  195. ]
  196. ]
  197. ],
  198. [
  199. "id" => "DELETE",
  200. "url" => "/profile/{id}/",
  201. "description" => "Deletes a player profile.",
  202. "parameters" => [
  203. [
  204. "key" => "{id}",
  205. "via" => "query",
  206. "type" => "string",
  207. "description" => "Player ID.",
  208. "optional" => false
  209. ],
  210. [
  211. "key" => "key",
  212. "via" => "body",
  213. "type" => "string",
  214. "description" => "API key.",
  215. "optional" => false
  216. ]
  217. ],
  218. "responses" => [
  219. [
  220. "status" => "204",
  221. "message" => "Profile deleted.",
  222. "description" => null,
  223. "example" => null,
  224. ],
  225. [
  226. "status" => "400",
  227. "message" => "User ID not received.",
  228. "description" => "The ID of the player to create is not in the query.",
  229. "example" => null
  230. ],
  231. [
  232. "status" => "400",
  233. "message" => "API key not received.",
  234. "description" => "No API key was suplied in the request.",
  235. "example" => null
  236. ],
  237. [
  238. "status" => "401",
  239. "message" => "Invalid credentials",
  240. "description" => "The API key is not valid for the profile being updated.",
  241. "example" => null
  242. ]
  243. ]
  244. ],
  245. ],
  246. ] // END COMMAND profile
  247. ]
  248. ], // END CATEGORY Profile
  249. [ // BEGIN CATEGORY Run
  250. "name" => "Run",
  251. "command" => [
  252. [ // BEGIN COMMAND run
  253. "name" => "run",
  254. "method" => [
  255. [
  256. "id" => "POST",
  257. "url" => "/run/",
  258. "description" => "Logs a game run.",
  259. "parameters" => [
  260. [
  261. "key" => "key",
  262. "via" => "body",
  263. "type" => "string",
  264. "description" => "API key.",
  265. "optional" => false
  266. ],
  267. [
  268. "key" => "result_response",
  269. "via" => "body",
  270. "type" => "string",
  271. "description" => "JSON received from game server on run result.",
  272. "optional" => false
  273. ],
  274. [
  275. "key" => "result_request",
  276. "via" => "body",
  277. "type" => "string",
  278. "description" => "JSON sent to game server on run result. Required for commands: BattleDungeonResult_V2",
  279. "optional" => true
  280. ],
  281. [
  282. "key" => "start_response",
  283. "via" => "body",
  284. "type" => "string",
  285. "description" => "JSON received from game server on run start. Required for commands: ",
  286. "optional" => true
  287. ],
  288. [
  289. "key" => "start_request",
  290. "via" => "body",
  291. "type" => "string",
  292. "description" => "JSON sent to game server on run start. Required for commands: ",
  293. "optional" => true
  294. ],
  295. ],
  296. "responses" => [
  297. [
  298. "status" => "201",
  299. "message" => "Created.",
  300. "description" => null,
  301. "example" => null,
  302. ],
  303. [
  304. "status" => "400",
  305. "message" => "API key not received.",
  306. "description" => "No API key was suplied in the request.",
  307. "example" => null
  308. ],
  309. [
  310. "status" => "400",
  311. "message" => "No result response data received.",
  312. "description" => "JSON received from game server on run result wast receiven on the request.",
  313. "example" => null
  314. ],
  315. [
  316. "status" => "400",
  317. "message" => "Result response data is no valid JSON.",
  318. "description" => "The parameter 'result_response' contains information, but it's not valid JSON data.",
  319. "example" => null
  320. ],
  321. [
  322. "status" => "401",
  323. "message" => "Invalid credentials",
  324. "description" => "The API key is not valid for the profile being updated.",
  325. "example" => null
  326. ],
  327. [
  328. "status" => "405",
  329. "message" => "Command not implemented.",
  330. "description" => "The command referenced in the JSON file is not implemented.",
  331. "example" => null
  332. ],
  333. [
  334. "status" => "409",
  335. "message" => "Run already in database.",
  336. "description" => "The run is already in the database for the user.",
  337. "example" => null
  338. ]
  339. ]
  340. ],
  341. ],
  342. ] // END COMMAND Run
  343. ]
  344. ], // END CATEGORY Run
  345. ],
  346. ];
  347. ?>