Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

perigon-api-wrapper

Package Overview
Dependencies
Maintainers
0
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perigon-api-wrapper

A minimalist Python wrapper for the Perigon News API.

  • 0.1.0
  • PyPI
  • Socket score

Maintainers
0

Perigon API Wrapper

python

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-api-wrapper

Basic Usage

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

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 for a comprehensive list of parameters.

get_articles() returns a list of dictionaries, where each dictionary is the JSON of an individual article.

Example:

# 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?

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc