Reddit API
L'API Reddit ti permette di cercare post di Reddit o recuperare un post completo con i suoi commenti in thread. Entrambi gli endpoint restituiscono JSON strutturato con subreddit, autore, punteggio, flair, premi e campi multimediali. Usalo per alimentare agenti consapevoli delle discussioni, monitoraggio del brand, analisi del sentiment o pipeline RAG che necessitano di contesto proveniente dalla comunità.
Endpoint
| Endpoint | Crediti | Descrizione |
|---|---|---|
POST /api/v1/reddit/search | 2 | Cerca post di Reddit per query, ordinamento e cursore di paginazione |
POST /api/v1/reddit/post | 2 | Ottieni un post completo con commenti in thread dall'URL del post Reddit |
Autenticazione
| Intestazione | Valore | Obbligatorio |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | Sì |
Content-Type | application/json | Sì |
Ricerca Post
POST https://api.scavio.dev/api/v1/reddit/searchCerca post di Reddit in tutto Reddit. Restituisce metadati del post tra cui titolo, URL, subreddit, autore, timestamp e flag NSFW. Supporta la paginazione tramite un token cursore.
Corpo della Richiesta
| Parametro | Tipo | Predefinito | Descrizione |
|---|---|---|---|
query | string | -- | Richiesto. Query di ricerca (1-500 caratteri). |
sort | string | relevance | Ordine di ordinamento. Uno tra: relevance, hot, top, new, comments |
cursor | string | -- | Token di paginazione dal campo nextCursor della risposta precedente. |
Esempio
curl -X POST 'https://api.scavio.dev/api/v1/reddit/search' \
-H 'Authorization: Bearer sk_live_your_key' \
-H 'Content-Type: application/json' \
-d '{
"query": "best python web frameworks 2026",
"sort": "new"
}'Esempio di Risposta
{
"data": {
"searchQuery": "best python web frameworks 2026",
"totalResults": 14,
"nextCursor": "eyJjYW5kaWRhdGVzX3JldH...",
"posts": [
{
"position": 0,
"id": "t3_1smb9du",
"title": "FastAPI vs Django in 2026 -- what the teams are actually using",
"url": "https://www.reddit.com/r/Python/comments/1smb9du/fastapi_vs_django/",
"subreddit": "Python",
"author": "python_dev",
"timestamp": "2026-04-15T16:34:40.389000+0000",
"nsfw": false
}
]
},
"response_time": 5200,
"credits_used": 2,
"credits_remaining": 498
}Paginazione
Per ottenere la pagina successiva, passa il valore di nextCursor dalla risposta precedente come parametro cursor nella tua prossima richiesta. Quando nextCursor è null, non ci sono più risultati.
Dettaglio Post
POST https://api.scavio.dev/api/v1/reddit/postRecupera un post completo di Reddit tramite il suo URL, inclusi corpo del post, metadati e albero completo dei commenti in thread. I commenti includono un campo depth che puoi utilizzare per ricostruire la gerarchia del thread.
Corpo della Richiesta
| Parametro | Tipo | Predefinito | Descrizione |
|---|---|---|---|
url | string | -- | Richiesto. URL completo del post Reddit (ad es. https://www.reddit.com/r/Python/comments/1smb9du/fastapi_vs_django/). |
Esempio
curl -X POST 'https://api.scavio.dev/api/v1/reddit/post' \
-H 'Authorization: Bearer sk_live_your_key' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://www.reddit.com/r/Python/comments/1smb9du/fastapi_vs_django/"
}'Esempio di Risposta
{
"data": {
"post": {
"id": "t3_1smb9du",
"title": "FastAPI vs Django in 2026 -- what the teams are actually using",
"body": "After a year of running both in production...",
"url": "https://www.reddit.com/r/Python/comments/1smb9du/fastapi_vs_django/",
"contentUrl": "https://www.reddit.com/r/Python/comments/1smb9du/fastapi_vs_django/",
"subreddit": "Python",
"author": "python_dev",
"score": 842,
"upvoteRatio": 0.97,
"numComments": 214,
"timestamp": "2026-04-15T16:34:40.389000+0000",
"flair": "Discussion",
"nsfw": false,
"awards": []
},
"comments": [
{
"id": "t1_lxs9a0k",
"author": "senior_py",
"body": "We moved to FastAPI for the API surface and kept Django for admin...",
"score": 312,
"depth": 0,
"timestamp": "2026-04-15T17:02:11.000000+0000",
"parentId": "t3_1smb9du"
},
{
"id": "t1_lxsa1b2",
"author": "django_dev",
"body": "Django ORM is still unmatched for anything with relational depth.",
"score": 178,
"depth": 1,
"timestamp": "2026-04-15T17:15:42.000000+0000",
"parentId": "t1_lxs9a0k"
}
]
},
"response_time": 8900,
"credits_used": 2,
"credits_remaining": 496
}Ricostruzione dell'Albero dei Commenti
I commenti vengono restituiti come un array piatto in ordine di attraversamento. Usa il campo depth (con indice 0) per l'indentazione visiva, o ricostruisci l'albero completo tramite il parentId di ciascun commento. Le risposte di primo livello hanno parentId uguale all'id del post (ad es. t3_…); le risposte nidificate hanno parentId uguale all'id di un altro commento (ad es. t1_…).
url vs contentUrl
url è il permalink canonico di Reddit per il post. contentUrl è l'URL che Reddit visualizza nel corpo del post -- per i post di link sarà l'articolo esterno, per i post di testo è uguale a url, e per i post di immagini/video è l'URL multimediale su i.redd.it o v.redd.it.
Formato della Risposta
Entrambi gli endpoint restituiscono un wrapper di risposta coerente:
| Campo | Tipo | Descrizione |
|---|---|---|
data | object | null | Il payload della risposta. null se la richiesta è fallita a monte. La ricerca restituisce {searchQuery, totalResults, nextCursor, posts}; il dettaglio post restituisce {post, comments}. |
response_time | number | Tempo di risposta lato server in millisecondi |
credits_used | number | Numero di crediti consumati (sempre 2 per gli endpoint Reddit) |
credits_remaining | number | Crediti rimanenti nel tuo attuale periodo di fatturazione |
Risposte di Errore
| Stato | Descrizione |
|---|---|
400 | Corpo della richiesta non valido -- mancante query / url, cursore errato o valore di ordinamento non supportato |
401 | Non autorizzato -- chiave API mancante o non valida |
429 | Limite di velocità o di utilizzo superato per il tuo piano |
502 | Errore a monte -- riprova dopo un breve ritardo |
503 | Servizio a monte non disponibile -- riprova più tardi |
504 | Timeout a monte -- Le richieste a Reddit possono richiedere 5-15 secondi; riprova con un timeout client più lungo |
Vedi Errori per il riferimento completo agli errori e le migliori pratiche di riprova.
Correlati
- Guida rapida -- ottieni la tua chiave API e effettua la tua prima richiesta
- API Ricerca Google -- cerca su Google con dati SERP strutturati
- API YouTube -- cerca video ed estrai metadati
- API Amazon -- cerca prodotti Amazon in 12 marketplace
- API Walmart -- cerca prodotti Walmart con filtri di evasione
- Limiti di velocità -- limiti per livello di piano