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.0.0.tar.gz (60.6 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.0.0-py3-none-any.whl (143.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for perigon-1.0.0.tar.gz
Algorithm Hash digest
SHA256 daac134bda467ddcfa39d2a955de84d2e7a053bc65ca7c3de154c9df36c9da4a
MD5 e29a3a8e8819d8ac2eceb381e195c6ea
BLAKE2b-256 f4279a4d81a84cfb331116de035636e06b2216be3ee6eed39b006a541b1c63fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for perigon-1.0.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.0.0-py3-none-any.whl.

File metadata

  • Download URL: perigon-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 143.5 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e72f9ee37cdabe88429aeb318a51b878950859ad7da8a218e5738fd54bc5b268
MD5 6249ec1c60266ff15ad140c054f1edbc
BLAKE2b-256 74f2d15bb6d67f2787a2515a484bf1934b2cec8f1d2078918f2964c5d8e47fe1

See more details on using hashes here.

Provenance

The following attestation bundles were made for perigon-1.0.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