ap2json

Split one AP API request into many JSON files.

Usage no npm install needed!

<script type="module">
  import ap2json from 'https://cdn.skypack.dev/ap2json';
</script>

README

ap2json

Build Status

TODO explain how this only does primaries for now

Convert AP API results to many JSON files, one per state-party-racetype combination.

Usage: ap2json [options]

Options:
    -f, --file       File containing API election results. Must have a <races> field.  [string] [required]
    -d, --directory  Directory where ap2json will place the output JSON files.  [string] [required]
    -c, --clear      Whether to clear output directory before writing output files.  [boolean] [default: true]

    Examples:
        ap2json -f results.json -d output -c false

Real-world example

curl 'https://api.ap.org/v2/elections/2016-02-01?statepostal=IA&test=true&level=ru&apikey=<APTOKEN>&format=json' > ia.json
ap2json -f ia.json -d races

output

Install

npm install -g ap2json