Sunlight Labs
Project of The Sunlight Foundation    
Read the labs blog

SunlightLabs API

Your API keys

people.getHCard

Get a HTML microformats hCard for a person

There are various sources of information about hCard, including http://microformats.org/wiki/hcard and http://en.wikipedia.org/wiki/HCard. hCards are useful as markup in themselves—this API method essentially returns a HTML business card for a person which can be plugged into a page—or it can be hidden in a page for automatic discovery, or one can use technorati's service that turns an hCard into a vCard and allows you to import them as contacts in your address book (Apple's Address Book, MS Outlook etc).

See a page of hCards for every member of congres [Warning: large & slow-loading]

Arguments

These are all $_GET parameters.

id (required)

The person's entity_id

apikey (required)

your individual API key

Example Call
http://api.sunlightlabs.com/people.getHCard.php?id=fakeopenID1
&apikey=23kj234kjb3kjbcl87ds

says give me a hCard for the person with entity_id "fakeopenID1".

Example Response

Note: This returns an HTML hCard.

photoRepresentative Neil Abercrombie 
Hawaii 1 (D)
U.S. House of Representatives
1502 Longworth HOB, Washington,DC,20515-1101,USA
(202) 225-2726
Congresspedia profile
Contact webform
Updated: April 23, 2007
which is
<div id='hcard-fakeopenID1' class='vcard'>
	<img style='float:left; margin-right:4px;height:100px' src='http://sunlightlabs.com/widgets/popuppoliticians/resources/images/Neilabercrombie.jpg' alt='photo' class='photo'/>
	<span class='n'>
		<span class='honorific-prefix'>Representative</span> 
		<a class='url fn' href='http://www.house.gov/abercrombie'>
			<span class='given-name'>Neil</span> 
			<span class='family-name'>Abercrombie</span> 
		</a>
	</span>
	<div class='role'>Hawaii 1 (D)</div>
	<div class='org'>U.S. House of Representatives</div>
	<a class='email' href='mailto:neil.abercrombie@mail.house.gov'>neil.abercrombie@mail.house.gov</a>
	<div class='adr'>
		<span class='street-address'>1502 Longworth HOB, </span>
		<span class='locality'>Washington</span>,
		<span class='region'>DC</span>,
		<span class='postal-code'>20515-1101</span>,
		<span class='country-name'>USA</span>
	</div>
	<div class='tel'>(202) 225-2726</div>
	<a class='url' href='http://www.sourcewatch.org/index.php?title=Neil_Abercrombie'>Congresspedia profile</a>
	<br/>
	<a class='url' href='http://www.house.gov/writerep/'>Contact webform</a>
	<br/>
	<abbr class='rev' title='20077-04-23'>Updated: April 23, 2007</abbr>
</div>

Error Codes

If there is an error: a plain text string will be returned:

1: entity not found

The entity_id was not recognized

100: invalid API key

The API key was invalid

101: API key not valid for this method

Not permitted to call this particular method with this particular API key