Perigon API Wrapper
A minimalist Python wrapper for the Perigon News API. Currently only supports querying all news articles via the v1/all
endpoint.
Installation (currently, only tested for Python 3.11):
pip install perigon-news-wrapper
Basic Usage
To initialize the API, import the package and add your API key:
from perigon_news_wrapper import PerigonAPI
api_key = '...'
api = PerigonAPI(api_key=api_key)
The main method is get_articles()
, which takes the following arguments:
paginate [bool = True]
: Whether or not to paginate results (if multiple pages are available). Defaults to True
.size [int = 100]
: The number of results to return per page. Defaults to 100
(maximum allowed by Perigon).**kwargs
: Arbitrary keyword arguments supported by the Perigon API. Consult the API docs for a comprehensive list of parameters.
get_articles()
returns a list of dictionaries, where each dictionary is the JSON of an individual article.
Example:
payload = {
'content': 'olympics AND usa AND gold',
'from': '2024-07-26',
'to': '2024-08-08',
'language': 'en',
'exclude_labels': [
'Non-news',
'Opinion',
'Fact Check',
'Roundup',
'Low Content'
]
}
results = api.get_articles(paginate=False, size=100, **payload)
TODO