Python Tutorial Exercise 3: Implement the govAPI_UK class
Write a
govAPI_UK implementation class which retrieves the following attributes from the UK government API:
-
familyName
-
givenName
-
gender
-
party
-
id (by extracting the number out of the about attributes)
We use the UK goverment API “data.parliament.uk” for retrieving government members.
-
The full API is described here:
-
The following request will return a JSON data structure of all members, which you have to transform:
-
The JSON is shown below
-
This formatted view can be achieved by using the online json formatter: https://jsonformatter.curiousconcept.com/
A hint:
-
When you have fetched the JSON and stored in a variable, loadedjson you have to iterate over the array found in
loaded_json[‘result’][‘items’]
Additional point:
-
Elaborate if the API used the paging mechanism
comments powered by Disqus