# Perigon API Wrapper
[](https://www.python.org)
A minimalist Python wrapper for the [Perigon News API](https://www.goperigon.com/). Currently only supports querying all news articles via the `v1/all` endpoint.
Installation (currently, only tested for Python 3.11):
```bash
pip install perigon-news-wrapper
```
## Basic Usage
To initialize the API, import the package and add your API key:
```python
from perigon_news_wrapper import PerigonAPI
# specify your credentials:
api_key = '...'
# initialize API:
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](https://docs.goperigon.com/reference/all-news) for a comprehensive list of parameters.
`get_articles()` returns a list of dictionaries, where each dictionary is the JSON of an individual article.
**Example:**
```python
# speciy **kwargs (recommend dict format):
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'
]
}
# get results, using payload as **kwargs:
results = api.get_articles(paginate=False, size=100, **payload)
```
## TODO
- [ ] Establish tests for other Python versions (only tested on Python 3.11).
- [ ] Add support for querying additional Perigon endpoints.
- [ ] Add support for parsing/saving results?
Raw data
{
"_id": null,
"home_page": "https://github.com/sean-doody/perigon_news_wrapper",
"name": "perigon-news-wrapper",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": null,
"author": "Sean Doody",
"author_email": "sean.t.doody@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/20/e9/83680e84eddbc11a7c2f92f140aa26d84f82b2ae1e5e07b1e5f928e88042/perigon_news_wrapper-0.0.3.tar.gz",
"platform": null,
"description": "# Perigon API Wrapper\n[](https://www.python.org)\n\nA minimalist Python wrapper for the [Perigon News API](https://www.goperigon.com/). Currently only supports querying all news articles via the `v1/all` endpoint.\n\nInstallation (currently, only tested for Python 3.11):\n\n```bash\npip install perigon-news-wrapper\n```\n\n## Basic Usage\n\nTo initialize the API, import the package and add your API key:\n\n```python\nfrom perigon_news_wrapper import PerigonAPI\n\n# specify your credentials:\napi_key = '...'\n\n# initialize API:\napi = PerigonAPI(api_key=api_key)\n\n```\n\nThe main method is `get_articles()`, which takes the following arguments:\n\n- `paginate [bool = True]`: Whether or not to paginate results (if multiple pages are available). Defaults to `True`.\n- `size [int = 100]`: The number of results to return per page. Defaults to `100` (maximum allowed by Perigon).\n- `**kwargs`: Arbitrary keyword arguments supported by the Perigon API. Consult the [API docs](https://docs.goperigon.com/reference/all-news) for a comprehensive list of parameters.\n\n`get_articles()` returns a list of dictionaries, where each dictionary is the JSON of an individual article.\n\n**Example:**\n\n```python\n# speciy **kwargs (recommend dict format):\npayload = {\n 'content': 'olympics AND usa AND gold',\n 'from': '2024-07-26',\n 'to': '2024-08-08',\n 'language': 'en', \n 'exclude_labels': [\n 'Non-news',\n 'Opinion',\n 'Fact Check',\n 'Roundup',\n 'Low Content'\n ]\n}\n\n# get results, using payload as **kwargs:\nresults = api.get_articles(paginate=False, size=100, **payload)\n```\n\n## TODO\n- [ ] Establish tests for other Python versions (only tested on Python 3.11).\n- [ ] Add support for querying additional Perigon endpoints.\n- [ ] Add support for parsing/saving results?",
"bugtrack_url": null,
"license": "MIT",
"summary": "A minimalist Python wrapper for the Perigon News API.",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/sean-doody/perigon_news_wrapper",
"Repository": "https://github.com/sean-doody/perigon_news_wrapper"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4d5dca1d6c9baf81a9f66c1b64ae7167419d163cd9602493415e33555db01908",
"md5": "e35e4dbc99d9f148e80519ae52855001",
"sha256": "6e6f2c58b9ca174abc0fd0c286a4666717991989ef327586e5ae2a3faff067f8"
},
"downloads": -1,
"filename": "perigon_news_wrapper-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e35e4dbc99d9f148e80519ae52855001",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 4849,
"upload_time": "2024-08-15T18:50:48",
"upload_time_iso_8601": "2024-08-15T18:50:48.765300Z",
"url": "https://files.pythonhosted.org/packages/4d/5d/ca1d6c9baf81a9f66c1b64ae7167419d163cd9602493415e33555db01908/perigon_news_wrapper-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "20e983680e84eddbc11a7c2f92f140aa26d84f82b2ae1e5e07b1e5f928e88042",
"md5": "cd70efad6568870caa3f49c9e0db078b",
"sha256": "b0aed70d8cff577cad2fb85a24f6467854a5b057ce2578f6a26556a9fd7eb652"
},
"downloads": -1,
"filename": "perigon_news_wrapper-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "cd70efad6568870caa3f49c9e0db078b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 4059,
"upload_time": "2024-08-15T18:50:50",
"upload_time_iso_8601": "2024-08-15T18:50:50.095596Z",
"url": "https://files.pythonhosted.org/packages/20/e9/83680e84eddbc11a7c2f92f140aa26d84f82b2ae1e5e07b1e5f928e88042/perigon_news_wrapper-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-15 18:50:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sean-doody",
"github_project": "perigon_news_wrapper",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "perigon-news-wrapper"
}