nytimesarticlev2 is a fully-functional Python wrapper for the New York Times Article Search API.
Installation
With pip:
$ pip install nytimesarticlev2
Dependencies
nytimesarticlev2 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 nytimesarticlev2 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/nytimesarticlev2>`__, 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.
Release files for nytimesarticlev2 1.1.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 | |
|---|---|---|---|
| nytimesarticlev2-1.1.0.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nytimesarticlev2-1.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / nytimesarticlev2-1.1.0.tar.gz
| Download URL | nytimesarticlev2-1.1.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36163773de8a7b652c63011711f9f40055683ca574254f809e813b0b73822aa1
|
|
BLAKE2b-256 checksum How to use checksums |
31629927272b139a2daf05cfb69119910fc4d905097b5b701f6aa37f8c1eec2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.6.6
|
Release files / nytimesarticlev2-1.1.0-py2.py3-none-any.whl
| Download URL | nytimesarticlev2-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c9d42d4d5c871a8a27d837101683df2c279439730094929d4edfa5135b2618e2
|
|
BLAKE2b-256 checksum How to use checksums |
06618ad5d3f00c542ba09cb4ea3dea21a26e0a8a93de2ddff73b3c2227cbb739
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.6.6
|