through which an application can make use of some features provided somewhere Web API : API by HTTP(S) requests In the case, features are provided by a web server B 2020 — 5 1 — 2020-11-09 – p.12/23
methods POST, GET, PUT, DELETE vs. CRUD (Create/Read/Update/Delete) CRUD represents the basic set of operations against a database Uniquely identify resources by URI Some demonstrations later Often returns results in the form of JSON (JavaScript Object Notation) B 2020 — 5 1 — 2020-11-09 – p.13/23
and state transitions An example of state transitions (state machines) (For example, on the web, page = state, and the page presents possible operations in that state as a set of buttons) A stack is a last-in, fast-out date store You can push data in, and pop data out A design would be like, POST to create a stack POST to push to the stack POST to pop from the stack GET to peek in the stack state PUT to update an item DELETE to delete the stack B 2020 — 5 1 — 2020-11-09 – p.14/23
sample API that provides stacks (requires Python3 and Flask) Run the simple web API server $ python stack.py See README to discover how to try At the end of this demo, we will try (5 − 2) × (3 + 4) B 2020 — 5 1 — 2020-11-09 – p.15/23