Documentazione
Introduzione
AletheIA Central è una piattaforma centralizzata che funge da marketplace per fonti PDF condivise tra tutti i sistemi AletheIA registrati.
Questa piattaforma permette ai sistemi AletheIA di:
- Registrarsi e ottenere credenziali API
- Esplorare e filtrare fonti PDF verificate
- Sottoscrivere fonti per la sincronizzazione automatica
- Monitorare statistiche e performance
Configurazione
1. Registrazione Sistema
Prima di poter utilizzare il marketplace, devi registrare il tuo sistema AletheIA:
POST /api/auth/register
Content-Type: application/json
{
"system_name": "AletheIA Production",
"organization": "La Tua Organizzazione",
"contact_email": "admin@example.com"
}
Risposta:
{
"success": true,
"system_id": "sys_1234567890",
"api_key": "ak_abcdefghijklmnopqrstuvwxyz",
"message": "Sistema registrato con successo"
}
Importante: Conserva l'API Key in modo sicuro. Non sarà più visibile dopo la registrazione.
2. Configurazione in AletheIA
Configura il tuo sistema AletheIA per connettersi a Central:
# Nel file .env di AletheIA
CENTRAL_API_URL=https://central.aletheia.io
CENTRAL_SYSTEM_ID=sys_1234567890
CENTRAL_API_KEY=ak_abcdefghijklmnopqrstuvwxyz
CENTRAL_SYNC_ENABLED=true
Autenticazione
Ogni richiesta API deve essere autenticata con un JWT token:
1. Ottenere un Token
POST /api/auth/token
Content-Type: application/json
{
"system_id": "sys_1234567890",
"api_key": "ak_abcdefghijklmnopqrstuvwxyz"
}
Risposta:
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_at": "2025-10-28T12:00:00Z"
}
2. Usare il Token
Includi il token nell'header Authorization di ogni richiesta:
GET /api/marketplace/sources
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
API Reference
Marketplace
| Endpoint | Metodo | Descrizione |
|---|---|---|
/api/marketplace/sources |
GET | Lista tutte le fonti PDF disponibili |
/api/marketplace/sources/:id |
GET | Dettagli di una fonte specifica |
/api/marketplace/sources/:id/subscribe |
POST | Sottoscrivi a una fonte |
/api/marketplace/sources/:id/unsubscribe |
POST | Annulla sottoscrizione |
/api/marketplace/subscriptions |
GET | Lista sottoscrizioni attive |
/api/marketplace/categories |
GET | Lista categorie disponibili |
Esempi
Esempio Python
import requests
class AletheiaCentralClient:
def __init__(self, base_url, system_id, api_key):
self.base_url = base_url
self.system_id = system_id
self.api_key = api_key
self.token = None
def authenticate(self):
"""Ottieni token JWT"""
response = requests.post(
f"{self.base_url}/api/auth/token",
json={
"system_id": self.system_id,
"api_key": self.api_key
}
)
data = response.json()
if data['success']:
self.token = data['token']
def get_sources(self, filters=None):
"""Recupera fonti disponibili"""
headers = {"Authorization": f"Bearer {self.token}"}
response = requests.get(
f"{self.base_url}/api/marketplace/sources",
headers=headers,
params=filters or {}
)
return response.json()
def subscribe_to_source(self, source_id):
"""Sottoscrivi a una fonte"""
headers = {"Authorization": f"Bearer {self.token}"}
response = requests.post(
f"{self.base_url}/api/marketplace/sources/{source_id}/subscribe",
headers=headers
)
return response.json()
# Utilizzo
client = AletheiaCentralClient(
base_url="https://central.aletheia.io",
system_id="sys_1234567890",
api_key="ak_abcdefghijklmnopqrstuvwxyz"
)
client.authenticate()
sources = client.get_sources({"language": "it", "featured": True})
print(f"Trovate {sources['total']} fonti")
Esempio cURL
# 1. Ottieni token
curl -X POST https://central.aletheia.io/api/auth/token \
-H "Content-Type: application/json" \
-d '{"system_id":"sys_1234567890","api_key":"ak_abcdefghijklmnopqrstuvwxyz"}'
# 2. Recupera fonti
curl -X GET https://central.aletheia.io/api/marketplace/sources \
-H "Authorization: Bearer YOUR_TOKEN_HERE"
# 3. Sottoscrivi a fonte
curl -X POST https://central.aletheia.io/api/marketplace/sources/1/subscribe \
-H "Authorization: Bearer YOUR_TOKEN_HERE"