api.php 23 KB

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