perigon-api-wrapper


Nameperigon-api-wrapper JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA minimalist Python wrapper for the Perigon News API.
upload_time2024-08-15 17:42:47
maintainerNone
docs_urlNone
authorSean Doody
requires_python<4.0,>=3.11
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Perigon API Wrapper
[![python](https://img.shields.io/badge/Python-3.11-3776AB.svg?style=flat&logo=python&logoColor=white)](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-api-wrapper
```

## Basic Usage

To initialize the API, import the package and add your API key:

```python
from perigon_api_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',
        'Face 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": null,
    "name": "perigon-api-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/61/d2/41d90933a75a3e964c527d3aec4f0272bd8a5053b204e75fbb41112b2368/perigon_api_wrapper-0.1.0.tar.gz",
    "platform": null,
    "description": "# Perigon API Wrapper\n[![python](https://img.shields.io/badge/Python-3.11-3776AB.svg?style=flat&logo=python&logoColor=white)](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-api-wrapper\n```\n\n## Basic Usage\n\nTo initialize the API, import the package and add your API key:\n\n```python\nfrom perigon_api_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        'Face 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.1.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "121ad66b71412801d7b9192d6947a47bf4b2784759795b8db11d222cba233c6d",
                "md5": "8d49d326cc4c7e994b4b905207dfe456",
                "sha256": "b214327fb535326f714690daaf3e98112a9093ff74b2e6a7374c36e3bd311830"
            },
            "downloads": -1,
            "filename": "perigon_api_wrapper-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d49d326cc4c7e994b4b905207dfe456",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 3958,
            "upload_time": "2024-08-15T17:42:46",
            "upload_time_iso_8601": "2024-08-15T17:42:46.152729Z",
            "url": "https://files.pythonhosted.org/packages/12/1a/d66b71412801d7b9192d6947a47bf4b2784759795b8db11d222cba233c6d/perigon_api_wrapper-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "61d241d90933a75a3e964c527d3aec4f0272bd8a5053b204e75fbb41112b2368",
                "md5": "857a80c5057ce2829bdb0d46f6c6d938",
                "sha256": "c1bf9b21f193196acc5d5445460938cd25b6edda46cb2387670b3f8ee45a7ddb"
            },
            "downloads": -1,
            "filename": "perigon_api_wrapper-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "857a80c5057ce2829bdb0d46f6c6d938",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 3279,
            "upload_time": "2024-08-15T17:42:47",
            "upload_time_iso_8601": "2024-08-15T17:42:47.134686Z",
            "url": "https://files.pythonhosted.org/packages/61/d2/41d90933a75a3e964c527d3aec4f0272bd8a5053b204e75fbb41112b2368/perigon_api_wrapper-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-15 17:42:47",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "perigon-api-wrapper"
}
        
Elapsed time: 1.44711s