api.bimba.tk.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. name: Bimba API
  2. version-code: 0.1.0
  3. version-name: Agrajag
  4. status: draft
  5. formats: &formats
  6. msgpack: msgpack
  7. errors:
  8. _general: &_general-error
  9. error:
  10. type: str
  11. _fields: &_fields-error
  12. fields:
  13. required: false
  14. type: list
  15. items:
  16. type: dict
  17. items:
  18. field:
  19. type: str
  20. error:
  21. type: str
  22. error_general: &error_general
  23. type: dict
  24. items:
  25. *_general-error
  26. error_fields: &error_fields
  27. type: dict
  28. items:
  29. <<: *_general-error
  30. <<: *_fields-error
  31. api:
  32. -
  33. path: /timetables/
  34. GET:
  35. description: list of dates (from,to)
  36. req:
  37. headers:
  38. - Accept
  39. - If-None-Match
  40. res:
  41. codes:
  42. - 200
  43. - 304
  44. - 406
  45. headers:
  46. - Allow
  47. - Content-Type
  48. - ETag
  49. schema:
  50. type: list
  51. items:
  52. type: dict
  53. items:
  54. id:
  55. type: str
  56. start:
  57. type: str:RFC_3339_full-date
  58. end:
  59. type: str:RFC_3339_full-date
  60. POST:
  61. description: new timetable [locked]
  62. req:
  63. headers:
  64. - Accept
  65. - Authorization (Signature {signature})
  66. - Content-Type
  67. schema: todo
  68. res:
  69. codes:
  70. - 201
  71. - 400
  72. - 401
  73. - 403
  74. - 406
  75. - 409 # already exists for the period
  76. headers:
  77. - Allow
  78. - WWW-Authenticate
  79. - Content-Type
  80. - Location
  81. schema:
  82. *error_fields
  83. DELETE:
  84. description: remove timetable [locked]
  85. req:
  86. headers:
  87. - Accept
  88. - Authorization (Signature {signature})
  89. res:
  90. codes:
  91. - 204
  92. - 401
  93. - 403
  94. - 406
  95. - 410
  96. headers:
  97. - Allow
  98. - WWW-Authenticate
  99. - Content-Type
  100. schema:
  101. *error_general
  102. -
  103. path: /timetables/:date:(`current`|RFC_3339_full-date)
  104. GET:
  105. description: timetable valid in :date full with metadata
  106. req:
  107. headers:
  108. - Accept
  109. - If-None-Match
  110. res:
  111. codes:
  112. - 200
  113. - 304
  114. - 404
  115. - 406
  116. - 410 # past date
  117. headers:
  118. - Allow
  119. - Content-Type
  120. - ETag
  121. schema: todo
  122. -
  123. path: /timetables/:date/lines/
  124. GET:
  125. description:
  126. req:
  127. headers:
  128. - Accept
  129. - If-None-Match
  130. res:
  131. codes:
  132. - 200
  133. - 304
  134. - 404
  135. - 406
  136. - 410 # past date
  137. headers:
  138. - Allow
  139. - Content-Type
  140. - ETag
  141. schema:
  142. type: list
  143. items:
  144. type: dict
  145. items:
  146. name:
  147. type: str
  148. directions:
  149. type: list
  150. items:
  151. type: int
  152. -
  153. path: /timetables/:date/lines/:number?direction:(0|1)=null
  154. GET:
  155. description: line graph <filtered by direction>
  156. req:
  157. headers:
  158. - Accept
  159. - If-None-Match
  160. res:
  161. codes:
  162. - 200
  163. - 304
  164. - 404
  165. - 406
  166. - 410 # past date
  167. headers:
  168. - Allow
  169. - Content-Type
  170. - ETag
  171. schema:
  172. type: list
  173. items:
  174. type: dict
  175. items:
  176. direction: # (0|1)
  177. type: int
  178. components:
  179. type: list
  180. items:
  181. type: dict
  182. items:
  183. main:
  184. type: bool
  185. stops:
  186. type: list
  187. items:
  188. type: dict
  189. items:
  190. code:
  191. type: str
  192. name:
  193. type: str
  194. -
  195. path: /timetables/:date/stops/?q:query=''
  196. GET:
  197. description: list of stops matching latinised, case insensitive ^.*q.*$; sorted by relevance and limited to N=10?
  198. req:
  199. headers:
  200. - Accept
  201. - If-None-Match
  202. res:
  203. codes:
  204. - 200
  205. - 304
  206. - 404
  207. - 406
  208. - 410 # past date
  209. headers:
  210. - Allow
  211. - Content-Type
  212. - ETag
  213. schema:
  214. type: list
  215. items:
  216. type: dict
  217. items:
  218. name:
  219. type: str
  220. code:
  221. type: str
  222. lines:
  223. type: list
  224. items:
  225. type: str # {line} → {headsign}
  226. -
  227. path: /timetables/:date/stops/:name/sheds/
  228. reason: is neccessary?
  229. -
  230. path: /timetables/:date/stops/:name/sheds/:code
  231. reason: is neccessary?
  232. -
  233. path: /timetables/:date/departures/sheds/:code?metadata:bool=false # todo: metadata schema
  234. GET:
  235. description: departures for whole shed
  236. req:
  237. headers:
  238. - Accept
  239. - If-None-Match
  240. res:
  241. codes:
  242. - 200
  243. - 304
  244. - 404
  245. - 406
  246. - 410 # past date
  247. headers:
  248. - Allow
  249. - Content-Type
  250. - ETag
  251. schema: &departure
  252. type: list
  253. items:
  254. type: dict
  255. items:
  256. line:
  257. type: str
  258. headsign:
  259. type: str
  260. time:
  261. type: int # seconds after midnight
  262. modifications:
  263. type: list
  264. items:
  265. type: str
  266. accessible: # low floor
  267. type: bool
  268. -
  269. path: /timetables/:date/departures/sheds/:code/lines/:number?metadata:bool=false # todo: metadata schema
  270. GET:
  271. description: departures for whole line in shed
  272. req:
  273. headers:
  274. - Accept
  275. - If-None-Match
  276. res:
  277. codes:
  278. - 200
  279. - 304
  280. - 404
  281. - 406
  282. - 410 # past date
  283. headers:
  284. - Allow
  285. - Content-Type
  286. - ETag
  287. schema:
  288. *departure
  289. -
  290. path: /timetables/:date/departures/sheds/:code/lines/:number/headsigns/:headsign?metadata:bool=false # todo: metadata schema
  291. GET:
  292. description: departures for whole line with headsign in shed
  293. req:
  294. headers:
  295. - Accept
  296. - If-None-Match
  297. res:
  298. codes:
  299. - 200
  300. - 304
  301. - 404
  302. - 406
  303. - 410 # past date
  304. headers:
  305. - Allow
  306. - Content-Type
  307. - ETag
  308. schema:
  309. *departure
  310. -
  311. path: /information/(news|alerts)/
  312. GET:
  313. description: list of ID, title, source, date, translations, thumbnail
  314. req:
  315. headers:
  316. - Accept
  317. - If-None-Match
  318. res:
  319. codes:
  320. - 200
  321. - 304
  322. - 406
  323. headers:
  324. - Allow
  325. - Content-Type
  326. - ETag
  327. schema:
  328. type: list
  329. items:
  330. type: dict
  331. items:
  332. id:
  333. type: str
  334. title:
  335. type: str
  336. source:
  337. type: str # URL
  338. datetime:
  339. type: str # RFC3339
  340. translations:
  341. type: list
  342. items:
  343. type: str # IETF language tag
  344. thumbnail: # preferably webp
  345. type: bytes
  346. -
  347. path: /imformation/*/:id
  348. GET:
  349. description: original text of the piece of information
  350. req:
  351. headers:
  352. - Accept
  353. - If-None-Match
  354. res:
  355. codes:
  356. - 200
  357. - 304
  358. - 404
  359. - 406
  360. headers:
  361. - Allow
  362. - Content-Type
  363. - ETag
  364. schema:
  365. type: dict
  366. items:
  367. content:
  368. type: str # ReStructuredText?
  369. lang:
  370. type: str # IETF language tag
  371. -
  372. path: /information/*/:id/translations/
  373. GET:
  374. description: list of translations (ID, lang)
  375. req:
  376. headers:
  377. - Accept
  378. - If-None-Match
  379. res:
  380. codes:
  381. - 200
  382. - 304
  383. - 404
  384. - 406
  385. headers:
  386. - Allow
  387. - Content-Type
  388. - ETag
  389. schema:
  390. type: list
  391. items:
  392. type: dict
  393. items:
  394. id:
  395. type: str
  396. lang:
  397. type: str # IETF language tag
  398. POST:
  399. description: create new translation
  400. req:
  401. headers:
  402. - Accept
  403. - Content-Type
  404. schema:
  405. type: dict
  406. items:
  407. content:
  408. type: str
  409. lang:
  410. type: str # IETF language tag
  411. res:
  412. codes:
  413. - 201
  414. - 400
  415. - 406
  416. headers:
  417. - Allow
  418. - Content-Type
  419. - Location
  420. schema:
  421. *error_fields
  422. -
  423. path: /information/*/:id/translations/:id
  424. GET:
  425. description: translations content and score
  426. req:
  427. headers:
  428. - Accept
  429. - If-None-Match
  430. res:
  431. codes:
  432. - 200
  433. - 304
  434. - 404
  435. - 406
  436. headers:
  437. - Allow
  438. - Content-Type
  439. - ETag
  440. schema:
  441. type: dict
  442. items:
  443. content:
  444. type: str
  445. lang:
  446. type: str # IETF language tag
  447. score:
  448. type: float
  449. PATCH:
  450. description: assess translation
  451. req:
  452. headers:
  453. - Accept
  454. - Content-Type
  455. schema:
  456. type: dict
  457. items:
  458. vote:
  459. type: float
  460. res:
  461. codes:
  462. - 200
  463. - 400
  464. - 404
  465. - 406
  466. headers:
  467. - Allow
  468. - Content-Type
  469. - Location
  470. schema:
  471. *error_fields
  472. -
  473. path: /crash_reports/
  474. GET:
  475. description: list of crash reports (date, id)
  476. formats:
  477. <<: *formats
  478. atom: atom
  479. req:
  480. headers:
  481. - Accept
  482. - If-None-Match
  483. res:
  484. codes:
  485. - 200
  486. - 304
  487. - 406
  488. headers:
  489. - Allow
  490. - Content-Type
  491. - ETag
  492. schema:
  493. type: list
  494. items:
  495. type: dict
  496. items:
  497. id:
  498. type: str
  499. date:
  500. type: str # RFC3339
  501. POST:
  502. description: new crash report
  503. req:
  504. headers:
  505. - Accept
  506. - Content-Type
  507. schema:
  508. type: dict
  509. items: &crash_report
  510. app: # web,apk,…
  511. type: str
  512. app_version:
  513. type: str
  514. conetxt: # apk:OS, web:browser
  515. type: str
  516. context_version: # apk:Android API level (ROM?), web:browser version
  517. type: str
  518. device: # apk:make,model,…, web:?
  519. type: str
  520. content: # staktrace, &c.
  521. type: str
  522. res:
  523. codes:
  524. - 201
  525. - 400
  526. - 406
  527. headers:
  528. - Allow
  529. - Content-Type
  530. - Location
  531. schema:
  532. *error_fields
  533. -
  534. path: /crash_reports/:id
  535. GET:
  536. description: crash report
  537. req:
  538. headers:
  539. - Accept
  540. - If-None-Match
  541. res:
  542. codes:
  543. - 200
  544. - 304
  545. - 404
  546. - 406
  547. headers:
  548. - Allow
  549. - Content-Type
  550. - ETag
  551. schema:
  552. type: dict
  553. items:
  554. <<: *crash_report
  555. issue: # bug tracking issue (e.g. in repo)
  556. type: str # URL
  557. updated:
  558. type: str # RFC3339
  559. PATCH:
  560. description: add info [locked]
  561. req:
  562. headers:
  563. - Accept
  564. - Authorization (Signature {signature})
  565. - Content-Type
  566. - If-Match
  567. schema:
  568. type: dict
  569. items:
  570. issue: # bug tracking issue (e.g. in repo)
  571. type: str # URL
  572. res:
  573. codes:
  574. - 200
  575. - 400
  576. - 401
  577. - 403
  578. - 406
  579. - 412
  580. - 428
  581. headers:
  582. - Allow
  583. - WWW-Authenticate
  584. - Content-Type
  585. - Location
  586. schema:
  587. *error_fields
  588. DELETE:
  589. description: remove [locked]
  590. req:
  591. headers:
  592. - Accept
  593. - Authorization (Signature {signature})
  594. res:
  595. codes:
  596. - 204
  597. - 401
  598. - 403
  599. - 406
  600. - 410
  601. headers:
  602. - Allow
  603. - WWW-Authenticate
  604. - Content-Type
  605. schema:
  606. *error_general