Skip to content

Create a CourtListener interface #245

Closed

Description

@waldoj

CourtListener is starting to add state Supreme Court decisions to their offerings, and intends to add all fifty states. Consequently, it is sensible to bake support for it into The State Decoded.

The trick is that CourtListener has no API, and even their bulk downloads are awkward. (They're broken up by year, with no indication of the span of years for which coverage is offered. So to get all court decisions for, say, Indiana, one would need to request 2013, 2012, 2011, etc., until finally a 404 was returned. And that's assuming that there's no year-long gaps in coverage.) So supporting CourtListener really means writing a system to periodically download their bulk files, parse their XML format, store those decisions, index them, put an API on top of all that, and then add support to The State Decoded to interface with that API.

This may reasonably be a separate project—surely it has more utility than for The State Decoded, and I'm not sure that I'd want it tightly coupled, anyway.

Activity

  1. mlissner commented on Mar 22, 2013

    @mlissner

    Yes, having a per-court dump would be tops, but alas, the processing power for that is pretty brutal. Couple thoughts though:

    1. You could download everything up until the last day of last month using this file: http://www.courtlistener.com/dump-api/all.xml.gz. Once you had that, to stay up to date, it'd be a matter of getting the daily or monthly dumps with a cron job, and we do have dumps of everything each month.
    2. An alternative might be for us to collaborate on an API in CL itself. If it met your needs, then you could just hit that from The State Decoded, and life would be good for both of us. It'd also provide a more canonical source of the data (better to get it from CL > The Court, than to get it from TSD > CL > The Court).

    Anyway, mostly just commenting so I'm tracking this issue, but let's stay in touch when/if you get to this.

  2. waldoj commented on Mar 22, 2013

    @waldoj
    MemberAuthor

    I agree that an API in CourtListener would be preferable. (Downloading and parsing a 3.2 GB—and growing—file is a non-trivial requirement that I'd hate to impose on people.) Maybe we could divide and conquer here? I could devise my own concept of what would be useful in an RESTful API, you could use that as the basis for an implementation, and I could create a GPLd PHP class to interface with it (which I'd then employ in The State Decoded, of course). That way you have an interface that you know is useful, and you're assured that it'll be easy for folks to use your API, since you'll have a client to offer. Of course, that still leaves you with the not-insignificant task of putting together an API, but if you're willing to take the "rough consensus, running code" approach, this might be pretty easy thing to knock out!

    This might be a v1.0 task (and we're only on v0.6), but this is something I'd be happy to do much sooner. What you're doing is important, and connecting The State Decoded with CourtListener seems like an investment that will accure interest pretty quickly!

  3. mlissner commented on Mar 23, 2013

    @mlissner

    I love it. Get me your concept of what'd be a good API, and I'll get you an API to apply it to. This has been on my list long enough.

    I've got one item I'll need to square away before I can start another big feature, but I'll move this to the number two spot as soon as I get the next piece from you.

  4. waldoj commented on Mar 23, 2013

    @waldoj
    MemberAuthor

    I'll start off with the 30,000-foot view. To my mind, there are a couple of primary goals in an interface for court rulings.

    1. Retrieve all rulings that cite a given law. When somebody is looking at § 12.3-45.6, they ought to be able to see every court ruling that mentions § 12.3-45.6.
    2. Retrieve the text and associated metadata for a given ruling.

    I've hacked together just such an API for Virginia court rulings, and it works nicely. I use a PCRE to identify every citation in every ruling, and then store those in a separate table. For the state-by-state PCREs to make those matches, you might look at the work being done by @konklone et al. on a legal citation extractor, intended to solve this very problem. (See Virginia for an example.) Since the Sunlight Foundation, the State Decoded, and Court Listener all need to solve this problem, I suspect we can collaboratively produce something for every state with a brief push of work.

    It seems to me that these two goals (rulings by law; retrieving rulings) might be best accomplished in two very different ways. You may not care to deal with the number of requests liable to be made of a per-section API, so perhaps that would be delivered as a bulk download. Maybe a big JSON file, providing ruling metadata for each section of the code. That way those frequent lookups can be done locally, and Court Listener's API instead can be focused on the thing that you do best—provide a centralized hub for court rulings.

    What do you think?

  5. konklone commented on Mar 23, 2013

    @konklone

    CourtListener might get some benefit out of building citation filtering into its API, rather than make people do the lookup locally. I have an undocumented parameter in our Congress API that does special citation filtering - and filtering is the right word, because the citations (and surrounding excerpts) are pre-extracted at index time using unitedstates/citation, and stored as an array on the bill or regulation. Clients (of which there is only Scout, since it's undocumented) are expected to pass in a citation formatted into the slug that unitedstates/citation uses. It may seem slightly roundabout, but this makes the citation lookup absurdly fast, and doable completely in a "normal" database, since there's no full text search. So a search like this one uses an API call like this one.

    But you could also get a lot of benefit just by including extracted citation metadata as part of each document in the bulk downloads (maybe you do this already?). Either way, you eliminate clients doing the work, and it's work you need to do server side anyway for Court Listener. I would suggest not breaking up the bulk downloads per-cited-section, if only because documents citing multiple sections will create a lot of redundancy.

    Maybe the simplest way to address the problem of huge files is for an API that provides a "since"-like parameter to only get new documents since a particular time/date/ID. That way, anyone can start off with the multi-GB download, but easily keep up to date. Or, the GPO FDSys approach is to keep a crawlable sitemap that lists documents in order of last modified, which is okay.

  6. waldoj commented on Mar 23, 2013

    @waldoj
    MemberAuthor

    To be sure, that's the scenario I prefer! But I don't want to make an unduly burdensome request.

  7. mlissner commented on Mar 24, 2013

    @mlissner

    From my perspective, this is really three things:

    1. Get the citations to statutes identified, squared away in our database
      and linked somewhere (State Decoded or LII, whatever makes sense, I don't
      know).
    2. Get an API for opinions up and running
    3. Get an API for everything else up and running (citations, court data,
      etc).

    Doing number one is probably a fairly big task right now. When we did it
    for only citations to other cases, it was a multi-month effort. Numbers 2
    and 3 are ones I'd like to get to ASAP.

    How useless would this API be for you guys if 1 wasn't done for a while or
    possibly ever (trying to be realistic -- I'm one day/week on CL!).

    On Sat, Mar 23, 2013 at 2:12 PM, Waldo Jaquith [email protected]:

    To be sure, that's the scenario I prefer! But I don't want to make an
    unduly burdensome request.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/245#issuecomment-15344896
    .

  8. waldoj commented on Mar 24, 2013

    @waldoj
    MemberAuthor

    I wouldn't say that it would useless to have an API without statutes identified, but it would certainly be substantially less useful. Court decisions that aren't connected to statutes cannot be connected to anything else (legislation, campaign finance, attorney general's opinions, etc.), which means that I can't connect them to laws and, downstream, @konklone (for instance) can't connect them to legislation via those laws.

    So that means that some third party (at this point, me) would have to identify statutes. Functionally, that means downloading the entire database on a regular basis, breaking it up by state, identifying every statute, and then hosting a huge JSON file for each state, cross-referencing statutes and decisions. Each State Decoded site would then syndicate their state's file, and then use that to query the Court Listener API for details about that case. But, weirdly, that leaves me holding a big pile of information that's got to be way more useful to folks visiting your site than to folks visiting my sites.

    If you were handed regular expressions for each state code's citation format, then would it still be difficult for you to identify those citations? In the abstract, it should be simple, but of course in software development, many things that are simple in the abstract can be very difficult in reality. :) What if I handed you the aforementioned huge JSON file—could you put that to work? Or what if I gave you the code that created the JSON file—could you run that and leave me out of it? :)

    (This, not incidentally, is just the sort of nuts-and-bolts project that could never get funding from open government foundations. It's transparently obvious to me that it would be wildly useful to have tested, known-good PCREs to identify every state law citation method. As we can see here, that would provide the glue that would link together so many different sources of public data. But who wants to fund something that boring? Who's going to brag about that at the next board meeting?)

  9. mlissner commented on Mar 24, 2013

    @mlissner

    Having the regexes would make a huge difference, yes. It'd still be
    difficult, but we can make it happen if we had those. Short of those,
    I'll start working on the opinion-API, since adding a statute API once
    we've got the PRES won't be that hard.

    On 03/23/2013 07:20 PM, Waldo Jaquith wrote:

    I wouldn't say that it would /useless/ to have an API without statutes
    identified, but it would certainly be substantially less useful. Court
    decisions that aren't connected to statutes cannot be connected to
    anything else (legislation, campaign finance, attorney general's
    opinions, etc.), which means that I can't connect them to laws and,
    downstream, @konklone https://github.com/konklone (for instance)
    can't connect them to legislation via those laws.

    So that means that some third party (at this point, me) would have to
    identify statutes. Functionally, that means downloading the entire
    database on a regular basis, breaking it up by state, identifying
    every statute, and then hosting a huge JSON file for each state,
    cross-referencing statutes and decisions. Each State Decoded site
    would then syndicate their state's file, and then use that to query
    the Court Listener API for details about that case. But, weirdly, that
    leaves me holding a big pile of information that's got to be /way/
    more useful to folks visiting your site than to folks visiting my sites.

    If you were handed regular expressions for each state code's citation
    format, then would it /still/ be difficult for you to identify those
    citations? In the abstract, it should be simple, but of course in
    software development, many things that are simple in the abstract can
    be very difficult in reality. :) What if I handed you the
    aforementioned huge JSON file—could you put that to work? Or what if I
    gave you the code that created the JSON file—could you run that and
    leave me out of it? :)

    (This, not incidentally, is just the sort of nuts-and-bolts project
    that could never get funding from open government foundations. It's
    transparently obvious to me that it would be wildly useful to have
    tested, known-good PCREs to identify every state law citation method.
    As we can see here, that would provide the glue that would link
    together so many different sources of public data. But who wants to
    fund something that boring? Who's going to brag about that at the next
    board meeting?)

    —
    Reply to this email directly or view it on GitHub
    #245 (comment).

  10. waldoj commented on Mar 25, 2013

    @waldoj
    MemberAuthor

    OK, I think @konklone and I have put together a decent (rough) plan for getting you all of those regular expressions. It'll cost me about a grand, but I think it's money well-spent. :) I'm waiting to get clearance from The Knight Foundation, and then we'll start putting together a detailed plan to make sure I'm not forgetting anything fundamental. I feel pretty good that you'll have a big list of regular expressions before very long.

  11. konklone commented on Mar 25, 2013

    @konklone

    I'm having some issues with the bulk dumps. For Utah, I get a 400 and a 404 respectively from:
    https://www.courtlistener.com/dump-api/2013/utah.xml.gz
    https://www.courtlistener.com/dumps/2013/utah.xml.gz

    For either version of that URL, I get a 104 byte zip with an empty XML file in it for years 2012, 2011, 2010, and 2009.

    For Oregon, I get the same response for 2013, but I get a few MB of opinion data for 2012, and a few for 2011, and a few for 2010, and a few for 2009. The data in the opinions looks right, though I'd expect more(?).

    Is there any data for 2013 for any state court? Is there a bug regarding Utah?

  12. waldoj commented on Mar 25, 2013

    @waldoj
    MemberAuthor

    I'm downloading the whole database.

    If I don't come out on the other side...avenge me.

  13. konklone commented on Mar 25, 2013

    @konklone

    I downloaded that too. =) It's a 13 GB file when unzipped - make sure you got some room! Rather than invest in learning how to SAX parse, I figured i'd just go after a subset...

  14. waldoj commented on Mar 26, 2013

    @waldoj
    MemberAuthor

    huge-mistake

  15. waldoj commented on Mar 26, 2013

    @waldoj
    MemberAuthor

    @mlissner, you should know that CourtListener will happily provide a file for any year. e.g., Utah 1752!

  16. 86 remaining items

  17. krusynth commented on Apr 14, 2017

    @krusynth
    Member

    So what should happen to this metadata on old (not-current) editions? The laws_meta table currently keys on the law's id, not the section number, so it's edition-specific already – do we need non-edition-specific metadata instead?

  18. waldoj commented on Apr 14, 2017

    @waldoj
    MemberAuthor

    Hmm. I hope we're not hitting CourtListener for every version of a law...but we might be? I don't mind never expiring CourtListener metadata on old editions, because they are, after all, old editions—one doesn't expect them to be current. I also don't mind clearing out CourtListener metadata for old editions, because I think it's fine for old editions not to list court rulings, because they're bound to sometimes include court rulings that are more recent than that edition, which would be confusing.

    Seems like it might be wise to blow away CourtListener metadata for old rulings, and prevent querying CourtListener's API for anything other than the current edition.

  19. krusynth commented on Apr 14, 2017

    @krusynth
    Member

    With that PR, I've added metadata-clearing for all court data if you're importing data for the current edition.

    I've also created a command to clear out metadata, per edition and/or field. It looks like this:

    ./statedecoded clearmetadata --edition=vacode --field=court_decisions
    
  20. krusynth commented on Apr 14, 2017

    @krusynth
    Member

    Also, I noticed that CourtListener is returning results that I'm not expecting, I dunno if this is an API change or what. For instance, the query on § 8.01-27 is:

    https://www.courtlistener.com/api/rest/v3/search/?q=%228.01-27%22&court=ca4,vaeb,vawb,vaed,vawd,va,vactapp&order_by=score+desc&format=json
    

    And that returns a couple of cases about Durham, NC. @mlissner, is that correct? I haven't touched this stuff much, so it's likely a pibcak error.

  21. mlissner commented on Apr 15, 2017

    @mlissner

    Looks like you're filtering to include CA4 cases, which would include NC. Seems right to me?

  22. krusynth commented on Apr 15, 2017

    @krusynth
    Member

    closeenough

  23. waldoj commented on Apr 18, 2017

    @waldoj
    MemberAuthor

    I think this is wrapped up, then, @krues8dr?

  24. mlissner commented on Apr 21, 2017

    @mlissner

    Yay! Now, then, to release v4 of the API.....

    (KIDDING!)

  25. krusynth commented on Apr 21, 2017

    @krusynth
    Member

    corgi-fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions