subredditstringobligatoire
Subreddit name without the r/ prefix (e.g. 'Fitness').
https://api.sandbase.ai/v1/api/reddit/subreddit-searchSearch posts within a single subreddit by query, sort, and timeframe.
Votre sortie apparaîtra ici
Complétez les entrées, puis cliquez sur Exécuter.
Returns Reddit posts from one subreddit that match a search query. It needs a subreddit name without the r/ prefix, and it accepts an optional query, sort and timeframe.
score or numComments to see which threads got the most attention.new.curl -X POST "https://api.sandbase.ai/v1/api/reddit/subreddit-search" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "push ups", "subreddit": "Fitness"}'
The result is returned in outputs[0].data.
| Name | Type | Required | Description |
|---|---|---|---|
subreddit | string | Yes | Subreddit name without the r/ prefix (e.g. 'Fitness'). |
cursor | string | No | Optional pagination token from a previous response. Include nextCursor in requireFields on the first request to make sure a source that supports pagination serves it. |
query | string | No | Optional search query to match posts (e.g. 'push ups'). |
requireFields | array | No | Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example nextCursor or selftext, and it is served only by a source that ret |
sort | string | No | Optional sort order: relevance, hot, top, new, comments. |
timeframe | string | No | Optional time filter: all, year, month, week, day, hour. |
Real response for the request above, trimmed: lists keep their first item and long strings are cut.
{
"data": {
"nextCursor": "cur_vSRO4dkJp_Wni4NIHlJvKQ",
"posts": [
{
"author": "Yea_Red",
"authorId": "j6hq9",
"createdUtc": 1428859519,
"id": "32cksu",
"nsfw": false,
"numComments": 528,
"permalink": "/r/Fitness/comments/32cksu/how_much_will_pushups_help_my_chest/",
"score": 2003,
"selftext": "I try to do 100 a day. Is this doing anything for me, or should I just focus on …",
"subreddit": "Fitness",
"title": "How much will push-ups help my chest?",
"url": "https://www.reddit.com/r/Fitness/comments/32cksu/how_much_will_pushups_help_my_c…"
}
]
},
"found": true
}
| Field | Meaning |
|---|---|
data.posts[].title | Title of the post. |
data.posts[].selftext | Body text of the post. Long text may be cut, and link posts may have none. |
data.posts[].score | Score of the post. |
data.posts[].numComments | Number of comments on the post. |
data.posts[].author / data.posts[].authorId | Username and ID of the post author. |
data.posts[].createdUtc | Creation time of the post as a Unix timestamp in seconds (UTC). |
data.posts[].id | Short ID of the post, such as 32cksu. |
data.posts[].permalink / data.posts[].url | Path and full URL of the post on Reddit. |
data.posts[].nsfw | true if the post is marked NSFW. |
data.nextCursor | Token to pass as cursor to get the next page of results. |
For a Python request example that keeps the search and comment parameters separate, follow the community-research tutorial.
Fitness.nextCursor to requireFields on the first request. Then send the returned data.nextCursor as cursor on the next call.selftext, isArchived or isLocked to requireFields if you need those fields on every post.Billed at the actual cost of each call, about $0.00035 for the request above. Failed calls are not charged.
Commencer à construire
Point de terminaison de l'API de la plateforme avec authentification unifiée et suivi de l'utilisation.
curl -X POST "https://api.sandbase.ai/v1/api/reddit/subreddit-search" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "push ups",
"subreddit": "Fitness"
}'Définissez votre clé API SandBase dans l'environnement de votre serveur. Les requêtes utilisent l'authentification Bearer.
export SANDBASE_API_KEY="YOUR_API_KEY"Conservez votre clé côté serveur. Ne l'exposez pas dans le code du navigateur.
subredditstringobligatoireSubreddit name without the r/ prefix (e.g. 'Fitness').
sortstringOptional sort order: relevance, hot, top, new, comments.
Valeurs possibles : relevance, hot, top, new, comments
querystringOptional search query to match posts (e.g. 'push ups').
cursorstringOptional pagination token from a previous response. Include `nextCursor` in requireFields on the first request to make sure a source that supports pagination serves it.
timeframestringOptional time filter: all, year, month, week, day, hour.
Valeurs possibles : all, year, month, week, day, hour
requireFieldsarrayOptional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `nextCursor` or `selftext`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. Name `nextCursor` only if you will fetch more than the first page: when you leave it out, a cheaper source that cannot paginate may serve the request, and its nextCursor is null, so there is no next page to ask for. A named field can still be absent on a post that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge. On a paginated walk it applies to the first page only; later pages stay with the source that page chose, at the price it was quoted.
Exemple de réponse enregistré pour cette API ; aucune requête en direct n'est effectuée lors de l'affichage.
Aucune réponse enregistrée n'a été publiée. Exécutez l'API dans Playground pour inspecter sa réponse.
Explorer plus
| API | Prix | Réponse |
|---|---|---|
Reddit Subreddit SearchCette API Reddit | À partir de $0.00035 par appel | JSON |
Reddit | $0.001 par appel | JSON |
Reddit | $0.001 par appel | JSON |
Reddit | $0.001 par appel | JSON |
Reddit | $0.001 par appel | JSON |
Reddit | $0.001 par appel | JSON |
Questions
Envoyez une requête POST à https://api.sandbase.ai/v1/api/reddit/subreddit-search avec votre clé API SandBase dans l’en-tête Authorization (Bearer) et les paramètres dans un corps JSON. Vous pouvez aussi l’essayer dans le Playground sur cette page sans écrire de code.
À partir de $0.00035 par appel, facturé depuis votre solde SandBase. Vous ne payez que les appels que vous effectuez ; aucun abonnement.
Obligatoire : subreddit (string). Facultatif : sort (l’un de relevance, hot, top, new, comments), query (string), cursor (string), timeframe (l’un de all, year, month, week, day, hour) et requireFields (array). Le tableau des paramètres et le Playground sur cette page listent tous les champs.
Une réponse JSON renvoyée dans la même requête HTTP (synchrone). Le README sur cette page inclut un exemple de réponse.
Non. Reddit Subreddit Search fonctionne via SandBase, donc une seule clé API SandBase couvre ce point de terminaison ainsi que toutes les autres API et tous les modèles du catalogue. Vous n’avez pas besoin de demander un accès API Reddit séparément.
Passez le nom de la communauté sans r/ dans subreddit, et mettez l’expression de recherche dans query. Cet endpoint accepte sort et timeframe ; utilisez les valeurs listées plutôt que les noms de paramètres de l’API Reddit officielle. Les endpoints Keyword Search et Dynamic Search de l’application ont des champs de requête différents.
Si vous avez besoin de pagination, demandez nextCursor dans requireFields lors du premier appel et vérifiez son prix indiqué : l’exigence de champ peut choisir une source plus coûteuse. Passez la valeur complète de data.nextCursor renvoyée comme cursor pour la page suivante. Les pages suivantes restent sur la source sélectionnée pour la première page. Sans cette exigence, une source moins chère peut ne renvoyer aucune continuation. Un champ demandé peut malgré tout être absent d’un post qui n’en dispose pas réellement. Ne réutilisez pas un cursor raccourci tiré d’un exemple de documentation.
Non. La référence autorise l’absence ou le raccourcissement de selftext, et les résultats de recherche ne sont qu’un échantillon, pas une archive complète de la discussion. Ouvrez le post sélectionné et utilisez l’endpoint Post Comments avec son URL lorsque vous avez besoin des réponses. Ne considérez pas un titre, un extrait ou un score comme un retour produit vérifié.