Skip to content

Commit a65e36c

Browse files
author
Paul Tagliamonte
committed
Moving congress to deprecated; move to new API soon
Will maintain congress_deprecated for a few releases.
1 parent 84ae15a commit a65e36c

File tree

11 files changed

+171
-311
lines changed

11 files changed

+171
-311
lines changed

docs/source/index.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ projects.
1111

1212
Currently this library supports the following APIs:
1313

14-
* `Sunlight Congress API <http://services.sunlightlabs.com/docs/Sunlight_Congress_API/>`_ (via :ref:`sunlight.congress`)
1514
* `Open States API <http://openstates.org/api/>`_ (via :ref:`sunlight.openstates`)
15+
* `Congress API <http://sunlightlabs.github.com/congress/>`_ (via :ref:`sunlight.congress`)
1616
* `Capitol Words API <http://capitolwords.org/api/>`_ (via :ref:`sunlight.capitolwords`)
1717

18-
Support is pending for the `Influence Explorer API <http://data.influenceexplorer.com/api/>`_ and the
19-
`Real Time Congress API <http://services.sunlightlabs.com/docs/Real_Time_Congress_API/>`_,
20-
though these currently have their own Python wrappers.
18+
* `The old Sunlight Congress API (deprecated) <http://services.sunlightlabs.com/docs/Sunlight_Congress_API/>`_ (via :ref:`sunlight.congress_deprecated`)
19+
2120

2221
Installation
2322
============

examples/congress/get_nacy renamed to examples/congress_deprecated/get_nacy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22

33
from __future__ import print_function
4-
from sunlight import congress
4+
from sunlight import congress_deprecated as congress
55

66
nancy = congress.legislators( lastname="Pelosi" )[0]
77
print( "%s %s %s (%s)" % ( nancy['title'], nancy['firstname'],

examples/influenceexplorer/contrib_to_mikulski

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/influenceexplorer/homeland_security_grants

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/influenceexplorer/lobby_for_pfizer

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/influenceexplorer/microsoft_contracts

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/influenceexplorer/nancy_givers

Lines changed: 0 additions & 13 deletions
This file was deleted.

sunlight/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
import sunlight.services.openstates
1717
import sunlight.services.capitolwords
1818
import sunlight.services.congress
19-
import sunlight.services.influenceexplorer
19+
import sunlight.services.congress_deprecated
2020

2121
openstates = sunlight.services.openstates.Openstates()
2222
capitolwords = sunlight.services.capitolwords.CapitolWords()
23+
2324
congress = sunlight.services.congress.Congress()
24-
influenceexplorer = sunlight.services.influenceexplorer.InfluenceExplorer()
25+
congress_deprecated = sunlight.services.congress_deprecated.Congress()
2526

2627
import os.path
2728
import warnings
@@ -34,7 +35,6 @@ def available_services():
3435
'openstates': openstates,
3536
'capitolwords': capitolwords,
3637
'congress': congress,
37-
'influenceexplorer': influenceexplorer,
3838
}
3939

4040

sunlight/services/congress.py

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
import sunlight.service
1212
import json
1313

14-
service_url = "http://services.sunlightlabs.com/api/"
15-
16-
17-
def _unpack(resp, key):
18-
return [e[key] for e in resp[key + 's']]
19-
2014

2115
class Congress(sunlight.service.Service):
2216
"""
@@ -25,132 +19,6 @@ class Congress(sunlight.service.Service):
2519
primarily for details on current federal legislators.
2620
"""
2721

28-
def legislators(self, **kwargs):
29-
"""
30-
Query for all legislators matching certain criteria.
31-
32-
See documentation at `legislators.get(List)
33-
<http://services.sunlightlabs.com/docs/congressapi/legislators.get(List)/>`_
34-
"""
35-
return _unpack(self.get('legislators.getList', **kwargs),
36-
'legislator')
37-
38-
def legislator_search(self, name, threshold=0.9, all_legislators=False,
39-
**kwargs):
40-
"""
41-
Fuzzy-matching name search against federal legislators.
42-
43-
See documentation at `legislators.search
44-
<http://services.sunlightlabs.com/docs/congressapi/legislators.search/>`_
45-
"""
46-
params = kwargs.copy()
47-
params.update({'name': name, 'threshold': threshold})
48-
49-
if all_legislators:
50-
params['all_legislators'] = 1
51-
52-
return _unpack(self.get('legislators.search', **params), 'result')
53-
54-
def legislators_for_zip(self, zipcode, **kwargs):
55-
"""
56-
Query for all legislators representing a given ZIP code.
57-
58-
This method is not recommended, prefer legislators_for_lat_lon instead.
59-
See the blog post `"Don't Use Zip Codes Unless You Have To"
60-
<http://sunlightlabs.com/blog/2012/dont-use-zipcodes/>`_.
61-
62-
See documentation at `legislators.allForZip
63-
<http://services.sunlightlabs.com/docs/congressapi/legislators.allForZip/>`_
64-
"""
65-
params = kwargs.copy()
66-
params.update({
67-
"zip": zipcode
68-
})
69-
return _unpack(self.get('legislators.allForZip', **params),
70-
'legislator')
71-
72-
def legislators_for_lat_lon(self, latitude, longitude, **kwargs):
73-
"""
74-
Query for all legislators representing an given location.
75-
76-
See documentation at `legislators.allForLatLong
77-
<http://services.sunlightlabs.com/docs/congressapi/legislators.allForLatLong/>`_
78-
"""
79-
params = kwargs.copy()
80-
params.update({
81-
"latitude": latitude,
82-
"longitude": longitude
83-
})
84-
return _unpack(self.get('legislators.allForLatLong', **params),
85-
'legislator')
86-
87-
def districts_for_zip(self, zipcode, **kwargs):
88-
"""
89-
Query for all congressional districts overlapping a zip code.
90-
91-
See documentation at `districts.getDistrictFromLatLong
92-
<http://services.sunlightlabs.com/docs/congressapi/districts.getDistrictFromLatLong/>`_
93-
"""
94-
params = kwargs.copy()
95-
params.update({
96-
"zip": zipcode
97-
})
98-
return _unpack(self.get('districts.getDistrictsFromZip', **params),
99-
'district')
100-
101-
def districts_for_lat_lon(self, latitude, longitude, **kwargs):
102-
"""
103-
Query for all congressional districts containing a given location.
104-
105-
See documentation at `districts.getDistrictFromLatLong
106-
<http://services.sunlightlabs.com/docs/congressapi/districts.getDistrictFromLatLong/>`_
107-
"""
108-
params = kwargs.copy()
109-
params.update({
110-
"latitude": latitude,
111-
"longitude": longitude
112-
})
113-
return _unpack(self.get('districts.getDistrictFromLatLong', **params),
114-
'district')
115-
116-
def committees(self, chamber, **kwargs):
117-
"""
118-
Query for all committees for a chamber. (House|Senate|Joint)
119-
120-
See documentation at `committees.getList
121-
<http://services.sunlightlabs.com/docs/congressapi/committees.getList/>`_
122-
"""
123-
params = kwargs.copy()
124-
params.update({"chamber": chamber})
125-
return _unpack(self.get('committees.getList', **params),
126-
'committee')
127-
128-
def committee_detail(self, committee_id, **kwargs):
129-
"""
130-
Query for all details for a committee, including members.
131-
132-
See documentation at `committees.get
133-
<http://services.sunlightlabs.com/docs/congressapi/committees.get/>`_
134-
"""
135-
params = kwargs.copy()
136-
params.update({"id": committee_id})
137-
# We can't use _unpack since top level is `committee' not committees
138-
return self.get('committees.get', **params)['committee']
139-
140-
def committees_for_legislator(self, bioguide_id, **kwargs):
141-
"""
142-
Query for all details for all of a legislator's committee assignments.
143-
144-
See documentation at `committees.allForLegislator
145-
<http://services.sunlightlabs.com/docs/congressapi/committees.allForLegislator/>`_
146-
"""
147-
params = kwargs.copy()
148-
params.update({
149-
"bioguide_id": bioguide_id
150-
})
151-
return _unpack(self.get('committees.allForLegislator', **params),
152-
'committee')
153-
15422
# implementation methods
15523
def _get_url(self, obj, apikey, **kwargs):
15624
return "%s/%s?apikey=%s&%s" % (
@@ -159,6 +27,3 @@ def _get_url(self, obj, apikey, **kwargs):
15927
apikey,
16028
sunlight.service.safe_encode(kwargs)
16129
)
162-
163-
def _decode_response(self, response):
164-
return json.loads(response)['response']

0 commit comments

Comments
 (0)