GovTrack.us

RDF and SPARQL Endpoint

Most of the data that powers this site is archived in RDF, the data format of the Semantic Web. It's around 25 million triples, covering about 15 years of legislative information. The vocabularies used in the data include FOAF, vCard, and several schemas I created. The RDF data is a dump of the source XML data.

There are a few ways that you can access the data. The first is by downloading the RDF files, which are in a mix of XML and N3 formats. You can query the data store using SPARQL, as described below. The entities in the data set are published as Linked Data, so if you find a URI you can plug it into your browser and trace through the data that way. Some starting points are on the SPARQL page. There are also <link> tags on many pages that indicate the RDF URI for the resource being described.

The RDF bulk download files are updated nightly though the SPARQL endpoint is not updated regularly at the moment. I don't really recommend you use them for anything serious. The schema is subject to change.

SPARQL Endpoint

The SPARQL endpoint is a combined endpoint for various RDF data I play with. It answers queries about 1 billion triples, mostly about U.S. Census data (see rdfabout.com), but also the GovTrack data.

The SPARQL engine's base URL is http://www.rdfabout.com/sparql, following (or trying to follow) the SPARQL Protocol spec. The SPARQL engine is Ryan Levering's engine for SESAME, plus my SemWeb library for C#. The data store is persisted in MySQL. Responses are limited to 1000 rows in the hopes that having this public won't break anything.

Enter a SPARQL query below:

Display As:

Notable Entities

Here are some notable URIs in the data:

  • Sen. John McCain: <http://www.rdfabout.com/rdf/usgov/congress/people/M000303>
  • H.R. 867 (a bill in congress): <http://www.rdfabout.com/rdf/usgov/congress/109/bills/h867>

Useful Namespaces

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dc:  <http://purl.org/dc/elements/1.1/>
PREFIX dcterms:  <http://purl.org/dc/terms/>
PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>
PREFIX foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX time: <http://pervasive.semanticweb.org/ont/2004/06/time#>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>

PREFIX usgov: <http://www.rdfabout.com/rdf/schema/usgovt/>
PREFIX pol: <http://www.rdfabout.com/rdf/schema/politico/>
PREFIX vote: <http://www.rdfabout.com/rdf/schema/vote/>
PREFIX bill: <http://www.rdfabout.com/rdf/schema/usbill/>
PREFIX sec: <http://www.rdfabout.com/rdf/schema/us/sec/>
PREFIX seccik: <tag:govshare.info,2005:data/us/sec/>
PREFIX census: <http://www.rdfabout.com/rdf/schema/census/>
PREFIX census2: <http://www.rdfabout.com/rdf/schema/census/details/>

Example Queries

Try out these examples:

What bills has John McCain sponsored:

PREFIX people: <http://www.rdfabout.com/rdf/usgov/congress/people/>
PREFIX bill: <http://www.rdfabout.com/rdf/schema/usbill/>
PREFIX dc:  <http://purl.org/dc/elements/1.1/>
SELECT * WHERE { [] dc:title ?billtitle; bill:sponsor people:M000303; bill:congress "109" . }

What's the population of the state represented by every current senator:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc:  <http://purl.org/dc/elements/1.1/>
PREFIX foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX usgov: <http://www.rdfabout.com/rdf/schema/usgovt/>
PREFIX pol: <http://www.rdfabout.com/rdf/schema/politico/>
PREFIX census: <http://www.rdfabout.com/rdf/schema/census/>
PREFIX time: <http://pervasive.semanticweb.org/ont/2004/06/time#>
PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>
SELECT ?name ?statename ?population WHERE {
	?person foaf:name ?name ;
		pol:hasRole [ time:to [ time:at ?enddate ] ;
			pol:forOffice [ pol:represents ?state ] ] .
	?state rdf:type usgov:State; dc:title ?statename;
		census:population ?population .
	FILTER(?enddate = "2006-12-31"^^xsd:date || ?enddate = "2008-12-31"^^xsd:date || ?enddate = "2010-12-31"^^xsd:date) .
}
ORDER BY ?population

Get a table of how senators voted on all of the Senate bills in 2009-2010:

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bill: <http://www.rdfabout.com/rdf/schema/usbill/>
PREFIX vote: <http://www.rdfabout.com/rdf/schema/vote/>

SELECT ?bill ?voter ?option  WHERE {
  ?bill a bill:SenateBill .
  ?bill bill:congress "111" ;
    bill:hadAction [
      a bill:VoteAction ;
      bill:vote [
        vote:hasOption [
          vote:votedBy ?voter ;
          rdfs:label ?option ;
        ]
      ] ;
   ] .
}

Find pairs of House and Senate bills that have the same title (which is actually fairly common):

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX bill: <http://www.rdfabout.com/rdf/schema/usbill/>

SELECT ?title ?hbill ?sbill WHERE {
    ?hbill rdf:type bill:HouseBill ; bill:congress "109" .
    ?sbill rdf:type bill:SenateBill ; bill:congress "109" .
    ?hbill bill:hasTitle [ rdf:value ?title ] .
    ?sbill bill:hasTitle [ rdf:value ?title ] .
}

Get a table to correlate the population and median income of the state represented by a senator and his/her vote on the economic stimulus bill:

PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
#PREFIX dc:  <http://purl.org/dc/elements/1.1/>
#PREFIX foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX vote: <http://www.rdfabout.com/rdf/schema/vote/>
PREFIX pol: <http://www.rdfabout.com/rdf/schema/politico/>
PREFIX census: <http://www.rdfabout.com/rdf/schema/census/>
PREFIX census2: <tag:govshare.info,2005:rdf/census/details/samp/>
PREFIX time: <http://pervasive.semanticweb.org/ont/2004/06/time#>
PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>
SELECT ?option ?population ?medianincome WHERE {
  <http://www.rdfabout.com/rdf/usgov/congress/111/senate/votes/2009-61>
      vote:hasOption [
        vote:votedBy ?person ;
        rdfs:label ?option ;
      ] .
   
  #?person foaf:name ?name .
  ?person pol:hasRole [
      time:to [ time:at ?enddate ] ;
      pol:forOffice [ pol:represents ?region ] ] .
  #?region dc:title ?regionname .
  ?region census:population ?population .

  ?region census:details [
    census2:population15YearsAndOverWithIncomeIn1999 [
      census2:medianIncomeIn1999 ?medianincome
    ]
  ] .

  FILTER(?enddate >= "2010-12-31"^^xsd:date) .

}
ORDER BY ?option