api.congress.gov
api.congress.gov copied to clipboard
How can I access the member container at the item level
I am trying to access the member container at the item level but get a key error. Here is the code I am using:
Get members information
response = requests.get(url) response_json = response.json() print(response_json["members"][0]["member"])
Always get key error, can someone please help me.
Hello. Thanks for your question. Could you please provide the request URL and screenshots of what you are doing/seeing? Thanks.
I do not see the "member" container
Thank you for bringing this to our attention. We’ve opened a bug ticket. It appears that the first item is always empty. Starting from 1 instead of 0 should work until the fix is in place.
I tried accessing starting at 1 but I do not see the 'member' key. Nor do I see the individual url for the congress person's website? Am I using the wrong endpoint?

Above is endpoint I am using
Ah, I think you might be misunderstanding the documentation. All of the available endpoints along with example requests & responses can be seen here: https://api.congress.gov/#/member/member_list
The documentation says this:
Each item in the members
array is a member
, but since it's not a JSON object, each item won't have a key of "member". Instead, each JSON object in the members
array is a "member".
I.e:
response_json["members"] // The entire array of members
response_json["members"][0] // One member from that array
Thank you for your response. This makes sense. My final question is, the endpoint https://api.congress.gov/v3/member?api_key=[INSERT_KEY], does not contain the url to the individual congress person's website? How can I pull that url from the API? Is there another endpoint that gives the url for each congress person's website? Thanks.
Hello. Thanks for your question. You cannot currently do this from the Congress.gov API. Here is a link to the documentation related to the member endpoint.