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.1.tar.gz (61.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.1-py3-none-any.whl (148.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: perigon-1.0.1.tar.gz
  • Upload date:
  • Size: 61.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.1.tar.gz
Algorithm Hash digest
SHA256 6aeb010c20ec8a564d121c38b64afc9aef0fee625f09e9f97a2ef5688fd15ca8
MD5 32e070f522e45c9770f882592a232c2a
BLAKE2b-256 0d3b7f76bc370fe7266fd0dc4f71ab55b6de8dc417d2e7642173802fedca5220

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: perigon-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 148.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45ea905d0542ae57741599542a646caf72ad7f7ef5cd9ba08092fc457ba117aa
MD5 aca0bc60d4ffa155071dd16077f8e99c
BLAKE2b-256 a2f201defd47509e398224ea51be91b4c73defd45d8dc1b23b73c83858800475

See more details on using hashes here.

Provenance

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