GithubHelp home page GithubHelp logo

web5design / nytcampfin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nytimes/nytcampfin

0.0 3.0 0.0 60 KB

A thin Python client for The New York Times Campaign Finance API

Home Page: http://nytimes.github.com/nytcampfin/

License: Other

nytcampfin's Introduction

NYT Campfin

A very basic Python client for the New York Times 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 for retrieving API endpoints and Roman Haritonov's requests-cache library 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, [email protected]

Copyright

Copyright (c) 2012 The New York Times Company. See LICENSE for details.

nytcampfin's People

Contributors

dwillis avatar

Watchers

JT5D avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.