- HTTP protocol
- What is an API
- Tutorial with Airvisual's API
- Task 1a: Use the Twitter API to retrieve tweets
or
-
Task 1b: Use the Github API to manage your account
-
Task 2: Build an API with the jupyter-kernelgateway. The worksheet in the handout had a wrong tasklist. Please, complete this task according the following instructions!
- Create an API with 4 endpoints
- /help returns with the help/usage of the other 3 endpoints
- 1 endpoint, where one needs to use arguments (key/value pairs)
- 1 endpoint, which returns some data in json format. Either the json should contain a description of what the data is or it is defined in the /help
- 1 endpoint, which returns an image or file (plot, graph etc). It's type should be defined in /help
- You can use any dataset for this task. Here is a list of some real life data:
- Create an API with 4 endpoints
From Task 1 choose only a, or b,!
For Task 2 Everyone should delete the container and start a new one, because the python packages were updated. Those who work on any other device they need to have the following package installed:
- jupyter_kernel_gateway==2.1.0
HTTP functions as a request–response protocol in the client–server computing model https://www.ntu.edu.sg/home/ehchua/programming/webprogramming/HTTP_Basics.html
You can only send text via the api. This data needs to be downloaded and converted back.
curl https://kooplex-edu.elte.hu/notebook/wfct0p-dataexplvisu/report/img > img.png
And this is how you convert it back to png
import base64
import json
with open("img.png",'r') as i:
imgstr = json.loads(i.read())
img_encoded = base64.decodebytes(imgstr.encode())
# Then maybe write it to a file
with open("t.png",'wb') as t:
t.write(img_encoded)