Get a subreddit's info and posts
curl --request POST \
--url https://api.stophy.dev/v1/reddit/subreddit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subreddit": "AskReddit"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({subreddit: 'AskReddit'})
};
fetch('https://api.stophy.dev/v1/reddit/subreddit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.stophy.dev/v1/reddit/subreddit"
payload = { "subreddit": "AskReddit" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"success": true,
"data": {
"posts": [
{
"type": "post",
"url": "<string>",
"score": 0,
"comments": 0,
"isNsfw": true,
"isVideo": true,
"isPinned": true,
"id": "<string>",
"title": "<string>",
"text": "<string>",
"author": {
"id": "<string>",
"username": "<string>",
"name": "<string>",
"url": "<string>",
"avatar": "<string>",
"isVerified": true
},
"subreddit": "<string>",
"upvotePercent": 50,
"createdAt": "2023-11-07T05:31:56Z",
"flair": "<string>",
"link": {
"url": "<string>",
"title": "<string>",
"description": "<string>",
"image": "<string>"
},
"thumbnail": "<string>",
"images": [
{
"url": "<string>",
"caption": "<string>",
"alt": "<string>"
}
],
"video": {
"url": "<string>",
"hls": "<string>",
"durationSeconds": 123
},
"poll": {
"options": [
{
"text": "<string>",
"votes": 0
}
],
"totalVotes": 0,
"endsAt": "2023-11-07T05:31:56Z"
},
"repostOf": {
"id": "<string>",
"url": "<string>",
"subreddit": "<string>",
"title": "<string>"
}
}
],
"subreddit": {
"type": "subreddit",
"url": "<string>",
"isNsfw": true,
"id": "<string>",
"name": "<string>",
"title": "<string>",
"description": "<string>",
"members": 0,
"createdAt": "2023-11-07T05:31:56Z",
"avatar": "<string>",
"rules": [
{
"title": "<string>",
"description": "<string>"
}
]
},
"cursor": "<string>"
},
"creditsUsed": 123,
"requestId": "<string>"
}{
"success": false,
"error": {
"code": "cliSessionCompleted",
"message": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterSeconds": 123
}
}{
"success": false,
"error": {
"code": "cliSessionCompleted",
"message": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterSeconds": 123
}
}Reddit
Reddit subreddit API
Call the Reddit subreddit API to get subreddit and posts, as JSON or markdown. 2 credits.
POST
/
v1
/
reddit
/
subreddit
Get a subreddit's info and posts
curl --request POST \
--url https://api.stophy.dev/v1/reddit/subreddit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"subreddit": "AskReddit"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({subreddit: 'AskReddit'})
};
fetch('https://api.stophy.dev/v1/reddit/subreddit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.stophy.dev/v1/reddit/subreddit"
payload = { "subreddit": "AskReddit" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"success": true,
"data": {
"posts": [
{
"type": "post",
"url": "<string>",
"score": 0,
"comments": 0,
"isNsfw": true,
"isVideo": true,
"isPinned": true,
"id": "<string>",
"title": "<string>",
"text": "<string>",
"author": {
"id": "<string>",
"username": "<string>",
"name": "<string>",
"url": "<string>",
"avatar": "<string>",
"isVerified": true
},
"subreddit": "<string>",
"upvotePercent": 50,
"createdAt": "2023-11-07T05:31:56Z",
"flair": "<string>",
"link": {
"url": "<string>",
"title": "<string>",
"description": "<string>",
"image": "<string>"
},
"thumbnail": "<string>",
"images": [
{
"url": "<string>",
"caption": "<string>",
"alt": "<string>"
}
],
"video": {
"url": "<string>",
"hls": "<string>",
"durationSeconds": 123
},
"poll": {
"options": [
{
"text": "<string>",
"votes": 0
}
],
"totalVotes": 0,
"endsAt": "2023-11-07T05:31:56Z"
},
"repostOf": {
"id": "<string>",
"url": "<string>",
"subreddit": "<string>",
"title": "<string>"
}
}
],
"subreddit": {
"type": "subreddit",
"url": "<string>",
"isNsfw": true,
"id": "<string>",
"name": "<string>",
"title": "<string>",
"description": "<string>",
"members": 0,
"createdAt": "2023-11-07T05:31:56Z",
"avatar": "<string>",
"rules": [
{
"title": "<string>",
"description": "<string>"
}
]
},
"cursor": "<string>"
},
"creditsUsed": 123,
"requestId": "<string>"
}{
"success": false,
"error": {
"code": "cliSessionCompleted",
"message": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterSeconds": 123
}
}{
"success": false,
"error": {
"code": "cliSessionCompleted",
"message": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterSeconds": 123
}
}- Endpoint:
reddit.subreddit - Returns:
datahassubreddit,posts. - Cost: 2 credits. Failed calls cost nothing.
- Paging: Yes. Send the
cursorfrom the response to get the next page. See Paging.
Example
import { Stophy } from "stophy";
const stophy = new Stophy({ apiKey: process.env.STOPHY_API_KEY });
const result = await stophy.reddit.subreddit({ subreddit: "AskReddit" });
console.log(result.data.subreddit);
from stophy import Stophy
stophy = Stophy() # reads STOPHY_API_KEY
result = stophy.reddit.subreddit(subreddit="AskReddit")
print(result["data"]["subreddit"])
curl -X POST https://api.stophy.dev/v1/reddit/subreddit \
-H "Authorization: Bearer $STOPHY_API_KEY" \
-H "content-type: application/json" \
-d '{"subreddit":"AskReddit"}'
stophy reddit subreddit AskReddit
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json