As stated in the note from the Sunlight Foundation′s Board Chair, as of September 2020 the Sunlight Foundation is no longer active. This site is maintained as a static archive only.

Follow Us

Tag Archive: congressapi

New Districts in Sunlight Congress API

by

Good news if you were one of the users waiting on our Congress API to support the newly drawn congressional districts! As of today it is possible to pass the districts=2012 flag to the Congress API's districts.getDistrictFromLatLong method to instruct the API to return the district in effect for the 2012 elections.

As you may recall, the data wasn't previously available in a uniform format but thanks to a recent data release from Census.gov we were able to get this data loaded, with days to spare until the election.

The default will remain to return the districts in effect for purposes of representation until the swearing in of the 113th Congress in January 2013 at which point the temporary districts=2012 flag will be retired (but it will be safe to continue to pass the parameter indefinitely).

This change does not yet impact other Sunlight API methods. The Open States district methods and the ZIP code related methods will be updated as that data is available, as described in our last update.)

Continue reading

Introducing python-sunlight

by

Hello, World!

We'd like to welcome python-sunlight into the most excellent family of open-source projects maintained by Labs. This particular project aims to unify and normalize the Sunlight APIs into a single Python library that's easy to understand, use, and fun to play with.

This library currently supports our Congress API, Open States API, and Capitol Words API. As such we're deprecating the old python-sunlightapi and python-openstates libraries. They'll still work but will no longer be receiving updates, so switching is highly recommended.

This library has some neat features that should make migration painless - as well as some new features, such as a standardized location to place your Sunlight API Key, which makes testing (as well as distributing) your app even easier.

We've just released version 1.0.1 over on PyPI, which makes installation a snap on any system with pip. The documentation is fairly complete, but feedback is super welcome -- we're eager to learn where folks get stuck.

Most of the bugs seemed to be worked out after the Boston Python Project Night, where we had a few folks test out the library. A special thanks to all our beta-testers!

Alright, so how do I get started?

Hacking on python-sunlight is super easy. Here's how to get setup.

You'll need an API key. If you've not done so, get an API key (it's alright, we'll wait, go ahead).

Back already? Great.

Now, you'll have gotten the email that has a long-ish string of letters and numbers - let's save this to ~/.sunlight.key (where python-sunlight will look for a key). If you already had a key, it'd be worth it to go and dig it up.

If you're on a UNIX-type (MacOS, GNU/Linux, *BSD, AIX or Solaris (or any of the other POSIX-ey systems)) machine, you should be able to run a command that looks like the following:

echo "your-api-key-here" > ~/.sunlight.key

It's worth mentioning that your-api-key-here should actually be your API key that was emailed to you up above.

Next, you should install python-sunlight via pip. If pip is not installed on your system, please download and install pip.

pip install sunlight

And you're good to go!

Without further ado, an example!

#!/usr/bin/env python
# Copyright (c) 2012, BSD-3 clause, Sunlight Labs

from sunlight import capitolwords
from sunlight import congress

phrase = "death metal"
# Today, we'll be printing out the Twitter IDs of all legislators that use
# this phrase most in the congressional record.

for cw_record in capitolwords.phrases_by_entity(
    "legislator",  # We're getting all legislators
    sort="count",  # sorted by how much they say
    phrase=phrase, # this word
)[:6]: # We'll just try the top 5 legislators
    legislator = congress.legislators(
        bioguide_id=cw_record['legislator'], # Look up this biogude (unique ID)
        #                                      for every fed. legislator 
        all_legislators="true" # search retired legislators 
    )
    if len(legislator) >= 1: # If we were able to find the legislator
        legislator = legislator[0] # (this is a search, so it's a list)
        if legislator['twitter_id'] != "": # and they have a Twitter ID
            print "%s. %s (@%s) said %s %s times" %  (
                legislator['title'],
                legislator['lastname'],
                legislator['twitter_id'],
                phrase,
                int(cw_record['count'])
            ) # Print it to output :)

The output looks like this:

Sen. Feingold (@russfeingold) said death metal 979 times
Rep. Jackson Lee (@JacksonLeeTX18) said death metal 923 times
Sen. Leahy (@SenatorLeahy) said death metal 800 times
Sen. Kyl (@senjonkyl) said death metal 755 times
Sen. Durbin (@SenatorDurbin) said death metal 593 times

And once more (this time, searching for "san francisco"):

Rep. Filner (@CongBobFilner) said san francisco 1346 times
Sen. Feinstein (@senfeinstein) said san francisco 1288 times
Sen. Boxer (@senatorboxer) said san francisco 1181 times
Rep. Pelosi (@NancyPelosi) said san francisco 1135 times
Rep. Eshoo (@RepAnnaEshoo) said san francisco 677 times

Rock on!

Questions, concerns, bugs, patches, examples and virtual hugs are all welcome on our GitHub page, so please do check it out!

Continue reading

Sunlight Congress API & The 112th Congress

by

We've recently gotten a few questions about our Congress API and when it will include new members elected in November.

The reason that these members are not yet in the Congress API is that most* new members will not take office until January 3, 2011 when the 112th Congress convenes. Because the 111th Congress is still in session we are waiting until these members are sworn in and have offices assigned to them to add them to the API. Rest assured though that we have begun work on tracking down all of the relevant information for the representatives and senators elect and should have a large update for the first week of the new year.

Note: Some individuals, such as Mark Kirk in Illinois were elected in special elections and have already been added to the API. To keep track of what changes have been made already look at our apidata repo.

Continue reading

CFC (Combined Federal Campaign) Today 59063

Charity Navigator