Skip to main content

A very basic Python client for the New York Times [Campaign Finance API](http://developer.nytimes.com/docs/campaign_finance_api). You’ll need an API key, which should be set as an environment variable to run the tests. The client returns JSON only, not full Python objects, and attempts to implement each response in The Times’ API.

Install

$ pip install nytcampfin

Or download and run

$ python setup.py install

Requirements

NYT Campfin uses the [Kenneth Reitz’s Requests library](https://github.com/kennethreitz/requests) for retrieving API endpoints and [Roman Haritonov’s requests-cache library](https://github.com/reclosedev/requests-cache) for local caching. The cache is preconfigured to use a local sqlite database and set to expire after 5 minutes.

Tests

To run the tests, set your API key as an environment variable NYT_CAMPFIN_API_KEY:

$ export NYT_CAMPFIN_API_KEY=YOUR-API-KEY

and then run the tests:

$ python test.py

The use of caching is disabled in the tests.

Usage

>>> from nytcampfin import NytCampfin
>>> finance = NytCampfin(YOUR_NYT_CAMPAIGN_FINANCE_API_KEY)

# retrieve today’s filings >>> today = finance.filings.today() >>> today[0][‘filing_id’] 793150

# retrieve a committee’s details >>> cmte = finance.committees.get(‘C00490219’,2012) >>> cmte[‘id’] u’C00490219’

# retrieve a candidate’s details >>> cand = finance.candidates.get(‘H4NY11138’) >>> cand[‘name’] u’CLARKE, YVETTE D’

See the tests for plenty more examples.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it.

  • Send a pull request. Bonus points for topic branches.

Authors

Derek Willis, dwillis@nytimes.com

Metadata

Release files for nytcampfin 0.4.0

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

Source distribution (sdist)

Source distribution for nytcampfin 0.4.0
File Size Uploaded Provenance
nytcampfin-0.4.0.tar.gz 6.5 kB Without provenance Details

Release files / nytcampfin-0.4.0.tar.gz

Download URL nytcampfin-0.4.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ac6db64f6279359e384585b8cb8cc802ad745dcb5f0295754f0d1bee3226efe4
BLAKE2b-256 checksum
How to use checksums
ea0b77faa0b4bb0717967bf91d4b683dfea279499d3249ae4307cc6ccc203105
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for nytcampfin 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.4.0 This release

1 release file No provenance

0.2.0

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