openelections/metadata

Name: metadata

Owner: The OpenElections Project

Description: Python API wrapper for OpenElections metadata API

Created: 2015-09-28 23:56:57.0

Updated: 2015-09-29 23:44:30.0

Pushed: 2015-09-30 01:12:06.0

Homepage: null

Size: 115

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Metadata

A Python library that provides a thin wrapper to the OpenElections Metadata API, which contains information about elections and the nature and availability of results data. The API provides JSON endpoints for individual states and Metadata provides a way to search for and filter elections within a state.

Metadata has been tested under Python 2.7.X.

Installation
install openelections-metadata
Usage

Metadata offers two classes, Request and Election, for accessing the information in the API. You do not need an API key.

Request

To make a request, you'll need to specify the state you're interested in and any or none of three optional parameters: start_date, end_date and offset. Metadata uses the two dates as a range; it will search for elections on or after the start_date and on or before the end_date. For example, to make a request for elections that occurred in Maryland in 2014, you would do the following:

import metadata
r = metadata.Request('MD', '2014-01-01')

Request objects retain details about the parameters and also save the API url and the JSON response, if needed. Calling the parse method on the Request object creates individual Election objects, which have the same attributes as the API, with one addition - it has a generated_filename attribute that we use in the data processing pipeline.

elections = r.parse()
elections[0]
adata.election.Election object at 0x103ffff10>
elections[0].start_date
14-11-04'
elections[0].race_type
neral'
Running tests
on setup.py test
Issues

To report an bug or request a feature, please create a new issue describing the situation, providing as much detail as possible. We welcome contributions: feel free to fork the code and submit pull requests.

License

Metadata is released under the MIT License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.