Skip to main content

# Metadata

A Python library that provides a thin wrapper to the [OpenElections Metadata API](http://docs.openelections.net/metadata-api/), which contains information about elections and the nature and availability of results data. The [API provides JSON endpoints for individual states](http://blog.openelections.net/an-improved-metadata-api/) and Metadata provides a way to search for and filter elections within a state.

Metadata has been tested under Python 2.7.X.

## Installation

` pip 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:

`python >>> 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.

`python >>> elections = r.parse() >>> elections[0] <metadata.election.Election object at 0x103ffff10> >>> elections[0].start_date u'2014-11-04' >>> elections[0].race_type u'general' `

## Running tests

` python setup.py test `

## Issues

To report an bug or request a feature, please [create a new issue](https://github.com/openelections/metadata/issues) 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.

Metadata

Release files for openelections-metadata 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openelections-metadata 0.1.1
File Size Uploaded
openelections-metadata-0.1.1.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openelections-metadata 0.1.1
File Interpreter ABI Platform
openelections_metadata-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 9.8 kB

Release files / openelections-metadata-0.1.1.tar.gz

Download URL openelections-metadata-0.1.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b6e31348126204adaa882ce04926dcc3c962a5f201670064246c0691589deeef
BLAKE2b-256 checksum
How to use checksums
ba5599d852d3c5fd802db0afc83bcf04d6d8037f9c4a3be0acaa2802a43f36e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / openelections_metadata-0.1.1-py2.py3-none-any.whl

Download URL openelections_metadata-0.1.1-py2.py3-none-any.whl
Size 6.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6bf9d966eee9f3dab2152e0697e3e8f9049375666264bb12bd8cd3edebf24c06
BLAKE2b-256 checksum
How to use checksums
978f36d64fc0a33ba8c2909168ea23b367ff7cc548c5d31aa31235be5f4bb5b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page