Perigon API
Project description
Perigon Python SDK
Python client for the Perigon API
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)
Wikipedia – search and filter pages (/v1/wikipedia)
Docs → https://docs.perigon.io/docs/wikipedia
# Search Wikipedia pages
wikipedia_result = api.search_wikipedia(
q="machine learning",
size=3,
sort_by="relevance"
)
# Filter by specific criteria
wikipedia_result = api.search_wikipedia(
q="artificial intelligence",
pageviews_from=100, # Only popular pages
)
Wikipedia vector search – semantic retrieval (/v1/vector/wikipedia)
Docs → https://docs.perigon.io/docs/vector-wikipedia
from perigon.models.wikipedia_search_params import WikipediaSearchParams
results = api.vector_search_wikipedia(
wikipedia_search_params=WikipediaSearchParams(
prompt="artificial intelligence and neural networks in computing",
size=3,
pageviews_from=100
)
)
| 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) |
| Search Wikipedia pages | api.search_wikipedia(q="machine learning", size=3, sort_by="relevance") |
| Wikipedia semantic search | api.vector_search_wikipedia(wikipedia_search_params=WikipediaSearchParams(prompt="artificial intelligence", size=3)) |
🔄 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perigon-1.6.0.tar.gz.
File metadata
- Download URL: perigon-1.6.0.tar.gz
- Upload date:
- Size: 98.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
541a98dd752ae33862571736afd4c5159213b1c7830ae9dd58ea7a2cef37550b
|
|
| MD5 |
57743909110973b4ded0c1cb97912990
|
|
| BLAKE2b-256 |
d80b7ba872743c13270cf3c546a0b10bd24b085e0a24c49b429144075946380e
|
Provenance
The following attestation bundles were made for perigon-1.6.0.tar.gz:
Publisher:
publish.yml on goperigon/perigon-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perigon-1.6.0.tar.gz -
Subject digest:
541a98dd752ae33862571736afd4c5159213b1c7830ae9dd58ea7a2cef37550b - Sigstore transparency entry: 1403819448
- Sigstore integration time:
-
Permalink:
goperigon/perigon-python@40211d8defa38a70b247d43cf4f5793a0b6b8f45 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/goperigon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@40211d8defa38a70b247d43cf4f5793a0b6b8f45 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file perigon-1.6.0-py3-none-any.whl.
File metadata
- Download URL: perigon-1.6.0-py3-none-any.whl
- Upload date:
- Size: 221.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de1fdf4a39b248fc28fd1b64317fb51f82cd196fc444c77ed2eeb73265a6d8a
|
|
| MD5 |
18ce000b1e2d9abff3404dd298d1d320
|
|
| BLAKE2b-256 |
7726b8a678365f880957413ac2f5c4070c8d98a23e34ea6f143be4d1292ae22d
|
Provenance
The following attestation bundles were made for perigon-1.6.0-py3-none-any.whl:
Publisher:
publish.yml on goperigon/perigon-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
perigon-1.6.0-py3-none-any.whl -
Subject digest:
0de1fdf4a39b248fc28fd1b64317fb51f82cd196fc444c77ed2eeb73265a6d8a - Sigstore transparency entry: 1403819554
- Sigstore integration time:
-
Permalink:
goperigon/perigon-python@40211d8defa38a70b247d43cf4f5793a0b6b8f45 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/goperigon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@40211d8defa38a70b247d43cf4f5793a0b6b8f45 -
Trigger Event:
workflow_dispatch
-
Statement type: