Neal Magee, Ph.D.
Solution Architect, Research Computing
University of Virginia
Consuming APIs is an important part of retrieving specific, managed data sets. The ability to communicate with remote APIs using authentication and over a variety of methods and endpoints is a critical skill in the data science toolkit.
This lab extends on the hands-on portion of Lecture 04 by asking you to complete two additional tasks:
delete
the gist programmatically using Python3.You may write and test your Python code in any editor you choose - Visual Studio, Atom, nano, Notepad, PyCharm, Eclipse, etc. There is no expectation that you MUST use any specific editor.
py-post.py
to set up your Github token and ENV
variable. Visit https://github.com/ds3002/course/blob/main/practice/06-api-consume/py-post.py for details.bb222a9c6366411000485682eacce254
DELETE
method.'Accept'
with a value of 'application/vnd.github.v3+json'
is required. This
should be defined as simple key-value pairs, with a comma separation. So the
full line defining "headers" for your script should look like this:
headers = {'Accept': 'application/vnd.github.v3+json', 'Authorization': f'token {token}'}
py-post.py
example.Scroll below to see a working answer.
py-post.py
example.Scroll below to see a working answer.