Skip to main content

Perigon API

Project description

Perigon logo

Perigon Python SDK

Python client for the Perigon API

pypi version python versions pypi downloads tests status documentation license

A modern, fully‑typed Python SDK for the Perigon API, generated from the official OpenAPI specification.
Works in CPython 3.8+, PyPy, serverless runtimes, notebooks, and async frameworks.

Table of Contents


✨ Features

  • Type‑hinted request/response models powered by Pydantic
  • Async and sync support - choose the right approach for your application
  • Ships with PEP 561 type hints for excellent IDE integration
  • Generated directly from https://docs.perigon.io, so it's always in sync

📦 Installation

pip install perigon
# poetry add perigon
# pipx install perigon

🚀 Quick start

1. Instantiate the client

from perigon import V1Api, ApiClient

# Create client with API key
api = V1Api(ApiClient(api_key="YOUR_API_KEY"))

# Alternative: environment variable or callable
# api = V1Api(ApiClient(api_key=os.environ["PERIGON_API_KEY"]))
# api = V1Api(ApiClient(api_key=lambda: get_api_key_from_vault()))

2. Make calls

# 🔍 Search recent news articles (sync)
articles = api.search_articles(q="artificial intelligence", size=5)
print(articles.num_results, articles.articles[0].title)

# 👤 Look up a journalist by ID (sync)
journalist = api.get_journalist_by_id(id="123456")
print(journalist.name)

# 🔄 Use async variant for async applications
import asyncio

async def fetch_data():
    # Search articles asynchronously 
    articles = await api.search_articles_async(q="technology", size=5)
    
    # Look up journalist asynchronously
    journalist = await api.get_journalist_by_id_async(id="123456")
    
    return articles, journalist

# Run in async context
articles, journalist = asyncio.run(fetch_data())

All methods return typed objects with full IDE autocompletion support.


🧑‍💻 Endpoint examples

Articles – search and filter news (/v1/all)

Docs → https://docs.perigon.io/docs/overview

# Simple query
articles = api.search_articles(q="technology", size=5)

# With date range
articles = api.search_articles(
    q="business", 
    var_from="2025-04-01",  # Note: 'from' is a reserved keyword in Python
    to="2025-04-08"
)

# Restrict to specific sources
articles = api.search_articles(source=["nytimes.com"])

Companies – fetch structured company data (/v1/companies)

Docs → https://docs.perigon.io/docs/company-data

results = api.search_companies(name="Apple", size=5)

Journalists – search and detail look‑up (/v1/journalists)

Docs → https://docs.perigon.io/docs/journalist-data

# Search for journalists
results = api.search_journalists1(name="Kevin", size=1)

# Get detailed information
journalist = api.get_journalist_by_id(id=results.journalists[0].id)

Stories – discover related article clusters (/v1/stories)

Docs → https://docs.perigon.io/docs/stories-overview

stories = api.search_stories(q="climate change", size=5)

Vector search – semantic retrieval (/v1/vector)

Docs → https://docs.perigon.io/docs/vector-endpoint

from perigon.models.article_search_params import ArticleSearchParams

results = api.vector_search_articles(
    article_search_params=ArticleSearchParams(
        prompt="Latest advancements in artificial intelligence",
        size=5
    )
)

Summarizer – generate an instant summary (/v1/summarizer)

Docs → https://docs.perigon.io/docs/search-summarizer

from perigon.models.summary_body import SummaryBody

summary = api.search_summarizer(
    summary_body=SummaryBody(prompt="Key developments"),
    q="renewable energy", 
    size=10
).summary

print(summary)

Topics – explore taxonomy (/v1/topics)

Docs → https://docs.perigon.io/docs/topics

topics = api.search_topics(size=10)
Action Code Example
Filter by source api.search_articles(source=["nytimes.com"])
Limit by date range api.search_articles(q="business", var_from="2025-04-01", to="2025-04-08")
Company lookup api.search_companies(name="Apple", size=5)
Summarize any query api.search_summarizer(summary_body=SummaryBody(prompt="Key points"), q="renewable energy", size=20)
Semantic / vector search api.vector_search_articles(article_search_params=ArticleSearchParams(prompt="advancements in AI", size=5))
Retrieve available taxonomic topics api.search_topics(size=10)

🔄 Async Support

All methods have async counterparts with the _async suffix:

import asyncio
from perigon import V1Api, ApiClient

async def main():
    api = V1Api(ApiClient(api_key="YOUR_API_KEY"))
    
    # Concurrent API calls
    articles_task = api.search_articles_async(q="technology", size=5)
    journalist_task = api.get_journalist_by_id_async(id="123456")
    
    # Gather results
    articles, journalist = await asyncio.gather(articles_task, journalist_task)
    
    return articles, journalist

# Run the async function
articles, journalist = asyncio.run(main())

🪪 License

MIT © Perigon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

perigon-1.1.0.tar.gz (73.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

perigon-1.1.0-py3-none-any.whl (179.9 kB view details)

Uploaded Python 3

File details

Details for the file perigon-1.1.0.tar.gz.

File metadata

  • Download URL: perigon-1.1.0.tar.gz
  • Upload date:
  • Size: 73.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for perigon-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2a6e93aa23d401ad8dbc628e33eb5b2a35c8972f5ea7386a7e016948e590eec5
MD5 9601e40c28fdfab28789dfb66dc35e2a
BLAKE2b-256 dcfae05fc16584c3e1584b3f9d85c6453f379607565b90d14fb6355df4991d1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for perigon-1.1.0.tar.gz:

Publisher: publish.yml on goperigon/perigon-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file perigon-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: perigon-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 179.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for perigon-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80e9b7de1dc334219b93a9207c00a43f8a7afcc9f84e348cfe31cef4fd39989c
MD5 c08b444f5f071c18005bddf7f7dd8e31
BLAKE2b-256 ce75392682bd796328f8e5f69850dfcdd8fd05c50f75cc4b6d3f11e12fd7b828

See more details on using hashes here.

Provenance

The following attestation bundles were made for perigon-1.1.0-py3-none-any.whl:

Publisher: publish.yml on goperigon/perigon-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page