Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including nyt with all npm packages installed. Try it out:

var nyt = require("nyt")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

nyt v0.1.0

NYT is a wrapper around the New York Times API

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 package.json.

var NYT = require('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 = {

These keys are to be passed through the constructor for the New York Times API wrapper.

var nyt = new 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:

nyt.api.(sub-api).function(args, callback)

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:

nyt.article.get({'query':'bill gates'}, console.log); 

Here's an example of accessing an API that has a sub-API:

nyt.congress.members.newMembers({}, console.log);

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.

  • Article
  • Best Sellers
  • Campaign Finance
    • Candidates
    • Committees
    • Presidential Campaigns
    • Electronic Filings
    • Electioneering Communications
    • Individual Contributions
    • Independent Expenditures
    • Late Contributions to Candidates
    • Lobbyist Bundlers
  • Community
  • Congress
    • Members
    • Votes
    • Bills
    • Nominees
    • Other
  • Districts
  • Event Listings
  • Geo
  • Most Popular
  • Movie Reviews
    • Reviews
    • Critics
  • Real Estate
    • Listings
    • Sales
  • Semantic
  • Newswire
  • Timestags


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.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free