nytimes-api
  • Welcome!
  • Documentation
    • Popular - mostEmailed
    • Popular - mostViewed
    • Popular - mostShared
    • Movies - allCritics
    • Movies - criticsPick
    • Movies - searchCritics
    • Movies - searchReviews
    • Books - bestSellersLists
    • Books - bestSellers
    • Books - overview
    • Books - searchReviews
    • TopStories - sections
    • TopStories - randomSection
    • TopStories - topStories
  • Examples
  • Changelogs
    • 1.0
    • 1.1
    • 1.2
    • 1.2.1
    • 1.3
Powered by GitBook
On this page
  • Example
  • What does it do?
  • Example Response
  1. Documentation

TopStories - randomSection

Example

example.js
const { TopStories } = require('nytimes-api');
const top = new TopStories('your-super-secret-api-key');

top.randomSection(data => console.log(data));

What does it do?

randomSection returns a random section from the array you get if you were to use sections. The code example above does the same.

This is not a feature in the API. It has just been added to the wrapper for convenience.

Example Response

example-response.json
'opinion'
PreviousTopStories - sectionsNextTopStories - topStories

Last updated 6 years ago