Examples
Real-world usage patterns for the Monopigi API, SDK, and CLI.
Due Diligence: Find All Public Activity for a Company
Look up a Greek company across all government data sources by VAT number:
from monopigi import MonopigiClient
with MonopigiClient() as client:
# Search by company name across all sources
results = client.search("ACME Constructions SA", limit=100)
print(f"Found {results.total} records across all sources")
for doc in results.results:
print(f" [{doc.source}] {doc.title} ({doc.published_at})")
# Entity resolution by VAT number (Enterprise tier)
entity = client.entity("123456789", type="afm")
Monitor Public Procurement
Track new procurement notices matching specific criteria:
# Watch for new hospital-related tenders (polls every 5 min)
monopigi watch "hospital procurement" --interval 300
# Export all procurement since start of year
monopigi export ted tenders_2026.csv --format csv --since 2026-01-01
With Python:
from monopigi import MonopigiClient
with MonopigiClient() as client:
# Find large procurement notices
for doc in client.search_iter("procurement", page_size=100):
if doc.source == "ted":
print(f"[TED] {doc.title}")
elif doc.source == "kimdis":
print(f"[KIMDIS] {doc.title}")
Export Government Decisions for Analysis
Export Diavgeia decisions to a Parquet file for analysis with pandas or polars:
from monopigi import MonopigiClient
with MonopigiClient() as client:
# Export all decisions from 2026
count = client.export(
"diavgeia",
"decisions_2026.parquet",
format="parquet",
since="2026-01-01"
)
print(f"Exported {count} decisions")
Then analyze with polars:
import polars as pl
df = pl.read_parquet("decisions_2026.parquet")
# Decisions by category
print(df.group_by("doc_category").len().sort("len", descending=True))
# Decisions per month
print(
df.with_columns(pl.col("published_at").str.slice(0, 7).alias("month"))
.group_by("month").len()
.sort("month")
)
Energy Sector Analysis
Analyze Greece's renewable energy permits:
from monopigi import MonopigiClient
with MonopigiClient() as client:
# Get all energy permits
permits = []
for doc in client.documents_iter("rae"):
permits.append(doc)
print(f"Total energy permits: {len(permits)}")
# Export for mapping (permits include GeoJSON coordinates)
client.export("rae", "energy_permits.json", format="json")
Batch Enrichment from a File
Search for multiple entities from a text file:
# One query per line
cat companies.txt | monopigi pipe --limit 5
Or in Python:
from monopigi import MonopigiClient
companies = [
"ACME SA",
"Hellenic Corp",
"Athens Medical Center",
]
with MonopigiClient() as client:
for company in companies:
results = client.search(company, limit=5)
print(f"\n{company}: {results.total} records found")
for doc in results.results:
print(f" [{doc.source}] {doc.title}")
Daily Data Pipeline
Build a daily pipeline that checks for new documents:
from datetime import datetime, timedelta
from monopigi import MonopigiClient
yesterday = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d")
with MonopigiClient() as client:
for source_name in ["ted", "diavgeia", "rae", "data_gov_gr"]:
docs = client.documents(source_name, since=yesterday, limit=1000)
print(f"{source_name}: {docs.total} new documents since {yesterday}")
# Process new documents
for doc in docs.documents:
# Your processing logic here
pass
Or use the CLI diff command:
# Show new documents since last check
monopigi diff ted
monopigi diff diavgeia
monopigi diff rae
Integrate with Polars
Convert API responses to DataFrames (requires pip install monopigi-sdk[polars]):
import polars as pl
from monopigi import MonopigiClient
with MonopigiClient() as client:
results = client.search("renewable energy")
# Convert to polars DataFrame
df = results.to_df()
print(df.head())
print(df.describe())
# Filter and analyze
ted_results = df.filter(pl.col("source") == "ted")
print(f"TED results: {len(ted_results)}")
Due Diligence Report by AFM
Run a full due diligence report on a company using its Greek VAT number (AFM):
import time
from monopigi import MonopigiClient
with MonopigiClient() as client:
# Create the report
report = client.reports.create(
entity_identifier="123456789",
identifier_type="afm",
)
print(f"Report {report.id} submitted, waiting for completion...")
# Poll until the report is ready
while report.status != "completed":
time.sleep(5)
report = client.reports.get(report.id)
print(f" status: {report.status}")
# Access the structured data
print(f"Report completed at {report.completed_at}")
print(report.report_json)
# Download PDF for stakeholders
pdf_bytes = client.reports.download_pdf(report.id)
with open(f"due-diligence-{report.entity_identifier}.pdf", "wb") as f:
f.write(pdf_bytes)
print("PDF saved.")
Or with the CLI:
# One-liner: create report, wait, download PDF
monopigi report create --identifier 123456789 --type afm --wait --pdf due-diligence.pdf
Set Up Procurement Alerts
Get notified when new public tenders match your criteria. This example creates an alert profile for hospital-related procurement above EUR 50,000 in TED and KIMDIS:
from monopigi import MonopigiClient
with MonopigiClient() as client:
# Create alert profile
profile = client.alerts.create_profile(
name="Hospital procurement > 50k",
filters={
"keywords": ["hospital", "medical equipment", "healthcare"],
"sources": ["ted", "kimdis"],
"min_value": 50000,
},
channels=["email", "webhook"],
webhook_url="https://your-app.example.com/hooks/procurement",
notify_email="procurement@example.com",
)
print(f"Alert profile created: {profile.id}")
print(f" Name: {profile.name}")
print(f" Channels: {profile.channels}")
# Check recent deliveries
deliveries = client.alerts.list_deliveries(limit=5)
print(f"\nRecent alerts: {deliveries.total}")
for d in deliveries.items:
print(f" {d.document_source_id} via {d.channel} ({d.delivery_status})")
Or with the CLI:
# Create the alert profile
monopigi alert create "Hospital procurement > 50k" \
--keywords hospital,"medical equipment",healthcare \
--sources ted,kimdis \
--min-value 50000 \
--channel email,webhook \
--webhook https://your-app.example.com/hooks/procurement \
--email procurement@example.com
# Check recent deliveries
monopigi alert deliveries
Monitor Entities for Compliance
Track a set of companies and get notified when any new government activity is detected:
from monopigi import MonopigiClient
ENTITIES_TO_MONITOR = [
{"identifier": "123456789", "type": "afm", "label": "Supplier Alpha"},
{"identifier": "987654321", "type": "afm", "label": "Contractor Beta"},
{"identifier": "Ministry of Health", "type": "name", "label": "MoH"},
]
with MonopigiClient() as client:
# Add entities to monitoring
for entity in ENTITIES_TO_MONITOR:
result = client.monitor.add_entity(
entity_identifier=entity["identifier"],
identifier_type=entity["type"],
label=entity["label"],
)
print(f"Now monitoring: {result.label} ({result.id})")
# Check for new events across all monitored entities
events = client.monitor.list_events(since="2026-03-01T00:00:00Z")
print(f"\n{events.total} events since March 2026:")
for ev in events.items:
print(f" [{ev.event_type}] {ev.summary}")
print(f" Entity: {ev.monitored_entity_id}")
print(f" Document: {ev.document_source_id}")
print(f" Detected: {ev.detected_at}")
# Acknowledge processed events
client.monitor.acknowledge_event(ev.id)
print(f" -> Acknowledged")
# Trigger a health report on a specific entity
entity_id = "d4e5f6a7-b8c9-0123-defa-234567890123"
report = client.monitor.entity_report(entity_id)
print(f"\nHealth report triggered: {report.report_id} ({report.status})")
Or with the CLI:
# Add entities
monopigi monitor add --identifier 123456789 --type afm --label "Supplier Alpha"
monopigi monitor add --identifier 987654321 --type afm --label "Contractor Beta"
# Check events
monopigi monitor events --since 2026-03-01
# Acknowledge an event
monopigi monitor ack e5f6a7b8-c9d0-1234-efab-345678901234
# Trigger health report
monopigi monitor report d4e5f6a7-b8c9-0123-defa-234567890123
Use with curl
All examples work with plain HTTP. No SDK required:
# Set your token
export TOKEN="mp_live_YOUR_KEY"
# List sources
curl -s -H "Authorization: Bearer $TOKEN" \
"https://api.monopigi.com/v1/sources" | jq '.[].name'
# Search
curl -s -H "Authorization: Bearer $TOKEN" \
"https://api.monopigi.com/v1/search?q=hospital&limit=5" | jq '.results[].title'
# Get stats
curl -s -H "Authorization: Bearer $TOKEN" \
"https://api.monopigi.com/v1/stats" | jq '.total_documents'
# Paginate through results
for offset in 0 100 200; do
curl -s -H "Authorization: Bearer $TOKEN" \
"https://api.monopigi.com/v1/ted/documents?limit=100&offset=$offset" \
| jq '.documents[].title'
done