From 19638966bb9dcf2cb7181f7055ad93eb4d2b395f Mon Sep 17 00:00:00 2001 From: Essem Date: Sat, 27 Nov 2021 17:13:12 -0600 Subject: [PATCH] Add docs for API --- api/IMPLEMENTATION.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 api/IMPLEMENTATION.md diff --git a/api/IMPLEMENTATION.md b/api/IMPLEMENTATION.md new file mode 100644 index 0000000..c039bd6 --- /dev/null +++ b/api/IMPLEMENTATION.md @@ -0,0 +1,33 @@ +# esmBot Image API +The esmBot image API is a combined HTTP and WebSocket API running on port 8080. The API supports very basic authentication, which is defined on the server via the PASS environment variable and is sent from the client via the Authentication header in both HTTP and WS requests. + +## HTTP + +### GET `/image/?id=` +Get image data after job is finished running. The Content-Type header is properly set. + +## WebSockets +A client sends *requests* (T-messages) to a server, which subsequently *replies* (R-messages) to the client. +### Message IDs +- Rerror 0x01 +- Tqueue 0x02 +- Rqueue 0x03 +- Tcancel 0x04 +- Rcancel 0x05 +- Twait 0x06 +- Rwait 0x07 +- Rinit 0x08 + +### Messages +[n] means n bytes. +[s] means a string that goes until the end of the message. +[j] means JSON data that goes until the end of the message. +`tag` is used to identify a request/response pair, like `lock` in the original API. `jid` is used to identify a job. `job` is a job object. +- Rerror tag[4] error[s] +- Tqueue tag[4] jid[4] job[j] +- Rqueue tag[4] +- Tcancel tag[4] jid[4] +- Rcancel tag[4] +- Twait tag[4] jid[4] +- Rwait tag[4] +- Rinit max_jobs[2] formats[j]