Skip to main content

Python wrapper for the New York Times Article Search API

Project description

NYTimesArticleAPI is a fully-functional Python wrapper for the New York Times Article Search API.


With pip:

$ pip install NYTimesArticleAPI


NYTimesArticleAPI requires the `requests <>`__ and `setuptools <>`__ packages.


Simply import and initialize the API with your developer key:

>>> from NYTimesArticleAPI import articleAPI
>>> api = articleAPI("YourAPIKey")

Then call the search function with your desired search parameters/values:

>>> articles ="Obama",
                          fq={"headline": "Obama",
                              "source": ["Reuters",
                                         "The New York Times"]},
                          begin_date="20161023", # this can also be an int
                          facet_field=["source", "day_of_week"],

The search function returns a Python dictionary of the search results.

You can specify multiple filters by using a dictionary:

.. code:: python
>>> fq = {"headline": "Obama", "source": ["Reuters", "AP", "The New York Times"]}

And multiple values by using a list:

.. code:: python
>>> facet_field = ["source", "day_of_week"]

More examples:

>>> articles ="Obama")

>>> articles ="Obama", begin_date="20111231", page=2)

For a complete overview of the available search parameters, please refer to the NYTimes Article Search API Documentation.


This package was originally written by Evan Sherlock as `nytimesarticle <>`__. It has since been forked and updated by Matt Morrison, and subsequently released as `NyTimesArticleAPI <>`__, with contributions from Gerald Spencer and Andrew Han.


© 2016 Matt Morrison

This is free software. It is licensed under the MIT License. Feel free to use this in your own work. However, if you modify and/or redistribute it, please attribute me in some way, and distribute your work under this or a similar license. A shout-out or a beer would be appreciated.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for NYTimesArticleAPInew, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size NYTimesArticleAPInew-1.0.0.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page