Created
June 30, 2021 16:54
-
-
Save ctrekker/32bed71928927cf9dfb87c2368eaf487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.14.3 | |
using Markdown | |
using InteractiveUtils | |
# ╔═╡ 732b9e4a-7852-45f3-8dfb-4840570f1006 | |
html""" | |
<style> | |
.requestBody, .responseBody { | |
font-size: 0.7em; | |
} | |
</style> | |
""" | |
# ╔═╡ acaab1c0-ae95-11eb-2113-ed072f61171b | |
md""" | |
# What you see is what you rest — HTTP Docs | |
This documentation is for users that wish to interact *directly* to the Pluto WYSIWYR HTTP interface *without* the use of a client library. It is recommended that you use a client library if possible. | |
### List of client libraries | |
As of now the following client libraries are available: | |
* [Julia](REST Docs.jl) (built into Pluto) | |
* [Node.js](https://github.com/ctrekker/pluto-rest) | |
* [Python](https://github.com/ctrekker/pyplutorest) | |
""" | |
# ╔═╡ 3353b1c1-911b-4b5a-8d26-32091b305a3d | |
md""" | |
## Serialization | |
To uphold interlanguage compatibility multiple serialization methods are supported. Native [Julia serialization](https://docs.julialang.org/en/v1/stdlib/Serialization/) is used for Julia → Julia communication via the Julia client library. For other clients which cannot serialize objects through Julia though, MsgPack is provided as an alternative serialization method. | |
Internally Pluto uses MsgPack with several extensions for all communication between the editor and the backend. These extensions provide functionality for serializing and deserializing arrays of a specific numeric precision. For example, native MsgPack does not support serializing Int16 (short) types without first converting them to a full integer type. The Pluto extensions address this issue with several MsgPack extensions, all of which should be implemented for a custom client library. | |
Refer to the [MsgPack.jl](https://github.com/fonsp/Pluto.jl/blob/main/src/webserver/MsgPack.jl) or [MsgPack.js](https://github.com/fonsp/Pluto.jl/blob/main/frontend/common/MsgPack.js) files from the Pluto source code for examples in Julia or JavaScript respectively. | |
### Headers | |
Serialization method is determined from client provided headers. The first, `Content-Type`, specifies what serialization method will be used for the request body. This tells Pluto how to *deserialize* the body. The next header, `Accept`, tells Pluto how to *serialize* the response. | |
**For MsgPack:** | |
``` | |
Content-Type: application/x-msgpack | |
Accept: application/x-msgpack | |
``` | |
**For Julia Serialization:** | |
``` | |
Content-Type: application/x-julia | |
Accept: application/x-julia | |
``` | |
""" | |
# ╔═╡ 7ff29b2c-1fef-4c2f-9ce6-2ce35c720c9d | |
html""" | |
<h2>Evaluation</h2> | |
<h3>URL Format</h3> | |
<pre> | |
POST http://<PLUTO_HOST>/v1/notebook/<FILENAME>/eval | |
</pre> | |
<div><b>PLUTO_HOST</b>: Base URL of Pluto server. Defaults to `localhost:1234` in Pluto as well as within each client library</div> | |
<div><b>FILENAME</b>: URL-encoded file name of the notebook to evaluate within.</div> | |
<h3>Request Body</h3> | |
<pre class="requestBody"> | |
{ | |
"inputs": { | |
"<in_variable_1>": <value_1>, | |
"<in_variable_2>": <value_2>, | |
⋮ ⋮ | |
"<in_variable_n>": <value_n> | |
}, | |
"outputs": [ | |
"<out_variable>" | |
] | |
} | |
</pre> | |
<b>NOTE</b>: Currently requesting only a single output is possible, but requesting multiple is likely to be implemented in the future | |
<h4>Example</h4> | |
<pre class="requestBody"> | |
{ | |
"inputs": { | |
"a": 3, | |
"b": 4 | |
}, | |
"outputs": [ "c" ] | |
} | |
</pre> | |
<h3>Response Body</h3> | |
<pre class="responseBody"> | |
{ | |
"<out_variable>": <out_value> | |
} | |
</pre> | |
<h4>Example</h4> | |
<pre class="responseBody"> | |
{ | |
"c": 5 | |
} | |
</pre> | |
""" | |
# ╔═╡ Cell order: | |
# ╟─732b9e4a-7852-45f3-8dfb-4840570f1006 | |
# ╟─acaab1c0-ae95-11eb-2113-ed072f61171b | |
# ╟─3353b1c1-911b-4b5a-8d26-32091b305a3d | |
# ╟─7ff29b2c-1fef-4c2f-9ce6-2ce35c720c9d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment