API

Our API is located at api.codefordemocracy.orgarrow-up-right. Our API helps you get to the raw data behind our tools without needing to use the front-end interface. Get started by viewing the available endpointsarrow-up-right or generating access credentials using the portal at account.codefordemocracy.orgarrow-up-right.

Code Samples

You can get started with sending requests quickly using the following wrapper functions in python. Just fill in your client_id and client_secret.

from urllib.parse import urlencode
import requests
import json

# set your credentials
client_id = "XXXXXXXXXXXXXXXXXXXXXXX"
client_secret = "XXXXXXXXXXXXXXXXXXXXXXX"

# this function gets the response from our API
def post(endpoint, body):
    url = "https://api.codefordemocracy.org"
    response = requests.post(url+endpoint, data=json.dumps(body), auth=(client_id, client_secret))
    if response.status_code == 200:
        return json.loads(response.text)
    return []

For example, you can use this code to print the cmte_id for 100 Lobbyist/Registrant PACs:

circle-info

Our API is open source! See the APIarrow-up-right repository on GitHub and inspect the code for exact details on how we calculate each endpoint.

Last updated

Was this helpful?