api.php 23 KB

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