NYTimesArticleAPI is a fully-functional Python wrapper for the New York Times Article Search API.
Installation
With pip:
$ pip install NYTimesArticleAPI
Dependencies
NYTimesArticleAPI requires the `requests <https://pypi.python.org/pypi/requests>`__ and `setuptools <https://pypi.python.org/pypi/setuptools>`__ packages.
Usage
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 = api.search(q="Obama",
fq={"headline": "Obama",
"source": ["Reuters",
"AP",
"The New York Times"]},
begin_date="20161023", # this can also be an int
facet_field=["source", "day_of_week"],
facet_filter=True)
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 = api.search(q="Obama")
>>> articles = api.search(q="Obama", begin_date="20111231", page=2)
For a complete overview of the available search parameters, please refer to the NYTimes Article Search API Documentation.
History
This package was originally written by Evan Sherlock as `nytimesarticle <https://github.com/evansherlock/nytimesarticle>`__. It has since been forked and updated by Matt Morrison, and subsequently released as `NyTimesArticleAPI <https://pypi.python.org/pypi/NYTimesArticleAPI>`__, with contributions from Gerald Spencer and Andrew Han.
License
© 2016 Matt Morrison mattdmo@pigimal.com.
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.
Metadata
Release files for NYTimesArticleAPInew 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| NYTimesArticleAPInew-1.0.0.tar.gz | 5.6 kB | Without provenance | Details for NYTimesArticleAPInew-1.0.0.tar.gz |
Release files / NYTimesArticleAPInew-1.0.0.tar.gz
| Download URL | NYTimesArticleAPInew-1.0.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fcf4f8151431bd3221bdebfdc7c70fb4caecf04b0fe9f04852927810f3a213c
|
|
BLAKE2b-256 checksum How to use checksums |
dff610db10a78a44f93107b780e4826a8c8f1532398ecd78955367c5fcfec629
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for NYTimesArticleAPInew 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.