Follow Us

Influence Explorer API, Now with Entity Type Filtering

by

Last year, we wrote about how to get access to our political influence data via the Influence Explorer API. That post is a great introduction, but here's an update on a small, but significant, improvement we've made to make accessing our data easier.

Calling our entity name search endpoint is the first step to accessing any of our aggregate data or wealth of metadata about political or politically influential entities, provided you don't already have the advantage of an ID from CRP, NIMSP, or the Congressional Bioguide (there's another endpoint to do ID-based lookups). For politicians, for instance, we've got not only campaign finance data and aggregate totals, but bios, photos, seats, districts, years run, and more. Say you want to find a head shot of John Boehner and how much money he raised in 2012. Play along with our examples, and go get a Sunlight API key. In the past, you would have just searched by name:

http://transparencydata.com/api/1.0/entities.json?&apikey=<your-key>&search=John+Boehner

From that, you'd get the following:

[
    {
        name: "Friends of John Boehner",
        count_given: 8,
        firm_income: 0,
        count_lobbied: 0,
        seat: null,
        total_received: 0,
        state: null,
        lobbying_firm: false,
        count_received: 0,
        party: null,
        total_given: 5701,
        type: "organization",
        id: "53ecb66245a64f0b989259b63f50bd9f",
        non_firm_spending: 0,
        is_superpac: false
    },
    {
        name: "John Boehner (R)",
        count_given: 0,
        firm_income: 0,
        count_lobbied: 0,
        seat: "federal:house",
        total_received: 31928263,
        state: "OH",
        lobbying_firm: null,
        count_received: 28267,
        party: "R",
        total_given: 0,
        type: "politician",
        id: "f990d08287c34c389cfabe3cbf3dde99",
        non_firm_spending: 0,
        is_superpac: null
    }
]

You'll notice that two entities were returned. Previously, you would have had to do an extra filtering step in your application code to get only the politician entity, which, nine times out of ten, is the one you'd want. And you'd either realize this up front, or spend some amount of time being frustrated as to why you were getting multiple results or assuming the first result returned was the one you wanted, when it wasn't really. No more! Now, you can search directly for the type of entity (politician/organization/individual/industry) you want.

http://transparencydata.com/api/1.0/entities.json?&apikey=<your-key>&search=John+Boehner&type=politician

And the result:

[
    {
        name: "John Boehner (R)",
        count_given: 0,
        firm_income: 0,
        count_lobbied: 0,
        seat: "federal:house",
        total_received: 31928263,
        state: "OH",
        lobbying_firm: null,
        count_received: 28267,
        party: "R",
        total_given: 0,
        type: "politician",
        id: "f990d08287c34c389cfabe3cbf3dde99",
        non_firm_spending: 0,
        is_superpac: null
    }
]

Isn't that better? You'll still have to do your due diligence to make sure you're getting what you really expect, but now you can just grab that ID and go get the full set of metadata for Boehner for that campaign finance total and headshot:

http://transparencydata.com/api/1.0/entities/f990d08287c34c389cfabe3cbf3dde99.json?apikey=<your-key>

With the results (JSON abbreviated):

    {
        name: "John Boehner (R)",
        totals: {
            2012: {
                recipient_amount: 12852363,
            },  
        },
        type: "politician",
        id: "f990d08287c34c389cfabe3cbf3dde99",
        metadata: {
            photo_url: "http://assets.sunlightfoundation.com/moc/100x125/B000589.jpg",
        }
    }

We hope you'll let us know if there are other ways we can make our data easier to use. Now, if you haven't already done so, go forth and get an API key and start building cool stuff with our Influence Explorer API!