[HN Gopher] Congress.gov API
___________________________________________________________________
Congress.gov API
Author : ElevenLathe
Score : 342 points
Date : 2022-09-08 18:40 UTC (4 hours ago)
(HTM) web link (api.congress.gov)
(TXT) w3m dump (api.congress.gov)
| smashah wrote:
| I hope one day we move government policy and legislation onto a
| git-like version control system so we can see the history of law
| itself.
| anigbrowl wrote:
| Wikiocracy > representative government
| pphysch wrote:
| If a "wikiocracy" is where shadowy, unaccountable hierarchies
| manipulate policy to their will while pretending to be
| democratic about it, then yeah we live in one but I'm not sure
| it's better than a representative system.
| princevegeta89 wrote:
| BTW, we are missing an API to delete congress people by name
| lapetitejort wrote:
| Why does it matter if a congress person can be deleted when
| party_affiliation seems to be a protected field?
| spullara wrote:
| This would be way better in a database than as an API.
| aabhay wrote:
| API can have predictable access patterns.
| TheLocehiliosan wrote:
| This is pretty cool, but...
|
| Authentication seems to be done with a query string ?api_key=KEY
| instead of some kind of standard header.
|
| Also, there is a query string "format" for changing the output,
| ?format=json. Instead of using the Accept header :/
| alxlu wrote:
| I was able to get it working with the 'X-Api-Key' header and it
| seemed to give back JSON by default without adding anything to
| the query string.
| simonw wrote:
| I think these are reasonable design decisions.
|
| Headers are harder to use than query string parameters. You
| can't start poking around in an API as easily using just a web
| browser if the API requires authentication and accept headers.
|
| The downside of query strings for API keys is that they can
| inadvertently be exposed by log files. For this API, where the
| API key appears to be there purely for analytics reasons, I
| don't think that risk is particularly bad.
| TheLocehiliosan wrote:
| I feel like there's all sorts of disappointing design
| decisions.
|
| * All of the endpoints are singular, but then /summaries is
| plural for some reason
|
| * You can enumerate the congresses, but non of the congress
| representations have a value which represents the numeric ID
| that should be used on other requests. Unless you request the
| congress data using that number, and then it does include it.
|
| Oh well, hopefully it improves and becomes more consistent
| over time.
| fnordpiglet wrote:
| I was looking at the control plane api but the campaign
| contribution metering rates are extraordinary and require
| lobbyist api key credentials.
| hitpointdrew wrote:
| This is awesome! Now if we can just get congress to use git for
| actually writing the bills.
| dirtsoc wrote:
| they tried that once. It was meme'd into oblivion...
|
| https://www.theverge.com/2022/6/23/23180813/cryptocurrency-b...
| bendur_ wrote:
| Nice start. Too bad there isn't a great way to filter data like
| members by status, state/district, congress number, etc
| [deleted]
| insane_dreamer wrote:
| cool; had no idea this existed. Would be great to have each bill
| available as a git repo so that you can see the bill's draft
| history as it goes through revisions (with annotations as to the
| authors of the changes).
| sand500 wrote:
| I think there was a post on here where a city's laws were hosted
| on git or some other version control.
|
| It's a intriguing hypothetical to think about. Imagine if all the
| discussion around a bill had to be as code review comments.
| beauzero wrote:
| Utah https://github.com/divegeek/utahcode
| sand500 wrote:
| Thanks!
| codelord wrote:
| I wish /member/fire was implemented.
| nikodunk wrote:
| This is very cool. How long has this been around?
| [deleted]
| smeyer wrote:
| It's pretty new https://blogs.loc.gov/law/2022/09/introducing-
| the-congress-g...
| https://github.com/LibraryOfCongress/api.congress.gov
| mikrl wrote:
| I see no endpoints use the POST verb
| lekevicius wrote:
| New API, and already mixes camelCase (committeeReport) and snake-
| case (house-communication).
| ianrahman wrote:
| And already there's a discussion on the matter:
| https://github.com/LibraryOfCongress/api.congress.gov/issues...
| hosh wrote:
| I remember there used to be (still there?) of this data marked up
| with semantic web.
| Cyberdog wrote:
| cookie_monsta wrote:
| Hmmm. Suspiciously normal. You're on the list, buddy.
| ratg13 wrote:
| For anyone wondering, there is no e-mail validation to get an API
| key.
|
| You can enter whatever you want in the form.
| no-dr-onboard wrote:
| Excellent note.
|
| benign use: love the fact that they are going to allow me to
| add a + address
|
| malicious use: consider testing for injection attacks :)
| cmeacham98 wrote:
| What injection attacks? It seems like the email just goes to
| /dev/null currently.
| OJFord wrote:
| Disappointed (but not surprised!) there's no `POST /amendment` or
| `PATCH /bill/:id/:para` etc., with copious notes on auth.
| toddwprice wrote:
| :-) I figured someone would beat me to this.
| obblekk wrote:
| I have to say, this is cool and surreal in some way.
|
| It's just surreal to think of international treaties as being
| objects with a "last updated time."
|
| Given the massive human apparatus constantly parsing this
| information from Capitol Hill, I'm not sure what the use-case is
| for an app, but nonetheless, it's cool.
|
| Now... if we could get this for every state and county
| legislature, that would enable some interesting use cases to
| track parallel legislative initiatives (usually advocated by
| corporations / non-profits).
| dheera wrote:
| Now if only we could have an API to vote ...
| bloppe wrote:
| The fact of the matter is: paper is still basically the most
| advanced voting technology around (from the perspective of
| auditability, which is crucial)
| Aunche wrote:
| Just release make everyone's vote semi-public. You can look
| up what you voted for with a combination of your name +
| position/ballot-measure + password that's passed through a
| one-way hash, which generates anonymous voter ID. You can
| file a complaint what was counted doesn't match who you
| remember voting for.
| sgammon wrote:
| votes and voter registration is already semi public.
| campaigns get access to voter rolls for outreach, for
| instance.
| bloppe wrote:
| _You can file a complaint what was counted doesn 't match
| who you remember voting for._
|
| Impossible to prove. You don't want people changing their
| votes. People wouldn't accept results if they change
| after the fact.
| e_i_pi_2 wrote:
| Yeah I took a class that talked about this - most people
| agree that what you'd end up with is companies or
| individuals forcing you to disclose a hash to prove you
| voted the way they wanted. Votes kinda need to be
| unrecoverable at an individual level for this. There's
| some cool research on "homomorphic encryption" if you
| want to learn more - it basically opens up the data in
| aggregate for analysis without being able to disclose
| information about any individual record in the data, but
| it's hard to pull off in practice
| Aunche wrote:
| > Yeah I took a class that talked about this - most
| people agree that what you'd end up with is companies or
| individuals forcing you to disclose a hash to prove you
| voted the way they wanted.
|
| That's what the one-way hash is for. If you're forced to
| provide a password beforehand, you can provide extra
| bogus passwords that cast ballots for both sides. The
| system can allow you to do this an arbitrary number of
| times.
|
| As far as paper ballots go, nothing stops someone from
| bullying you into taking a video of you voting and
| dropping it into the ballot box.
| meowkit wrote:
| Problem is you are incentivizing people to sell their
| vote or to threaten others to vote a specific way
| (abusive spouse wants to verify their SO voted a certain
| way).
|
| The only info we should provide electronically is that
| your vote was counted at all. Direct value verification
| would have to be done in person and under supervision.
| leesalminen wrote:
| With widespread mail-in voting an abusive spouse could
| just fill in the ballot and drop it in the mailbox. No
| need to verify your spouse's actions if you can just do
| it yourself.
| cookie_monsta wrote:
| Cue the obligatory xkcd...
| Shared404 wrote:
| For those unfamiliar: https://xkcd.com/2030/
| sofixa wrote:
| Way too complicated to implement securely, anonymously and
| transparently. Going physically somewhere to click on a
| button after a human identification is probably as
| technologically advanced as we're going to get in the near
| future.
|
| I mean sure, with the EU's NFC chips in passports and ID
| cards there can be an app that compares that to a 3D selfie
| (there are already apps that do that for lesser government
| services), but the risks associated in getting it wrong are
| still too great. Not to mention the lack of transparency
| which is paramount for a healthy democracy.
| throw_nbvc1234 wrote:
| It'd be interesting to explore transparent/public voting
| combined with an in person way to correct/lock_in your
| vote. Instead of having a voting day let people vote over a
| month and be able to lock in their vote in person at any
| time.
|
| Maybe not use it for elections but maybe for polling on
| issues or a replacement for petitions and/or referendums.
| Enabling some aspects of direct democracy especially at
| local levels. But i think this would need to be public or
| overly transparent to enable people to trust the outcome or
| become aware of any attacks on the system.
| permo-w wrote:
| Estonia manages it
| VWWHFSfQ wrote:
| There's a pretty big difference in scale between Estonia
| and USA.
| jimhi wrote:
| If Estonia had the GDP, political influence, or military
| of the USA it might not hold up to the same level of
| attacks.
|
| It also helps that their population and schooling system
| prioritizes coding and technical literacy.
| nonethewiser wrote:
| Seriously?
| o_1 wrote:
| let's all make an bot to read bills and vote on our behalf.
| seaourfreed wrote:
| GREAT, BUT! We need an API on who wrote which parts of the
| bill. Find lobbyists who wrote parts. Find when there is an
| evil part (where lobbyists get congress to sell out), and we
| need to find out WHICH congress person put it in there.
|
| We need to track the evil parts of bills to the congress person
| who is the sell out for lobbyists (and the corporations beind
| them)
| ElevenLathe wrote:
| For pieces that were added as amendments, it is at least
| possible to determine who proposed the amendment. Instances
| where the as-written initial bill is written on K Street will
| probably always be impossible unless Congress pass absurdly
| strict sunlight laws with teeth (i.e. make it illegal for
| congresspeople to have substantive meetings without
| livestreaming them) that inconvenience themselves.
| clairity wrote:
| yah, for that, we'd need complete social graphs for public
| servants, which would quickly run afoul the congressional
| staffs' civil liberties, because they'd try to hide as much
| as possible behind other people. you'd need that to
| appropriately apportion attributions back to the public
| servant.
|
| i'd be ok pushing for a legal carve-out for this social
| graph however, as i'd posit that greater governmental
| transparency overrides the potential encroachments of the
| ~tens/hundreds of thousands of partisans and lobbyists
| (<0.1% of population; though slippery slope could be
| invoked here). you'd start with staffers and move out to
| anyone paid directly by the office and their affiliated
| political organizations, then move to large donors and
| their PACs. obviously the current supreme court would try
| to block this as an antecedent to the _citizen 's united_
| case.
| ElevenLathe wrote:
| Oh yeah it would definitely be in the interests of the
| ruled class. Unfortunately, since it is bad for the
| ruling class, we won't get it.
| TOMDM wrote:
| git grep -n 'healthcare' | perl -F':' -anpe '$_=`git blame
| -L$F[1],+1 $F[0]`'
| zeruch wrote:
| Until you define a method/definition of "Evil" you're out of
| luck. What you can do, is use this to track changes, and then
| match it to a corpus of other data to get a better fidelity
| on what may influence legislation; financial transactions,
| public statements and where they were made, state visits,
| litigation, etc. Much of it in the public eye, hence
| scrapable and able to be put into a data
| lake/warehouse/cabana/dilapidated shack, and analytics
| applied to it. From there you may find emergent phenomena.
| cyberge99 wrote:
| Isn't this what opensecrets.org does?
| tcmart14 wrote:
| Just need a github for legislation. Want to see who added
| what subsection? Check the commit history.
| e_i_pi_2 wrote:
| We do have this in the US! All laws should show who wrote
| them, when, who approved it, etc, we just don't have a
| great API for programs, and moreso we don't have the public
| appetite to consume it
| CH1jZci6jV wrote:
| I use to work in Congress. 100% of it is written by
| lobbyists.
| atlasunshrugged wrote:
| This is categorically false. If you want an understanding
| of what life in Congress is like, I highly recommend Mark
| Strand's "Surviving Inside Congress"
| xapata wrote:
| It's not categorically false, just false. Some phrases
| written by lobbyists survive in some bills.
| [deleted]
| [deleted]
| seaourfreed wrote:
| We need WHICH congress-person approved it getting into the
| bill. We have to VOTE OUT the congress-person linked to the
| evil riders to bills (Budget bills, Defence bills, etc.)
| sgammon wrote:
| lots of this data exists. campaign finance and lobbying
| reports help shine a light on this behavior.
| matthoiland wrote:
| I'd love to see a git history for our current US legislation
| e_i_pi_2 wrote:
| You're in luck, someone recreated the constitution in git
| with the history of edits
|
| https://github.com/jessekphillips/usa-constitution
|
| Edit: just noticed the dates aren't accurate, but still
| interesting and the authors are accurate
| judge2020 wrote:
| Can git do pre-1970 dates?
| progval wrote:
| The file/wire format can, but the official implementation
| doesn't handle it well. There is some work in progress to
| make it work, for this kind of historical work.
| quadratecode wrote:
| There is a project doing exactly this for German law.[1] I
| also once cobbled together a rather primitive Python script
| which commits Swiss federal law as MD-file into a repo
| through GitHub actions.[2]
|
| [1] https://github.com/bundestag/gesetze
|
| [2] https://github.com/quadratecode/ch-law-tracker
| tstrimple wrote:
| Yes. We need git-blame here.
| mortdeus wrote:
| you are arguing for Git for legislation. not an api.
| naikrovek wrote:
| i'd be happy with voting information for each bill that was
| voted on by either house or senate.
| sc90 wrote:
| _Find lobbyists who wrote parts_ Is this usually noted on the
| document?
| sgammon wrote:
| unfortunately, no. but other records can and do illuminate
| such behavior.
| cjpearson wrote:
| It's a common misconception that increasing transparency
| reduces the power of lobbyists, when it actually does the
| opposite. [0] In short, the average voter doesn't care enough
| to find out who added a specific line to a bill, but
| lobbyists care a lot and they use the additional access to
| monitor and influence legislators. Legislator accountability
| is increased with more transparency, but they become more
| accountable to lobbyists than to their constituents.
|
| There needs to be a balance. A democracy that operates
| completely in the dark isn't much of a democracy, but
| Congress currently has the problem off too much rather than
| too little transparency.
|
| [0]
| https://congressionalresearch.org/TransparencyProblem.html
| zhynn wrote:
| You might also find this academic paper interesting:
| https://philpapers.org/go.pl?id=NGUTIS&aid=NGUTISv1
|
| The title is a bit click-bait-y, but the argument is sound,
| I think. Forcing transparency changes how people do their
| work, especially what indicators of success they choose to
| focus on (which may be easy to relate, but bad indicators
| of success - like GPA).
|
| Transparency does not automatically grant accountability.
|
| I don't think we have a good handle on this problem, and we
| make the situation worse by assuming that transparency will
| solve the problems of corruption and government
| accountability.
| cwkoss wrote:
| I am skeptical, this sounds like 'trickle-down economics'
| where the theory is internally cohesive but the conclusions
| don't actually line up with reality.
|
| Seems like the page you linked is an anti-trasparency
| advocacy org, what makes you trust them? Is there any data
| to back up this assertion?
| whatshisface wrote:
| There is, but you'd be best off it you didn't see it.
| sgammon wrote:
| fiscalnote.com govtrack.us opensecrets.org openstates.org
| ElevenLathe wrote:
| This actually also exists in https://openstates.org/, but it's
| a separate nonprofit, not a government service.
| sailplease wrote:
| If anyone is interested I setup the bills and committee endpoints
| in a google sheet, makes it easy to get the data in one spot,
| manage pagination, etc.. You can simply copy the spreadsheet and
| it will copy the api connectors, just enter your api key, you can
| easily add other endpoints, change query params, etc.
|
| Pagination seems to be limited to 250 on the endpoints and some
| of the data sets are quite large so I set a limit on pagination
| of 10 pages, if you want all the bills from all time, prepare to
| wait.
|
| Full disclosure it uses a free addon myself and my cofounders
| created to easily push any api data into a google sheet. I just
| find it useful to play around in a spreadsheet very quickly vs
| setting up a db.
|
| spreadsheet is here:
| https://docs.google.com/spreadsheets/d/1amnbqb_J9W2r-XaVsrue...
| davidy123 wrote:
| I hope they soon provides schemas rather than just separate
| human-only markdown description of fields. Both XML and JSON have
| methods for this using Linked Data.
|
| For JSON-LD, this would basically look like this (from
| https://json-ld.org/spec/latest/json-ld/#the-context):
| { "@context": { "name":
| "http://schema.org/name", - This means that 'name' is shorthand
| for 'http://schema.org/name' "homepage": {
| "@id": "http://schema.org/url", - This means that 'homepage' is
| shorthand for 'http://schema.org/url' } ...
| }, ... data part using name, homepage, etc }
|
| Once you have stable places for information (identifiers), you
| can start building a real web as described by the semantic web,
| by bundling schemas with the data you can freely use information
| with human and machine understanding, until then you've got a
| muddle.
| simonw wrote:
| I wonder why this has API keys at all? Maybe so they can keep
| logs of who is using the API and for what purpose.
| phantomread wrote:
| It also helps when trying to put limits on greedy users or
| maintain a ban-list. Attribution is also important, like you
| said. Granted, an abusive user could just keep creating new
| keys, but if they require something like email verification
| then it's a little bit costlier to circumvent than nothing.
|
| EDIT: Based on other comments, there's no email verification.
| cmeacham98 wrote:
| There isn't currently, but they could add whatever
| requirements to generate new keys in the future they want. If
| they didn't have keys that would break every existing client.
| maxmcd wrote:
| Is the OpenAPI json/yaml spec not available? Seems clear from the
| UI that this is likely using the API, but I can't find an
| endpoint that returns the spec.
|
| edit: oh, it's just inline within the html source, strange
| 11thEarlOfMar wrote:
| Maybe I missed it while glancing through, but does this return
| the actual voting by congressperson for each bill?
| sgammon wrote:
| I don't think so, but several other sources do provide
| structured roll call data, which is what this is called.
| acaloiar wrote:
| Roll call vote data is available from ProPublica's Congress
| API: https://projects.propublica.org/api-docs/congress-api/
|
| ProPublica took over a number of the Sunlight Foundation
| (Sunlight Labs') API projects:
| https://sunlightfoundation.com/2016/11/01/sunlight-labs-upda...
| naikrovek wrote:
| don't see it.
|
| i would like to see a vote summary, similar to what you see on
| C-SPAN after a vote.
| efitz wrote:
| Cool idea.
|
| Some suggestions for missing interfaces:
|
| DELETE/Representative POST/Bill
| drstewart wrote:
| There's a joke somewhere about it desperately needing to support
| PATCH methods
| goatcode wrote:
| The delete verb would be preferable, imo.
| mindcrime wrote:
| DELETE /congress HTTP/1.1 Host: api.congress.gov
| Accept-Language: en HTTP/1.1 200 OK
|
| Wouldn't that be something?
| [deleted]
| [deleted]
| ZeWaka wrote:
| Wouldn't it be a 204 Not Found? ;)
| dhritzkiv wrote:
| 204 would be No Content
|
| 404 would be Not Found
| gennarro wrote:
| Most government departments have some form of api. Many use
| openapi (swagger) and have design decisions like this one,
| excepting the major APIs, like FDA. They enable projects like
| https://ofr.report/ or https://sec.report/
| showerst wrote:
| If you're interested in bill data, open states maintains a
| federal scraper that outputs into a common format with our
| scrapers for all 50 states as well.
|
| https://github.com/openstates/openstates-scrapers
|
| It uses the GPO's api though, not this one.
| devmunchies wrote:
| Seems like a miss that this is using google fonts instead of the
| font made by the govt https://public-sans.digital.gov/
| joecool1029 wrote:
| It's also using Cloudflare and set up to block Digitalocean
| ip's outright from browsing anything at congress.gov and its
| subdomains.
| CreepGin wrote:
| Sorry, why Digitalocean ip's? Anti-bots and DDOS? And, how do
| you even find out about this?
| flatline wrote:
| Is this not just the default swagger output?
| [deleted]
| logicallee wrote:
| This is a very good start! What would close the loop is an
| endpoint to serve legally binding notices.
|
| Consider someone with a legally recognized special need necessary
| for some bodily function.
|
| For example, someone in a wheelchair wants to use a bathroom. Or
| two people who can't speak want to get a condom by communicating
| it non-verbally, by pointing at it or writing their request down
| on a piece of paper, but whose requests are ignored whereas
| speaking customers have their needs met.
|
| In code you can just try: try usebathroom()
| catch cant
|
| or try buycondomnonverbally() catch
| cant
|
| The exact function call that makes it fail becomes obvious.
|
| With an endpoint, you could apply the legal API to it and demand
| that the proprietor provide legally mandated accommodations until
| the failing function succeeds for the special case.
|
| It's hard to deny you exist if there is a parking lot full of
| employees and you can serve them a notice by GPS lookup.
|
| If someone made _that_ service it would be an "oh shit, they
| _actually_ mean it " moment for every unaccountable black box
| Establishment that skirts its accessibility obligations.
|
| It would instantly improve the world for everyone.
| ethbr0 wrote:
| Was not expecting Swagger... neat!
|
| https://en.m.wikipedia.org/wiki/Swagger_(software)
| djbusby wrote:
| Don't they call it OpenAPI now?
| o_1 wrote:
| yes
| jzig wrote:
| Depends on the version :P
| omginternets wrote:
| Hmm... all the useful endpoints are returning a 402 status.
| jonas-w wrote:
| Maybe didn't pay your taxes?
|
| https://www.webfx.com/web-development/glossary/http-status-c...
| adolph wrote:
| I havn't seen this before but the .pagination.next url value is a
| great convenience. On the other hand, the OpenAPI documentation
| doesn't explicitly mention offset and limit for paginated
| services even though it lists format for each service.
| jq '.pagination.next ' member.json "https://api.data.gov/c
| ongress/v3/member?offset=20&limit=20&format=json"
| AndreasHae wrote:
| >I havn't seen this before but the .pagination.next url value
| is a great convenience
|
| Reminds me of HATEOAS [0]. Definitely makes it easier to browse
| using a REST client.
|
| >On the other hand, the OpenAPI documentation doesn't
| explicitly mention offset and limit for paginated services even
| though it lists format for each service
|
| I could imagine that they use some kind of middleware for
| pagination which leads to it not being explicitly included in
| the OpenAPI spec, especially if they generate it from their DTO
| classes instead of going API first.
|
| Also, am I the only one who thinks specifying the expected
| response format via query param is weird and they should just
| use the Accept header instead? Eh, I guess it's better
| supported by OpenAPI.
|
| [0] https://en.wikipedia.org/wiki/HATEOAS
| simonw wrote:
| Looks like the page size limit is 250 so you can fetch records
| like this: https://api.congress.gov/v3/bill?for
| mat=json&api_key=...&limit=250
| smrtinsert wrote:
| Incredible.
| todsacerdoti wrote:
| The Congress.gov API has been added to Pipedream -
| https://pipedream.com/apps/congress-gov/.
|
| Please share what you build!
___________________________________________________________________
(page generated 2022-09-08 23:00 UTC)