pynytimes
  • Introduction to pynytimes
  • Getting Started
    • Installation
    • Usage
    • Citation
  • Search
    • Article Search
    • Book Reviews
    • Movie Reviews
  • Popular
    • Top Stories
    • Most Viewed
    • Most Shared
    • Best Sellers Lists
  • Metadata
    • Article Metadata
    • Archive Metadata
    • Latest Articles
  • Other
    • Tags
  • Advanced Usage
    • Close Connection
    • Automatic Connection
  • Repository
  • PyPI
Powered by GitBook
On this page
Edit on GitHub
  1. Advanced Usage

Automatic Connection

PreviousClose Connection

Last updated 2 years ago

Was this helpful?

CtrlK

Was this helpful?

If you want to automatically close the connection then usage using the with statement is supported.

with NYTAPI("Your API Key", parse_dates=True) as nyt:
    nyt.most_viewed()