ICT-4540 Homework 7
Purpose
What to Hand In
You may replace your API key with the phrase "api-key-goes-here" for your submission.
Problems
- Setup
-
Register as a ProPublica developer at projects.propublica.org/ api-docs/congress-api/ This will give you the ability to create API keys to obtain certain information. -
Create an API key for the Congress API. You will need to name your application (perhaps ICT4570 HW7?) -
You can use the API Console (lower left link) to test the call, using your developer key, as created in the previous step. We will use the Member List query and the Member Vote Positions query in this exercise. -
Determine which representative you will use. If you are in the US, you may want to select your local representative. If not, please pick one of interest to you, or use Denver's representative, Diana DeGette. -
As of Fall, 2019, the current House is number 118, and Denver's representative is in District 1 of Colorado (CO)
-
- XML Approach (Constructed so each step can be separately tested before moving on to
the next step)
-
Create an XQuery file, and set variables for your developer key, the congress id, the state, and the district you selected above -
Construct the URL to request Member List for that congress id, state, and district as an XML document and assign to a variable (test by copying the returned URL and pasting it into a browser). -
Execute the query and assign the result to a variable (test by returning the variable) -
Create a variable to represent the unique ID of the selected representative. You may wish to consult the browser result from the console API from problem 1 to see how to navigate to the unique ID. This variable will be needed to construct the next query below. -
Construct the URL to request the selected Representative's Member Vote Positions as an XML document. You will need to the member's unique ID, as created above, to construct the URL. -
Execute the query and assign the result to a variable -
Now we begin to play with the return value. Return an HTML container fragment, perhaps a section, and create display elements for the basic member information returned (name, birthday). -
Optional: Add the most recent party, chamber, congress, state, and district -
Create a table for each Congress the member was in, ordered numerically by congress, showing the congress number, and the percent they voted with their party -
Optional: Compute and display the year range for each term -
As a stretch goal for the very advanced student, display an SVG graph of these values, with the horizontal axis by election year, and the vertical axis by % (zero to 100).
-
- Extra: JSON Approach
-
This problem has the same steps as the previous problem except that you will request JSON data from the API instead of XML documents. This would allow JavaScript manipulation of the data, as well as using the XQuery approach.
-
Notes
-
Please contact the instructor with any problems in following these steps above. -
It is recommended that you test each step separately, ensuring it is as expected before continuing. The ProPublica Developer API can help spot check your accuracy. -
The concat
function can be used in XQuery to create a new string out of different pieces. -
The XQuery processor can capture the result for you as you work.
Evaluation
Criteria | Weight |
---|---|
XQuery for XML data and display | 60% |
Generated web page for XML data and display | 20% |
Screenshot for XML data and display | 20% |
Option parts of problem 2 | Extra 10 points for each |
XQuery and JavaScript for JSON data and display, resulting web page, and screenshot. | Extra 60 points |