npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nyt

v0.1.0

Published

NYT is a wrapper around the New York Times API

Downloads

12

Readme

New York Times API Wrapper

A New York Times API wrapper for Node.js

Motivation

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 = {
            '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 = 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.

Structure

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

Contributing

If you encounter any bugs, or wish to improve upon the API, please feel free to issue a pull request.

Author

This project was written and is maintained by Carlos Reyes. Find me on twitter @theCzarlos.