api.yaml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. swagger: '2.0'
  2. info:
  3. title: Jupyter Notebook API
  4. description: Notebook API
  5. version: "5"
  6. contact:
  7. name: Jupyter Project
  8. url: https://jupyter.org
  9. # will be prefixed to all paths
  10. basePath: /
  11. produces:
  12. - application/json
  13. consumes:
  14. - application/json
  15. parameters:
  16. kernel:
  17. name: kernel_id
  18. required: true
  19. in: path
  20. description: kernel uuid
  21. type: string
  22. format: uuid
  23. session:
  24. name: session
  25. required: true
  26. in: path
  27. description: session uuid
  28. type: string
  29. format: uuid
  30. path:
  31. name: path
  32. required: true
  33. in: path
  34. description: file path
  35. type: string
  36. checkpoint_id:
  37. name: checkpoint_id
  38. required: true
  39. in: path
  40. description: Checkpoint id for a file
  41. type: string
  42. section_name:
  43. name: section_name
  44. required: true
  45. in: path
  46. description: Name of config section
  47. type: string
  48. terminal_id:
  49. name: terminal_id
  50. required: true
  51. in: path
  52. description: ID of terminal session
  53. type: string
  54. paths:
  55. /api/contents/{path}:
  56. parameters:
  57. - $ref: '#/parameters/path'
  58. get:
  59. summary: Get contents of file or directory
  60. description: "A client can optionally specify a type and/or format argument via URL parameter. When given, the Contents service shall return a model in the requested type and/or format. If the request cannot be satisfied, e.g. type=text is requested, but the file is binary, then the request shall fail with 400 and have a JSON response containing a 'reason' field, with the value 'bad format' or 'bad type', depending on what was requested."
  61. tags:
  62. - contents
  63. parameters:
  64. - name: type
  65. in: query
  66. description: File type ('file', 'directory')
  67. type: string
  68. enum:
  69. - file
  70. - directory
  71. - name: format
  72. in: query
  73. description: "How file content should be returned ('text', 'base64')"
  74. type: string
  75. enum:
  76. - text
  77. - base64
  78. - name: content
  79. in: query
  80. description: "Return content (0 for no content, 1 for return content)"
  81. type: integer
  82. responses:
  83. 404:
  84. description: No item found
  85. 400:
  86. description: Bad request
  87. schema:
  88. type: object
  89. properties:
  90. error:
  91. type: string
  92. description: Error condition
  93. reason:
  94. type: string
  95. description: Explanation of error reason
  96. 200:
  97. description: Contents of file or directory
  98. headers:
  99. Last-Modified:
  100. description: Last modified date for file
  101. type: string
  102. format: dateTime
  103. schema:
  104. $ref: '#/definitions/Contents'
  105. 500:
  106. description: Model key error
  107. post:
  108. summary: Create a new file in the specified path
  109. description: "A POST to /api/contents/path creates a New untitled, empty file or directory. A POST to /api/contents/path with body {'copy_from': '/path/to/OtherNotebook.ipynb'} creates a new copy of OtherNotebook in path."
  110. tags:
  111. - contents
  112. parameters:
  113. - name: model
  114. in: body
  115. description: Path of file to copy
  116. schema:
  117. type: object
  118. properties:
  119. copy_from:
  120. type: string
  121. ext:
  122. type: string
  123. type:
  124. type: string
  125. responses:
  126. 201:
  127. description: File created
  128. headers:
  129. Location:
  130. description: URL for the new file
  131. type: string
  132. format: url
  133. schema:
  134. $ref: '#/definitions/Contents'
  135. 404:
  136. description: No item found
  137. 400:
  138. description: Bad request
  139. schema:
  140. type: object
  141. properties:
  142. error:
  143. type: string
  144. description: Error condition
  145. reason:
  146. type: string
  147. description: Explanation of error reason
  148. patch:
  149. summary: Rename a file or directory without re-uploading content
  150. tags:
  151. - contents
  152. parameters:
  153. - name: path
  154. in: body
  155. required: true
  156. description: New path for file or directory.
  157. schema:
  158. type: object
  159. properties:
  160. path:
  161. type: string
  162. format: path
  163. description: New path for file or directory
  164. responses:
  165. 200:
  166. description: Path updated
  167. headers:
  168. Location:
  169. description: Updated URL for the file or directory
  170. type: string
  171. format: url
  172. schema:
  173. $ref: '#/definitions/Contents'
  174. 400:
  175. description: No data provided
  176. schema:
  177. type: object
  178. properties:
  179. error:
  180. type: string
  181. description: Error condition
  182. reason:
  183. type: string
  184. description: Explanation of error reason
  185. put:
  186. summary: Save or upload file.
  187. description: "Saves the file in the location specified by name and path. PUT is very similar to POST, but the requester specifies the name, whereas with POST, the server picks the name."
  188. tags:
  189. - contents
  190. parameters:
  191. - name: model
  192. in: body
  193. description: New path for file or directory
  194. schema:
  195. type: object
  196. properties:
  197. name:
  198. type: string
  199. description: The new filename if changed
  200. path:
  201. type: string
  202. description: New path for file or directory
  203. type:
  204. type: string
  205. description: Path dtype ('notebook', 'file', 'directory')
  206. format:
  207. type: string
  208. description: File format ('json', 'text', 'base64')
  209. content:
  210. type: string
  211. description: The actual body of the document excluding directory type
  212. responses:
  213. 200:
  214. description: File saved
  215. headers:
  216. Location:
  217. description: Updated URL for the file or directory
  218. type: string
  219. format: url
  220. schema:
  221. $ref: '#/definitions/Contents'
  222. 201:
  223. description: Path created
  224. headers:
  225. Location:
  226. description: URL for the file or directory
  227. type: string
  228. format: url
  229. schema:
  230. $ref: '#/definitions/Contents'
  231. 400:
  232. description: No data provided
  233. schema:
  234. type: object
  235. properties:
  236. error:
  237. type: string
  238. description: Error condition
  239. reason:
  240. type: string
  241. description: Explanation of error reason
  242. delete:
  243. summary: Delete a file in the given path
  244. tags:
  245. - contents
  246. responses:
  247. 204:
  248. description: File deleted
  249. headers:
  250. Location:
  251. description: URL for the removed file
  252. type: string
  253. format: url
  254. /api/contents/{path}/checkpoints:
  255. parameters:
  256. - $ref: '#/parameters/path'
  257. get:
  258. summary: Get a list of checkpoints for a file
  259. description: List checkpoints for a given file. There will typically be zero or one results.
  260. tags:
  261. - contents
  262. responses:
  263. 404:
  264. description: No item found
  265. 400:
  266. description: Bad request
  267. schema:
  268. type: object
  269. properties:
  270. error:
  271. type: string
  272. description: Error condition
  273. reason:
  274. type: string
  275. description: Explanation of error reason
  276. 200:
  277. description: List of checkpoints for a file
  278. schema:
  279. type: array
  280. items:
  281. $ref: '#/definitions/Checkpoints'
  282. 500:
  283. description: Model key error
  284. post:
  285. summary: Create a new checkpoint for a file
  286. description: "Create a new checkpoint with the current state of a file. With the default FileContentsManager, only one checkpoint is supported, so creating new checkpoints clobbers existing ones."
  287. tags:
  288. - contents
  289. responses:
  290. 201:
  291. description: Checkpoint created
  292. headers:
  293. Location:
  294. description: URL for the checkpoint
  295. type: string
  296. format: url
  297. schema:
  298. $ref: '#/definitions/Checkpoints'
  299. 404:
  300. description: No item found
  301. 400:
  302. description: Bad request
  303. schema:
  304. type: object
  305. properties:
  306. error:
  307. type: string
  308. description: Error condition
  309. reason:
  310. type: string
  311. description: Explanation of error reason
  312. /api/contents/{path}/checkpoints/{checkpoint_id}:
  313. post:
  314. summary: Restore a file to a particular checkpointed state
  315. parameters:
  316. - $ref: "#/parameters/path"
  317. - $ref: "#/parameters/checkpoint_id"
  318. tags:
  319. - contents
  320. responses:
  321. 204:
  322. description: Checkpoint restored
  323. 400:
  324. description: Bad request
  325. schema:
  326. type: object
  327. properties:
  328. error:
  329. type: string
  330. description: Error condition
  331. reason:
  332. type: string
  333. description: Explanation of error reason
  334. delete:
  335. summary: Delete a checkpoint
  336. parameters:
  337. - $ref: "#/parameters/path"
  338. - $ref: "#/parameters/checkpoint_id"
  339. tags:
  340. - contents
  341. responses:
  342. 204:
  343. description: Checkpoint deleted
  344. /api/sessions/{session}:
  345. parameters:
  346. - $ref: '#/parameters/session'
  347. get:
  348. summary: Get session
  349. tags:
  350. - sessions
  351. responses:
  352. 200:
  353. description: Session
  354. schema:
  355. $ref: '#/definitions/Session'
  356. patch:
  357. summary: "This can be used to rename the session."
  358. tags:
  359. - sessions
  360. parameters:
  361. - name: model
  362. in: body
  363. required: true
  364. schema:
  365. $ref: '#/definitions/Session'
  366. responses:
  367. 200:
  368. description: Session
  369. schema:
  370. $ref: '#/definitions/Session'
  371. 400:
  372. description: No data provided
  373. delete:
  374. summary: Delete a session
  375. tags:
  376. - sessions
  377. responses:
  378. 204:
  379. description: Session (and kernel) were deleted
  380. 410:
  381. description: "Kernel was deleted before the session, and the session was *not* deleted (TODO - check to make sure session wasn't deleted)"
  382. /api/sessions:
  383. get:
  384. summary: List available sessions
  385. tags:
  386. - sessions
  387. responses:
  388. 200:
  389. description: List of current sessions
  390. schema:
  391. type: array
  392. items:
  393. $ref: '#/definitions/Session'
  394. post:
  395. summary: "Create a new session, or return an existing session if a session of the same name already exists"
  396. tags:
  397. - sessions
  398. parameters:
  399. - name: session
  400. in: body
  401. schema:
  402. $ref: '#/definitions/Session'
  403. responses:
  404. 201:
  405. description: Session created or returned
  406. schema:
  407. $ref: '#/definitions/Session'
  408. headers:
  409. Location:
  410. description: URL for session commands
  411. type: string
  412. format: url
  413. 501:
  414. description: Session not available
  415. schema:
  416. type: object
  417. description: error message
  418. properties:
  419. message:
  420. type: string
  421. short_message:
  422. type: string
  423. /api/kernels:
  424. get:
  425. summary: List the JSON data for all kernels that are currently running
  426. tags:
  427. - kernels
  428. responses:
  429. 200:
  430. description: List of currently-running kernel uuids
  431. schema:
  432. type: array
  433. items:
  434. $ref: '#/definitions/Kernel'
  435. post:
  436. summary: Start a kernel and return the uuid
  437. tags:
  438. - kernels
  439. parameters:
  440. - name: name
  441. in: body
  442. description: Kernel spec name (defaults to default kernel spec for server)
  443. schema:
  444. type: object
  445. properties:
  446. name:
  447. type: string
  448. responses:
  449. 201:
  450. description: Kernel started
  451. schema:
  452. $ref: '#/definitions/Kernel'
  453. headers:
  454. Location:
  455. description: Model for started kernel
  456. type: string
  457. format: url
  458. /api/kernels/{kernel_id}:
  459. parameters:
  460. - $ref: '#/parameters/kernel'
  461. get:
  462. summary: Get kernel information
  463. tags:
  464. - kernels
  465. responses:
  466. 200:
  467. description: Kernel information
  468. schema:
  469. $ref: '#/definitions/Kernel'
  470. delete:
  471. summary: Kill a kernel and delete the kernel id
  472. tags:
  473. - kernels
  474. responses:
  475. 204:
  476. description: Kernel deleted
  477. /api/kernels/{kernel_id}/interrupt:
  478. parameters:
  479. - $ref: '#/parameters/kernel'
  480. post:
  481. summary: Interrupt a kernel
  482. tags:
  483. - kernels
  484. responses:
  485. 204:
  486. description: Kernel interrupted
  487. /api/kernels/{kernel_id}/restart:
  488. parameters:
  489. - $ref: '#/parameters/kernel'
  490. post:
  491. summary: Restart a kernel
  492. tags:
  493. - kernels
  494. responses:
  495. 200:
  496. description: Kernel interrupted
  497. headers:
  498. Location:
  499. description: URL for kernel commands
  500. type: string
  501. format: url
  502. schema:
  503. $ref: '#/definitions/Kernel'
  504. /api/kernelspecs:
  505. get:
  506. summary: Get kernel specs
  507. tags:
  508. - kernelspecs
  509. responses:
  510. 200:
  511. description: Kernel specs
  512. schema:
  513. type: object
  514. properties:
  515. default:
  516. type: string
  517. description: Default kernel name
  518. kernelspecs:
  519. type: object
  520. additionalProperties:
  521. $ref: '#/definitions/KernelSpec'
  522. /api/config/{section_name}:
  523. get:
  524. summary: Get a configuration section by name
  525. parameters:
  526. - $ref: "#/parameters/section_name"
  527. tags:
  528. - config
  529. responses:
  530. 200:
  531. description: Configuration object
  532. schema:
  533. type: object
  534. patch:
  535. summary: Update a configuration section by name
  536. tags:
  537. - config
  538. parameters:
  539. - $ref: "#/parameters/section_name"
  540. - name: configuration
  541. in: body
  542. schema:
  543. type: object
  544. responses:
  545. 200:
  546. description: Configuration object
  547. schema:
  548. type: object
  549. /api/terminals:
  550. get:
  551. summary: Get available terminals
  552. tags:
  553. - terminals
  554. responses:
  555. 200:
  556. description: A list of all available terminal ids.
  557. schema:
  558. type: array
  559. items:
  560. $ref: '#/definitions/Terminal_ID'
  561. 403:
  562. description: Forbidden to access
  563. 404:
  564. description: Not found
  565. post:
  566. summary: Create a new terminal
  567. tags:
  568. - terminals
  569. responses:
  570. 200:
  571. description: Succesfully created a new terminal
  572. schema:
  573. $ref: '#/definitions/Terminal_ID'
  574. 403:
  575. description: Forbidden to access
  576. 404:
  577. description: Not found
  578. /api/terminals/{terminal_id}:
  579. get:
  580. summary: Get a terminal session corresponding to an id.
  581. tags:
  582. - terminals
  583. parameters:
  584. - $ref: '#/parameters/terminal_id'
  585. responses:
  586. 200:
  587. description: Terminal session with given id
  588. schema:
  589. $ref: '#/definitions/Terminal_ID'
  590. 403:
  591. description: Forbidden to access
  592. 404:
  593. description: Not found
  594. delete:
  595. summary: Delete a terminal session corresponding to an id.
  596. tags:
  597. - terminals
  598. parameters:
  599. - $ref: '#/parameters/terminal_id'
  600. responses:
  601. 204:
  602. description: Succesfully deleted terminal session
  603. 403:
  604. description: Forbidden to access
  605. 404:
  606. description: Not found
  607. /api/status:
  608. get:
  609. summary: Get the current status/activity of the server.
  610. tags:
  611. - status
  612. responses:
  613. 200:
  614. description: The current status of the server
  615. schema:
  616. $ref: '#/definitions/APIStatus'
  617. /api/spec.yaml:
  618. get:
  619. summary: Get the current spec for the notebook server's APIs.
  620. tags:
  621. - api-spec
  622. produces:
  623. - text/x-yaml
  624. responses:
  625. 200:
  626. description: The current spec for the notebook server's APIs.
  627. schema:
  628. type: file
  629. definitions:
  630. APIStatus:
  631. description: |
  632. Notebook server API status.
  633. Added in notebook 5.0.
  634. properties:
  635. started:
  636. type: string
  637. description: |
  638. ISO8601 timestamp indicating when the notebook server started.
  639. last_activity:
  640. type: string
  641. description: |
  642. ISO8601 timestamp indicating the last activity on the server,
  643. either on the REST API or kernel activity.
  644. connections:
  645. type: number
  646. description: |
  647. The total number of currently open connections to kernels.
  648. kernels:
  649. type: number
  650. description: |
  651. The total number of running kernels.
  652. KernelSpec:
  653. description: Kernel spec (contents of kernel.json)
  654. properties:
  655. name:
  656. type: string
  657. description: Unique name for kernel
  658. KernelSpecFile:
  659. $ref: '#/definitions/KernelSpecFile'
  660. resources:
  661. type: object
  662. properties:
  663. kernel.js:
  664. type: string
  665. format: filename
  666. description: path for kernel.js file
  667. kernel.css:
  668. type: string
  669. format: filename
  670. description: path for kernel.css file
  671. logo-*:
  672. type: string
  673. format: filename
  674. description: path for logo file. Logo filenames are of the form `logo-widthxheight`
  675. KernelSpecFile:
  676. description: Kernel spec json file
  677. required:
  678. - argv
  679. - display_name
  680. - language
  681. properties:
  682. language:
  683. type: string
  684. description: The programming language which this kernel runs. This will be stored in notebook metadata.
  685. argv:
  686. type: array
  687. description: "A list of command line arguments used to start the kernel. The text `{connection_file}` in any argument will be replaced with the path to the connection file."
  688. items:
  689. type: string
  690. display_name:
  691. type: string
  692. description: "The kernel's name as it should be displayed in the UI. Unlike the kernel name used in the API, this can contain arbitrary unicode characters."
  693. codemirror_mode:
  694. type: string
  695. description: Codemirror mode. Can be a string *or* an valid Codemirror mode object. This defaults to the string from the `language` property.
  696. env:
  697. type: object
  698. description: A dictionary of environment variables to set for the kernel. These will be added to the current environment variables.
  699. additionalProperties:
  700. type: string
  701. help_links:
  702. type: array
  703. description: Help items to be displayed in the help menu in the notebook UI.
  704. items:
  705. type: object
  706. required:
  707. - text
  708. - url
  709. properties:
  710. text:
  711. type: string
  712. description: menu item link text
  713. url:
  714. type: string
  715. format: URL
  716. description: menu item link url
  717. Kernel:
  718. description: Kernel information
  719. required:
  720. - id
  721. - name
  722. properties:
  723. id:
  724. type: string
  725. format: uuid
  726. description: uuid of kernel
  727. name:
  728. type: string
  729. description: kernel spec name
  730. last_activity:
  731. type: string
  732. description: |
  733. ISO 8601 timestamp for the last-seen activity on this kernel.
  734. Use this in combination with execution_state == 'idle' to identify
  735. which kernels have been idle since a given time.
  736. Timestamps will be UTC, indicated 'Z' suffix.
  737. Added in notebook server 5.0.
  738. connections:
  739. type: number
  740. description: |
  741. The number of active connections to this kernel.
  742. execution_state:
  743. type: string
  744. description: |
  745. Current execution state of the kernel (typically 'idle' or 'busy', but may be other values, such as 'starting').
  746. Added in notebook server 5.0.
  747. Session:
  748. description: A session
  749. type: object
  750. properties:
  751. id:
  752. type: string
  753. format: uuid
  754. path:
  755. type: string
  756. description: path to the session
  757. name:
  758. type: string
  759. description: name of the session
  760. type:
  761. type: string
  762. description: session type
  763. kernel:
  764. $ref: '#/definitions/Kernel'
  765. Contents:
  766. description: "A contents object. The content and format keys may be null if content is not contained. If type is 'file', then the mimetype will be null."
  767. type: object
  768. required:
  769. - type
  770. - name
  771. - path
  772. - writable
  773. - created
  774. - last_modified
  775. - mimetype
  776. - format
  777. - content
  778. properties:
  779. name:
  780. type: string
  781. description: "Name of file or directory, equivalent to the last part of the path"
  782. path:
  783. type: string
  784. description: Full path for file or directory
  785. type:
  786. type: string
  787. description: Type of content
  788. enum:
  789. - directory
  790. - file
  791. - notebook
  792. writable:
  793. type: boolean
  794. description: indicates whether the requester has permission to edit the file
  795. created:
  796. type: string
  797. description: Creation timestamp
  798. format: dateTime
  799. last_modified:
  800. type: string
  801. description: Last modified timestamp
  802. format: dateTime
  803. size:
  804. type: integer
  805. description: "The size of the file or notebook in bytes. If no size is provided, defaults to null."
  806. mimetype:
  807. type: string
  808. description: "The mimetype of a file. If content is not null, and type is 'file', this will contain the mimetype of the file, otherwise this will be null."
  809. content:
  810. type: string
  811. description: "The content, if requested (otherwise null). Will be an array if type is 'directory'"
  812. format:
  813. type: string
  814. description: Format of content (one of null, 'text', 'base64', 'json')
  815. Checkpoints:
  816. description: A checkpoint object.
  817. type: object
  818. required:
  819. - id
  820. - last_modified
  821. properties:
  822. id:
  823. type: string
  824. description: Unique id for the checkpoint.
  825. last_modified:
  826. type: string
  827. description: Last modified timestamp
  828. format: dateTime
  829. Terminal_ID:
  830. description: A Terminal_ID object
  831. type: object
  832. required:
  833. - name
  834. properties:
  835. name:
  836. type: string
  837. description: name of terminal ID