Skip to content

A python wrapper for Google's Civic Information API

License

Notifications You must be signed in to change notification settings

k0pak4/google-civic-information-api-py

Repository files navigation

google-civic-information-api-py

PyPI GitHub PyPI - Python Version GitHub Workflow Status

google-civic-information-api-py is a Python wrapper for Google's Civic Information API.

Installation

Installing with Pip from Pypi

pip install google-civic-information-api

Installing with Pip Locally

git clone https://github.com/k0pak4/google-civic-information-api-py.git
cd google-civic-information-api-py
pip install .

Usage

The google-civic-information-api has three modules: divisions, elections, and representatives. Each module has a few functions, examples of each are provided below.

divisions

import os
from google_civic_information_api import divisions

civic_api_key = os.environ["TEST_CIVIC_INFO_API_KEY"]

# Search Divisions by Address
search_results = divisions.search(civic_api_key, "District of Columbia")
print(search_results.json())

elections

import os
from google_civic_information_api import elections

civic_api_key = os.environ["TEST_CIVIC_INFO_API_KEY"]

# Search all Elections
elections_results = elections.elections(civic_api_key)
print(elections_results.json())

representatives

import os
from google_civic_information_api import 

civic_api_key = os.environ["TEST_CIVIC_INFO_API_KEY"]

# Retrieve all country level representatives from D.C. by searching by Address
dc_results = representatives.representative_info_by_address(
        civic_api_key, "20001", recursive=True, levels="country")
print(dc_results.json())

# Retrieve all country level representatives from D.C. by searching by OCD Division
dc_results = representatives.representative_info_by_division(
        civic_api_key, "ocd-division/country:us/district:dc", recursive=True, levels="country")
print(dc_results.json())

Contributing

Refer to the Contributing Guide for details on opening issues, pull requests, and development considerations.

Security

Refer to the Security Policy for details on supported versions, reporting vulnerabilities, and security considerations.

License

BSD 3-Clause License