New York Times API Wrapper
A New York Times API wrapper for Node.js
I wasn't able to find a wrapper for the New York Times developer API, and I thought it would be great if one existed, thus, I wrote this one.
Setting Things Up
Installing things up is fairly simple:
npm install -s nyt
this will install the module and save it in
var NYT = ;
Accessing the Endpoint
Before making API calls we have to add the developer keys. To do this create a JSON object with keys for each of the New York Times APIs that you wish to access. Thus each key is paired with its name as seen in this next snippet:
var keys ='article-search':'sample-key''congress':'sample-key'
These keys are to be passed through the constructor for the New York Times API wrapper.
var nyt = keys;
You are now ready to start making calls. Calls are made via the specific API and the sub-API that we wish to access. Therefore calls are structured as such:
Some of the API's have sub-APIs, and some don't. Here is an example of accessing an API that doesn't have a sub-API:
Here's an example of accessing an API that has a sub-API:
In the previous example, 'congress' is the API, 'members' is the sub-API, and 'newMembers()' is the method call. The API structure follows the New York Times documentation, and is outlined further in the 'Structure' section of this document.
Please refer to the docs pages for in-depth API outlines.
Below is the structure of the API and sub-APIs. Official documentation for this structure can be found in the New York Times API.
- Best Sellers
- Campaign Finance
- Presidential Campaigns
- Electronic Filings
- Electioneering Communications
- Individual Contributions
- Independent Expenditures
- Late Contributions to Candidates
- Lobbyist Bundlers
- Event Listings
- Most Popular
- Movie Reviews
- Real Estate
If you encounter any bugs, or wish to improve upon the API, please feel free to issue a pull request.
This project was written and is maintained by Carlos Reyes. Find me on twitter @theCzarlos.