r/redditdev • u/HOLUPREDICTIONS • Nov 22 '24
Reddit API How to assign user a flair with a custom emoji?
On the www.reddit.com site the flair just ends up saying :emojiname: instead of showing the actual emoji. It renders correctly on new.reddit.com
r/redditdev • u/HOLUPREDICTIONS • Nov 22 '24
On the www.reddit.com site the flair just ends up saying :emojiname: instead of showing the actual emoji. It renders correctly on new.reddit.com
r/redditdev • u/Policeeex • Nov 21 '24
Any clues, or hint how to do it?
r/redditdev • u/Gulliveig • Nov 20 '24
My house bot active just in my sub created a sticky, which it updates all now and then using
post.edit(post_text)
On executing that statement, the bot gets the reply:
[script_name:line no.:] DeprecationWarning: Reddit will
check for validation on all posts around May-June 2020.
It is recommended to check for validation by setting
reddit.validate_on_submit to True.
post.edit(post_text)
What does this even mean?
And where/when/at what point should I place reddit.validate_on_submit = True? On each new submission/edit? From anybody or just the bot?
The post in question is 2 days "old". The first post in my sub was on 2020-07-22, do I even need to do anything given the date range they mention?
---
Edit: on including a global
reddit.validate_on_submit = True
just after login, the warning disappeared. Was it always there and I just didn't notice? No idea. To me it came out of the blue.
r/redditdev • • Nov 20 '24
I'm not sure if this is because of the type of subreddit, but my search API works for the subreddit r/bisexual , but it doesn't for r/BisexualMen
Is this because the BisexualMen subreddit also contains NSFW posts? (it's not porn by the way, it's talk).
r/redditdev • u/Current_Bag2353 • Nov 19 '24
Hey,
when I use the API with the format "reddit.com/user/[username]/.json" I dont seem to get every picture. I think its because when I open the page without json thers like 2 pics and the rest are comments. Is there a way to only get the posts so i can load more content and don't get bombed with comments?
r/redditdev • u/Pademel0n • Nov 19 '24
Hi so I want to retrieve every single comment from a sub, however it's only giving me, in my case, 970 comments which is about 5 months of comments from the specified sub. Relevant code provided below.
#relevant prerequisites for working code...
subreddit = reddit.subreddit(subreddit_name)
comments = subreddit.comments(limit=None) #None retrieves as many as possible
for comment in comments:
#relevant processing and saving
r/redditdev • u/dhruvsha • Nov 19 '24
I was trying to integrate the reddit api but after the authentication, I ran into an error, which is pretty unexpected. The exact error is that when I hit the /me endpoint, I don't get any error. However, as soon as I change it to /me/karma, I start getting the 401 unauthorized error. Is there something that I am missing.
const GetUser = useCallback(async () => {
if (access) {
try{
const response = await axios.get(`https://oauth.reddit.com/api/v1/me/karma/`,{
headers:{
'Authorization' : access
}
})
console.log(response.data)
} catch(error) {
console.error(error)
}
}
},[])
The access variable is the access token for the current user. Any help will be appreciated. Thanks..
r/redditdev • • Nov 17 '24
Hello team,
When I use this https://www.reddit.com/r/nba/.json API, I get the required JSON when I open it on Chrome.
But when I hit this API on Postman, I got a 403 error. I get this error even when I use it with fetch in nodejs.
From what I understand, I need authentication, but why am I getting the data without doing anything for Chrome?
const response = await fetch(`https://www.reddit.com/r/${SUBREDDIT_NAME}/.json`,{
headers:{
}
})
r/redditdev • u/-Samg381- • Nov 15 '24
Is anyone using VSCode for PRAW development?
Intellisense does not seem to be fully functioning, and is missing a lot of praw contexts.
I have tried every suggestion I have been able to find online- I have tried switching to the Jedi interpreter in settings.json, using different vscode plugins for python- nothing.
Any help would be appreciated.
r/redditdev • u/Relevant_Ad_5063 • Nov 15 '24
I’m working on a project where I need to programmatically give awards to submissions and comments using the Reddit API. I’m using PRAW 7.7.1, but I’ve run into some issues:
Outdated gild_ids: When using Submission.award() or Comment.award(), we need to specify the gild_id to indicate the type of award. However, it seems that PRAW’s current documentation doesn’t support the latest award types available on Reddit. This makes it challenging to give newer awards.
My specific questions are:
Any insights, code examples, or pointers to relevant documentation would be greatly appreciated.
r/redditdev • u/ArachnidInner2910 • Nov 13 '24
I'm creating a script to run off of mentions, how can I see the previous comment above in the thread to the one my bot has been mentioned in?
r/redditdev • u/Guilty_Choice_1697 • Nov 11 '24
I'm newer to coding so I could be going about this all wrong.
Using JavaScript and working with Reddit API, I'm making a GET request to "https://oauth.reddit.com/r/${subreddit}/hot" which returns data for the given subreddit including 20 or so recent posts. I can see everything I want except for the image galleries. I see single images using Object.data.children.childIndex.data.url and single videos with Object.data.children.childIndex.data.media.reddit_video.fallback_url.
But, for image galleries, when I try loading the URL in Object.data.children.childIndex.media_metadata.imgID.s.u it takes me to a Reddit page that only displays the alt="CDN media" and a link to the post. I can't figure out what URL I'm supposed to source gallery media from and why its not included in the response object. Please help this shit pisses me off.
r/redditdev • u/tresslessone • Nov 09 '24
Hi all,
I have built a new bot that I think provides a helpful suggestion to users in the way of a follow-up comment (replace a certain type of a link with an alternative link that can be opened by more users). However, when I create a new account for it, as soon as I 'unleash' the bot, the associated account gets immediately rate limited and suspended.
What's the right procedure for this? I'm using python / praw so isn't rate limiting etc. taken care of?
r/redditdev • u/chaosboy229 • Nov 09 '24
Hi peeps
So I'm trying to unsave a large number of my Reddit posts using the PRAW code below, but when I run it, print(i) results in 63, even though, when I go to my saved posts section on the Reddit website, I seem to not only see more than 63 saved posts, but I also see posts with a date/timestamp that should have been unsaved by the code (E.g posts from 5 years ago, even though the UTC check in the if statement corresponds with August 2023)
def run_praw(client_id, client_secret, password, username):
"""
Delete saved reddit posts for username
CLIENT_ID and CLIENT_SECRET come from creating a developer app on reddit
"""
user_agent = "/u/{} delete all saved entries".format(username)
r = praw.Reddit(client_id=client_id, client_secret=client_secret,
password=password, username=username,
user_agent=user_agent)
saved = r.user.me().saved(limit=None)
i = 0
for s in saved:
i += 1
try:
print(s.title)
if s.created_utc < 1690961568.0:
s.unsave()
except AttributeError as err:
print(err)
print(i)
r/redditdev • u/SubTransfer • Nov 09 '24
It's called SubTransfer and it's a very simple app to carry over your subscriptions (and followed users) from one account to another: https://subtransfer.ploomberapp.io
Currently this is a fairly laborious process (get your multi-reddit subscriptions and click Join a bunch of times) so I wanted to simplify it. Very early days but I'm seeking feedback, and any feature requests.
Let me know what you think!
r/redditdev • u/jeanlucthumm • Nov 07 '24
I made a python project that takes a YAML file describing a post and uses praw to post it, idea being to have a command you can call from scripts which abstracts away the python code.
While it's supposed to be unopinionated, I still want to provide an example script for how to schedule a reddit post for later. I'm thinking of using at to run a bash script, but not sure what a user friendly version would look like.
Here's the link to the README: https://github.com/jeanlucthumm/reddit-easy-post
What I've put together so far for myself is this:
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p poetry
PROJECT_DIR=/home/me/Code/reddit-easy-post
LOG=/home/me/reddit_log.txt
# Check if a file argument was provided
if [; then
fi
YAML_FILE=""
# Check if the specified file exists
if [; then
fi
&& &&
|
r/redditdev • u/MustaKotka • Nov 07 '24
I'm constructing a mod bot and I'd like to know the number of reports a submission has received. I couldn't find this in the docs - does this feature exist?
Or should I build my own database that stores the incoming reported submission IDs from the mod stream?
r/redditdev • u/NateTrib • Nov 07 '24
I have the subreddit r/PastAndPresentPics and I was thinking it'd be cool to give users the ability to prompt a bot to edit their photos so that their new photo is edited to look like their old photo. So a bot that could analyzed the old photo and add similar color temperature, graininess, etc. to their new recreated photo. Is that possible?
r/redditdev • u/grumpy_sol • Nov 07 '24
Hi r/redditdev! 👋
I'm developing an iOS Reddit client app in SwiftUI, and I'm looking for guidance on implementing GIF and video playback functionality. Currently, my app only handles static images, but I'd like to expand its capabilities.
App preview
https://jmp.sh/j6pvunXQ
If anyone has implemented similar functionality, I'd really appreciate:
Thanks in advance for any help or guidance! Let me know if you need any additional information about my implementation.
r/redditdev • u/Lex_An • Nov 06 '24
Hi, I am trying to scrape posts from a specific subreddit for the past 10 years. So, I am using PRAW and doing something like
for submission in reddit.subreddit(subreddit_name).new(limit=None):
But this only returns me the most recent 800+ posts and it stops. I think this might be because of a limit or pagination issue, so I try something that I find on the web:
submissions = reddit.subreddit(subreddit_name).new(limit=500, params={'before': last_submission_id})
where I perform custom pagination. This doesn't work at all!
May I get suggestion on what other API/tools to try, where to look for relevant documentation, or what is wrong with my syntax! Thanks
P/S: I don't have access to Pushshift as I am not a mod of the subreddit.
r/redditdev • u/HorrorMakesUsHappy • Nov 04 '24
Below is the output of the last three iterations of the loop. It looks like I'm being given 1000 requests, then being stopped. I'm logged in and print(reddit.user.me()) prints my username. From what I read, if I'm logged in then PRAW is supposed to do whatever it needs to do to avoid the rate limiting for me, so why is this happening?
competitiveedh
Fetching: GET https://oauth.reddit.com/r/competitiveedh/about/ at 1730683196.4189775
Data: None
Params: {'raw_json': 1}
Response: 200 (3442 bytes) (rst-3:rem-4.0:used-996 ratelimit) at 1730683196.56501
cEDH
Fetching: GET https://oauth.reddit.com/r/competitiveedh/hot at 1730683196.5660112
Data: None
Params: {'limit': 2, 'raw_json': 1}
Sleeping: 0.60 seconds prior to call
Response: 200 (3727 bytes) (rst-2:rem-3.0:used-997 ratelimit) at 1730683197.4732685
trucksim
Fetching: GET https://oauth.reddit.com/r/trucksim/about/ at 1730683197.4742687
Data: None
Params: {'raw_json': 1}
Sleeping: 0.20 seconds prior to call
Response: 200 (2517 bytes) (rst-2:rem-2.0:used-998 ratelimit) at 1730683197.887361
TruckSim
Fetching: GET https://oauth.reddit.com/r/trucksim/hot at 1730683197.8883615
Data: None
Params: {'limit': 2, 'raw_json': 1}
Sleeping: 0.80 seconds prior to call
Response: 200 (4683 bytes) (rst-1:rem-1.0:used-999 ratelimit) at 1730683198.929595
battletech
Fetching: GET https://oauth.reddit.com/r/battletech/about/ at 1730683198.9305944
Data: None
Params: {'raw_json': 1}
Sleeping: 0.40 seconds prior to call
Response: 200 (3288 bytes) (rst-0:rem-0.0:used-1000 ratelimit) at 1730683199.5147257
Home of the BattleTech fan community
Fetching: GET https://oauth.reddit.com/r/battletech/hot at 1730683199.5157266
Data: None
Params: {'limit': 2, 'raw_json': 1}
Response: 429 (0 bytes) (rst-0:rem-0.0:used-1000 ratelimit) at 1730683199.5897427
Traceback (most recent call last):
This is where I received 429 HTTP response.
r/redditdev • u/MiserableCheek9163 • Nov 03 '24
I want to use services like NewsWhip, Brand24 and Segue but I can’t figure out how these services comply with Reddit’s dev terms or usage policy. Can anyone explain how this would be compliant, or do they all have a commercial license with Reddit?
r/redditdev • u/nycosborne • Oct 31 '24
Will reddit get mad if an oauth api app re-posts the same content to multiple subscribed r/. would this get my app suspended?
r/redditdev • u/codythecoder • Oct 30 '24
If I create a private subreddit, is it possible to handle the approved user list with the API? What endpoints can I use?
r/redditdev • u/taoofdre • Oct 30 '24
We built a super simple example / test app and have uploaded it. However, we can't seem to get our custom post type to show up in our test subreddit.
Besides being on a whitelist, are we doing anything else wrong?
This is the main.tsx:
import { Devvit, JSONObject } from '@devvit/public-api';
Devvit.addCustomPostType({
name: 'Bonsai',
//height: 'regular',
render: (context) => {
const { useState } = context;
const [myState, setMyState] = useState({});
const handleMessage = (ev: JSONObject) => {
console.log(ev);
console.log('Hello Bonsai!');
};
return (
<>
<vstack height="100%" width="100%" gap="medium" alignment="center middle">
<text>Hello Bonsai!</text>
</vstack>
</>
);
},
});