Closed weallwegot closed 6 years ago
no cookie storage from request to request. idk
With RESTful API, the idea is for any given request to be idempotent and independent of prior or upcoming requests. Sounds like the bot doesn’t quite fit this paradigm, but that’s OK. One idea is to provide the client with some kind of token that encodes the client state (or at least serves as a key to the client’s state on the server). The client would then be expected to include this token in any future requests, allowing the server to respond accordingly.
What do you think of a contract such as the following?
METHOD POST
URI /api/v1
By versioning the API, we can introduce new compatibility-breaking changes without disrupting existing clients.
REQUEST { "action": String, "data": { ... } }
"action" is an enum of actions supported by the API. For now, we would just support the action "CONVERSATE". "data" can be anything (or nothing) required for the action to be carried out. "CONVERSATE" would require "data.query" as a String.
Encoding requests in a common envelope has many advantages. In some ways, it makes life easier for the client while also simplifying logging requests (should we so choose).
RESPONSE { "meta": { "code": 200 }, "data": { ... } }
Containing every response in a common envelope results in a predictable set of keys that the client interacts with.
Im gonna implement this using a database linked to some UUID
change from get url request params to POST JSON with requests
http://stackoverflow.com/questions/22273671/flask-restful-post-json-fails
change force parameter to false and silent parameters in request.get_json() method so that the request is required to also have a header that specifies "application/json"
From @weAllWeGot on January 26, 2017 5:29
http://flask-restful-cn.readthedocs.io/en/0.3.5/quickstart.html#a-minimal-api
_Copied from original issue: weAllWeGot/kbai_chatbot3#36