Learn R Programming

rtimes (version 0.5.0)

rtimes-package: rtimes

Description

Interface to the Congress and Campaign Finance APIs from Propublica, and the Article Search and Geographic 'APIs' from the New York Times.

Arguments

rtimes API

Functions that wrap these sets of APIs are prefixed by two letter acronyms fo reach API endpoint + the function name itself as for example cg + fxn

See the vignette for help.

Authentication

Get your own API keys for NYTimes APIs at http://developer.nytimes.com/signup - you'll need a different key for each of the article saerch and geo NYTimes APIs.

Get your Propublica API key for Congress and Campaign Finance APIs at either https://www.propublica.org/datastore/api/propublica-congress-api or https://www.propublica.org/datastore/api/campaign-finance-api - as far as I know, you can use the same key for both APIs

We set up the functions so that you can put the key in your .Renviron file, which will be called on startup of R, and then you don't have to enter your API key for each run of a function. Add entries for an R session like

  • Sys.setenv(NYTIMES_AS_KEY = "YOURKEYHERE")

  • Sys.setenv(NYTIMES_GEO_KEY = "YOURKEYHERE")

  • Sys.setenv(PROPUBLICA_API_KEY = "YOURKEYHERE")

Or set them across sessions by putting entries in your .Renviron file like

  • NYTIMES_AS_KEY=<yourkey>

  • NYTIMES_GEO_KEY=<yourkey>

  • PROPUBLICA_API_KEY=<yourkey>

You can also pass in your key in a function call, but be careful not to expose your keys in code committed to public repositories. If you do pass in a function call, use e.g., Sys.getenv("NYTIMES_AS_KEY")

Rate limits

Rate limits vary for the different APIs:

  • Article Search API: 1/sec, 1,000/day

  • Geographic API: 5/sec, 1,000/day

  • Congress API: 2/sec, 5,000/day

  • Campaign Finance API: 50/sec, 5,000/day

Details

Backstory is that the Congress and Campaign finance APIs used to be part of NYTimes, but were taken over by Propublica.