Re: [Sunlight Labs API] Getting bills in .Net

Showing 1-17 of 17 messages
Re: [Sunlight Labs API] Getting bills in .Net Eric Mill 2/28/12 12:30 PM
I haven't written any .NET code against our bill API, or using XML - but I have against our legislator API, and in JSON, if that's of any help at all.

This is the object wrapper for legislators in Sunlight's Windows Phone 7 app, "Congress":

It uses the Newtonsoft JSON parsing library:

Also, as you use the RTC API, I would strongly recommend you add a "sections" parameter to limit the scope of what fields you collect. It will slim down your response sizes, and will be forward compatible with the changes I announced earlier on this list, which will make that parameter a requirement.

-- Eric

On Tue, Feb 28, 2012 at 3:04 PM, Andy Xufuris <axuf...@gmail.com> wrote:
I'm working in .Net and i am trying to figure out how to pull these
bills into objects.  I have tried this but it hasn't worked.

int i = 111;
               XDocument xmlDoc = XDocument.Load("http://
api.realtimecongress.org/api/v1/bills.xml?
apikey=0582b905d77f4041917800b1119adb4e&session=" + i.ToString());

               var tutorials = from tutorial in
xmlDoc.Descendants("bill")
                               select new
                               {
                                   SponsorID =
tutorial.Element("sponsor_id").Value,
                                   SponsorFirstName =
tutorial.Element("sponsor").Element("first_name").Value,
                                   SponsorLastName =
tutorial.Element("sponsor").Element("last_name").Value,
                                   LastActionText =
tutorial.Element("last_action").Element("text").Value,
                                   BillNumber =
tutorial.Element("number").Value,
                                   BillType =
tutorial.Element("bill_type").Value,
                                   Enacted =
tutorial.Element("enacted").Value,
                                   EnactedDateTime =
tutorial.Element("enacted_at").Value,
                                   CongressSession =
tutorial.Element("session").Value,
                                   HousePassageResult =
tutorial.Element("house_passage_result").Value,
                                   HousePassageDateTime =
tutorial.Element("house_passage_result_at").Value,
                                   SenatePassageResult =
tutorial.Element("senate_passage_result").Value,
                                   SenatePassageDateTime =
tutorial.Element("senate_passage_result_at").Value,
                                   ShortTitle =
tutorial.Element("short_title").Value,
                               };

Has anyone done this, and can they help me through it?

--
You received this message because you are subscribed to the Google Groups "Sunlight Labs API Discussion" group.
To post to this group, send email to sunlightlabs...@googlegroups.com.
To unsubscribe from this group, send email to sunlightlabs-api-discuss+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sunlightlabs-api-discuss?hl=en.




--

Re: Getting bills in .Net Andy Xufuris 2/28/12 12:50 PM
Thank you Eric for the quick reply.  I'm still kind of new to JSON and
XML so its a struggle for me.  I didn't have a preference on json or
xml so i will take a look at what you sent, hopefully i can understand
it enough to use it for bills. Also you wouldn't happen to know if
there is no data for bills in any of the sessions before 111 would
you?  I did searches for all kinds of sessions but the only ones
returning are 110, 111, and 112.

On Feb 28, 2:30 pm, Eric Mill <e...@sunlightfoundation.com> wrote:
> I haven't written any .NET code against our bill API, or using XML - but I
> have against our legislator API, and in JSON, if that's of any help at all.
>
> This is the object wrapper for legislators in Sunlight's Windows Phone 7
> app, "Congress":https://github.com/sunlightlabs/congress-winphone/blob/master/Congres...
>
> It uses the Newtonsoft JSON parsing library:http://james.newtonking.com/pages/json-net.aspx
>
> Also, as you use the RTC API, I would strongly recommend you add a
> "sections" parameter to limit the scope of what fields you collect. It will
> slim down your response sizes, and will be forward compatible with the
> changes I announced earlier on this list, which will make that parameter a
> requirement.
>
> -- Eric
>
>
>
>
>
>
>
>
>
Re: [Sunlight Labs API] Re: Getting bills in .Net Eric Mill 2/28/12 12:54 PM
Cool, hope it's helpful. We just have sessions 111 and 112 right now.
Re: Getting bills in .Net Andy Xufuris 3/1/12 9:27 AM
I was working on getting a larger number for my initial download of
the bills.  But i cant get the number of bills to be more than 20?  I
went by the documantation and did this
http://api.realtimecongress.org/api/v1/bills.xml?page=1per_page=500&apikey=[apikey]&session=112"

On Feb 28, 2:54 pm, Eric Mill <e...@sunlightfoundation.com> wrote:
> Cool, hope it's helpful. We just have sessions 111 and 112 right now.
>
>
>
>
>
>
>
>
>
Re: [Sunlight Labs API] Re: Getting bills in .Net Eric Mill 3/1/12 9:31 AM
The RTC API isn't meant for archiving data. I actually changed the max per_page to 50, and I just updated the docs to reflect that. I'm also about to change the API so that the 'sections' field is required.

What I may do is start providing bulk data files of the JSON in the database behind the API, to facilitate archival usage.

-- Eric
Re: Getting bills in .Net Andy Xufuris 3/6/12 7:25 AM
Does the sections currently work?  Can you show an example how we will
be passing those variables in?

On Mar 1, 11:31 am, Eric Mill <e...@sunlightfoundation.com> wrote:
> The RTC API isn't meant for archiving data. I actually changed the max
> per_page to 50, and I just updated the docs to reflect that. I'm also about
> to change the API so that the 'sections' field is required.
>
> What I may do is start providing bulk data files of the JSON in the
> database behind the API, to facilitate archival usage.
>
> -- Eric
>
>
>
>
>
>
>
>
>
> On Thu, Mar 1, 2012 at 12:27 PM, Andy Xufuris <axufu...@gmail.com> wrote:
> > I was working on getting a larger number for my initial download of
> > the bills.  But i cant get the number of bills to be more than 20?  I
> > went by the documantation and did this
>
> >http://api.realtimecongress.org/api/v1/bills.xml?page=1per_page=500&a...[apikey]&session=112
Re: [Sunlight Labs API] Re: Getting bills in .Net Eric Mill 3/6/12 8:07 AM
Yes, the 'sections' parameter has been there since the API was launched, it's a comma-separated list of fields you want returned on each object in the response. There's a magic section called 'basic' that returns a bunch of common fields, and you can combine that with others.

For example, this returns common fields about bills, and the full list of actions that have occurred to it (use your api key):
RE: [Sunlight Labs API] Re: Getting bills in .Net Matthew Klahorst 3/6/12 9:44 AM

Eric,

 

One frustration I had with this is that I wanted to pull all fields + the additional fields you have (mongdo db, date added to db, basically the special fields)

 

But when I used sections, it only pulls from those sections and have no way to say something to the effect of (give me all AND the special fields)

 

So if I wanted to add them PLUS all orginal fields, I would have to string them all out in my query which I didn't end up doing.

 

I wanted your special fields so I could check to see if something was updated.

 

THAT BEING SAID - your product is wonderful!

 

Sincerely,

Matthew Klahorst
Square M, Inc.
23046 Avenida de la Carlota #270
Laguna Hills, CA 92653
Direct: (714) 458-8697
ma...@squareminc.com
www.squareminc.com

web | design | marketing

 

From: sunlightlabs...@googlegroups.com [mailto:sunlightlabs-api-discuss@googlegroups.com] On Behalf Of Eric Mill
Sent: Tuesday, March 06, 2012 8:08 AM
To: sunlightlabs...@googlegroups.com
Subject: Re: [Sunlight Labs API] Re: Getting bills in .Net

Re: [Sunlight Labs API] Re: Getting bills in .Net Eric Mill 3/6/12 10:32 AM
Okay - can I ask why you want all the fields for every document? Are you really using every one?

If you're using it to archive all the information, that's not what the API is designed for -- but I have been considering exporting the content to flat JSON files and offering it as bulk data. You would be able to download all of our bill information at once. Would this be more useful for your purposes?

-- Eric
RE: [Sunlight Labs API] Re: Getting bills in .Net Matthew Klahorst 3/6/12 10:40 AM

Great question!

 

Since my clients requirements seem ever-changing and in beta mode, I am not sure all that I need at this point.

 

I ran my script once and DB'd all the data. What I wanted to do is check your "last updated" internal change do I could just update when you updated.

 

And yes, getting all the bill data in one file without destroying your server (and mine)  with a massive script paginating at 50 pages per call would be beneficial.  Better yet, just download from yours and drop to mine (or rsynch).

 

Thanks for your prompt attention.

 

Sincerely,

Matthew Klahorst
Square M, Inc.
23046 Avenida de la Carlota #270
Laguna Hills, CA 92653
Direct: (714) 458-8697
ma...@squareminc.com
www.squareminc.com

web | design | marketing

 

From: sunlightlabs...@googlegroups.com [mailto:sunlightlabs-api-discuss@googlegroups.com] On Behalf Of Eric Mill
Sent: Tuesday, March 06, 2012 10:33 AM

Re: [Sunlight Labs API] Re: Getting bills in .Net Eric Mill 3/6/12 11:47 AM
Yeah, I don't want people running archive scripts on the API, as I made clear in the docs and on earlier threads in this list, and I've simply been slow about finally making the sections parameter a requirement. 

I can offer bulk data downloads, and am planning on doing so at some point, but GovTrack already provides a lot of the bulk data that you'd be looking for, for bills and amendments anyhow. They even support rsync. Is there data we have that you can't get as easily from there?

-- Eric
Re: Getting bills in .Net Andy Xufuris 3/6/12 12:20 PM
I have a question that may be off topic, but i was curious how i could
find out if a bill or vote was updated?  I won't know the bill or vote
id just wanting to grab the last updated one.  I was thinking maybe
the api returns the last added or updated bill or vote, would that be
correct?

On Mar 6, 1:47 pm, Eric Mill <e...@sunlightfoundation.com> wrote:
> Yeah, I don't want people running archive scripts on the API, as I made
> clear in the docs and on earlier threads in this list, and I've simply been
> slow about finally making the sections parameter a requirement.
>
> I can offer bulk data downloads, and am planning on doing so at some point,
> but GovTrack already provides a lot of the bulk data that you'd be looking
> for, for bills and amendments anyhow. They even support rsync. Is there
> data we have that you can't get as easily from there?
>
> -- Eric
>
> On Tue, Mar 6, 2012 at 1:40 PM, Matthew Klahorst <m...@squareminc.com>wrote:
>
>
>
>
>
>
>
> > Great question!****
>
> > ** **
>
> > Since my clients requirements seem ever-changing and in beta mode, I am
> > not sure all that I need at this point.****
>
> > ** **
>
> > I ran my script once and DB'd all the data. What I wanted to do is check
> > your "last updated" internal change do I could just update when you updated.
> > ****
>
> > ** **
>
> > And yes, getting all the bill data in one file without destroying your
> > server (and mine)  with a massive script paginating at 50 pages per call
> > would be beneficial.  Better yet, just download from yours and drop to mine
> > (or rsynch).****
>
> > ** **
>
> > Thanks for your prompt attention.****
>
> > ** **
>
> > Sincerely,
>
> > Matthew Klahorst
> > Square M, Inc.
> > 23046 Avenida de la Carlota #270
> > Laguna Hills, CA 92653
> > Direct: (714) 458-8697
> > m...@squareminc.com
> >www.squareminc.com
>
> > web | design | marketing****
>
> > ** **
>
> > *From:* sunlightlabs...@googlegroups.com [mailto:
> > sunlightlabs...@googlegroups.com] *On Behalf Of *Eric Mill
> > *Sent:* Tuesday, March 06, 2012 10:33 AM
>
> > *To:* sunlightlabs...@googlegroups.com
> > *Subject:* Re: [Sunlight Labs API] Re: Getting bills in .Net****
>
> > ** **
>
> > Okay - can I ask why you want all the fields for every document? Are you
> > really using every one?****
>
> > ** **
>
> > If you're using it to archive all the information, that's not what the API
> > is designed for -- but I have been considering exporting the content to
> > flat JSON files and offering it as bulk data. You would be able to download
> > all of our bill information at once. Would this be more useful for your
> > purposes?****
>
> > ** **
>
> > -- Eric****
>
> > ** **
>
> > On Tue, Mar 6, 2012 at 12:44 PM, Matthew Klahorst <m...@squareminc.com>
> > wrote:****
>
> > Eric,****
>
> >  ****
>
> > One frustration I had with this is that I wanted to pull all fields + the
> > additional fields you have (mongdo db, date added to db, basically the
> > special fields)****
>
> >  ****
>
> > But when I used sections, it only pulls from those sections and have no
> > way to say something to the effect of (give me all AND the special fields)
> > ****
>
> >  ****
>
> > So if I wanted to add them PLUS all orginal fields, I would have to string
> > them all out in my query which I didn't end up doing.****
>
> >  ****
>
> > I wanted your special fields so I could check to see if something was
> > updated.****
>
> >  ****
>
> > THAT BEING SAID - your product is wonderful!****
>
> >  ****
>
> > Sincerely,
>
> > Matthew Klahorst
> > Square M, Inc.
> > 23046 Avenida de la Carlota #270
> > Laguna Hills, CA 92653
> > Direct: (714) 458-8697
> > m...@squareminc.com
> >www.squareminc.com
>
> > web | design | marketing****
>
> >  ****
>
> > *From:* sunlightlabs...@googlegroups.com [mailto:
> > sunlightlabs...@googlegroups.com] *On Behalf Of *Eric Mill
> > *Sent:* Tuesday, March 06, 2012 8:08 AM
> > *To:* sunlightlabs...@googlegroups.com
> > *Subject:* Re: [Sunlight Labs API] Re: Getting bills in .Net****
>
> >  ****
>
> > Yes, the 'sections' parameter has been there since the API was launched,
> > it's a comma-separated list of fields you want returned on each object in
> > the response. There's a magic section called 'basic' that returns a bunch
> > of common fields, and you can combine that with others.****
>
> >  ****
>
> > For example, this returns common fields about bills, and the full list of
> > actions that have occurred to it (use your api key):****
>
> >http://api.realtimecongress.org/api/v1/bills.json?apikey=[apikey]&bill_id=s1813-112&sections=basic,actions
> > ****
>
> >  ****
>
> > -- Eric****
>
> > On Tue, Mar 6, 2012 at 10:25 AM, Andy Xufuris <axufu...@gmail.com> wrote:*
> > ***
>
> > Does the sections currently work?  Can you show an example how we will
> > be passing those variables in?****
>
> > On Mar 1, 11:31 am, Eric Mill <e...@sunlightfoundation.com> wrote:
> > > The RTC API isn't meant for archiving data. I actually changed the max
> > > per_page to 50, and I just updated the docs to reflect that. I'm also
> > about
> > > to change the API so that the 'sections' field is required.
>
> > > What I may do is start providing bulk data files of the JSON in the
> > > database behind the API, to facilitate archival usage.
>
> > > -- Eric
>
> > >****
>
> > > On Thu, Mar 1, 2012 at 12:27 PM, Andy Xufuris <axufu...@gmail.com>
> > wrote:
> > > > I was working on getting a larger number for my initial download of
> > > > the bills.  But i cant get the number of bills to be more than 20?  I
> > > > went by the documantation and did this
> > >****
>
> >http://api.realtimecongress.org/api/v1/bills.xml?page=1per_page=500&a...[apikey]&session=112
> > ****
> ...
>
> read more »
Re: [Sunlight Labs API] Re: Getting bills in .Net Eric Mill 3/6/12 1:09 PM
You probably would want to sort on last_action_at or last_version_on? last_action_at gives you the timestamp of the last official action, and last_version_on is a date field that indicates when the last printed version of the bill was produced.

You wouldn't want to sort on updated_at, as the RTC API updates every bill every day regardless of changes. That's part of the reason why I hide the updated_at field from the response; it's really only useful for me.

-- Eric

To unsubscribe from this group, send email to sunlightlabs-api-discuss+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sunlightlabs-api-discuss?hl=en.




--

Re: [Sunlight Labs API] Re: Getting bills in .Net Matthew Klahorst 3/6/12 1:54 PM
Good to know!

Sent from my iPhone
Re: [Sunlight Labs API] Re: Getting bills in .Net Andy Xufuris 3/8/12 6:58 AM
Re: [Sunlight Labs API] Re: Getting bills in .Net Eric Mill 3/8/12 3:54 PM
The problem was both of us. I had a bug that affected date filters on that field - but also, none of your calls were correct.

You'll want to do 3 things -

* Use a double underscore before the gte - it should be "last_version_on__gte". This is how I demarcate operators.
* Always use a 0 prefix when specifying the dates, so, "2010-01-01", not "2010-1-1".
* Specify a "sections" parameter, to ask for just the fields you need.

This works for me now, after I fixed my code, and fixed your URL:

-- Eric
Re: [Sunlight Labs API] Re: Getting bills in .Net Andy Xufuris 3/8/12 4:09 PM

Awesome. Thank you for the great work. I love your services