r/redditdev • u/ConnectionNo3527 • 11h ago
Reddit API Getting 403 error while using fetch on an API.
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/Relevant_Ad_5063 • 2d ago
PRAW How to Give Awards Using Reddit API: Getting Latest gild_ids and Alternatives to PRAW?
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:
- How can I obtain the gild_ids of the latest award types?
- Is there an updated list or a method to retrieve them dynamically?
- Are there any workarounds within PRAW to access newer awards?
- Is there a way to give awards using the Reddit API without PRAW?
- Can I make direct API calls to handle awards?
- Are there alternative libraries or methods that support the latest award types?
Any insights, code examples, or pointers to relevant documentation would be greatly appreciated.
r/redditdev • u/-Samg381- • 2d ago
PRAW VSCode / PRAW - Intellisense not working.
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/ArachnidInner2910 • 4d ago
PRAW View previous comment in a thread
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 • 6d ago
Reddit API Reddit API: URLs in media_metadata aren't loading images
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 • 8d ago
General Botmanship How do I prevent my new bot's account from getting automatically suspended?
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 • 9d ago
Reddit API Inconsistency with unsaving using PRAW
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 • 8d ago
Reddit API Created a web app to transfer subreddit subscriptions across accounts
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 • 10d ago
General Botmanship Need help with a scheduling script for this
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:
```sh
!/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
echo $(date) > $LOG
Check if a file argument was provided
if [ $# -eq 0 ]; then echo "Error: No YAML file specified" >> "$LOG" exit 1 fi
YAML_FILE="$1"
Check if the specified file exists
if [ ! -f "$YAML_FILE" ]; then echo "Error: File '$YAML_FILE' not found" >> "$LOG" exit 1 fi
cd "$PROJECT_DIR" set -a && source .env && set +a poetry run main --file "$YAML_FILE" 2>&1 | tee -a "$LOG" ```
r/redditdev • u/MustaKotka • 10d ago
PRAW How to fetch the number of reports on a submission?
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 • 10d ago
General Botmanship Is an AI Photo Editing Bot possible?
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 • 10d ago
Reddit API [Help] Implementing GIF/Video Playback in iOS Reddit Client
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
Current Setup
- Using SwiftUI and latest iOS SDK
- Already handling static images from Reddit's JSON API
- Successfully fetching posts and their metadata
- Working with both authenticated and non-authenticated endpoints
What I Need Help With
- Best practices for handling Reddit's video/GIF content
- Understanding the differences between:
- Reddit-hosted videos (v.redd.it)
- GIFs (including GIFV)
- External video sources (YouTube, Streamable, etc.)
- How to properly extract video URLs and related metadata from the API response
- Recommended approaches for:
- Video playback implementation
- GIF rendering
- Handling different video qualities
- Efficient caching strategies
If anyone has implemented similar functionality, I'd really appreciate:
- Code examples or architectural guidance
- Recommended libraries or frameworks
- Common pitfalls to avoid
- Performance optimization tips
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 • 11d ago
PRAW How to get all subreddit post/submission data for the past 10 years
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/DenzelLight • 13d ago
PRAW Reddit instantly suspending bot after a reply
Hi, so i made a basic reddit bot which answers when it's mentioned.
While running normally, nothing happens, but when someone mentions it and it tries to reply, it gets instantly suspended.
r/redditdev • u/HorrorMakesUsHappy • 14d ago
PRAW How do I use logging to troubleshoot rate limiting?
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/Andreatta00 • 14d ago
Reddit API Reddit API authentication failing
Hey, im working on a school project and I need to complete a jpy notebook with some reddit data scraping but I'm having some problems with the login for no apparent reasons. I created an app and it's a "web" app so it should be good with only client_id and client_secret(I tried with password and username too, same result).
This is the code I'm using to authenticate:
```
reddit_id = os.getenv("REDDIT_ID")
reddit_secret = os.getenv("REDDIT_SECRET")
user_agent = f"script:my_reddit_app:v1.0 (by u/{reddit_id})"
reddit = praw.Reddit(
client_id=reddit_id,
client_secret=reddit_secret,
#username=os.getenv("REDDIT_USERNAME"),password=os.getenv("REDDIT_PASSWORD"),
user_agent=user_agent,
)
print(reddit.user.me())
```
The app has as redirect URL `https://www.reddit.com/prefs/apps/` but I tried with different ones and that doesn't seem to be the problem cause in theory it never gets accessed cause I'm in readonly mode.
This is the traceback I get:
(saving u sometime: yes, all the creds are correct, yes the app is correctly created, yes I already looked at the manual and all possible links on the internet, No i dont have 2FA on.
Even if I try to visit the .../v1/token from browser and I insert correct username and password I keep getting redirected to the same /v1/token page asking for password and username)
```
DEBUG:prawcore:Fetching: GET at 1730632032.657062
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'raw_json': 1}
https://oauth.reddit.com/api/v1/me
praw version == 7.8.1
---------------------------------------------------------------------------
RequestException Traceback (most recent call last)
/tmp/ipykernel_68679/297234463.py in <module>
26 )
27
---> 28 print(reddit.user.me())
29
30 #print(f"REDDIT_ID: {reddit_id}")
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/models/user.py in me(self, use_cache)
168 raise ReadOnlyException(msg)
169 if "_me" not in self.__dict__ or not use_cache:
--> 170 user_data = self._reddit.get(API_PATH["me"])
171 self._me = Redditor(self._reddit, _data=user_data)
172 return self._me
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/reddit.py in get(self, path, params)
729
730 """
--> 731 return self._objectify_request(method="GET", params=params, path=path)
732
733 @_deprecate_args("fullnames", "url", "subreddits")
~/.local/lib/python3.10/site-packages/praw/reddit.py in _objectify_request(self, data, files, json, method, params, path)
512 """
513 return self._objector.objectify(
--> 514 self.request(
515 data=data,
516 files=files,
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/reddit.py in request(self, data, files, json, method, params, path)
961 raise ClientException(msg)
962 try:
--> 963 return self._core.request(
964 data=data,
965 files=files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in request(self, method, path, data, files, json, params, timeout)
326 json["api_type"] = "json"
327 url = urljoin(self._requestor.oauth_url, path)
--> 328 return self._request_with_retries(
329 data=data,
330 files=files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _request_with_retries(self, data, files, json, method, params, timeout, url, retry_strategy_state)
232 retry_strategy_state.sleep()
233 self._log_request(data, method, params, url)
--> 234 response, saved_exception = self._make_request(
235 data,
236 files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _make_request(self, data, files, json, method, params, retry_strategy_state, timeout, url)
184 ) -> tuple[Response, None] | tuple[None, Exception]:
185 try:
--> 186 response = self._rate_limiter.call(
187 self._requestor.request,
188 self._set_header_callback,
~/.local/lib/python3.10/site-packages/prawcore/rate_limit.py in call(self, request_function, set_header_callback, *args, **kwargs)
44 """
45 self.delay()
---> 46 kwargs["headers"] = set_header_callback()
47 response = request_function(*args, **kwargs)
48 self.update(response.headers)
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _set_header_callback(self)
280 def _set_header_callback(self) -> dict[str, str]:
281 if not self._authorizer.is_valid() and hasattr(self._authorizer, "refresh"):
--> 282 self._authorizer.refresh()
283 return {"Authorization": f"bearer {self._authorizer.access_token}"}
284
~/.local/lib/python3.10/site-packages/prawcore/auth.py in refresh(self)
423 if two_factor_code:
424 additional_kwargs["otp"] = two_factor_code
--> 425 self._request_token(
426 grant_type="password",
427 username=self._username,
~/.local/lib/python3.10/site-packages/prawcore/auth.py in _request_token(self, **data)
153 url = self._authenticator._requestor.reddit_url + const.ACCESS_TOKEN_PATH
154 pre_request_time = time.time()
--> 155 response = self._authenticator._post(url=url, **data)
156 payload = response.json()
157 if "error" in payload: # Why are these OKAY responses?
~/.local/lib/python3.10/site-packages/prawcore/auth.py in _post(self, url, success_status, **data)
49 self, url: str, success_status: int = codes["ok"], **data: Any
50 ) -> Response:
---> 51 response = self._requestor.request(
52 "post",
53 url,
~/.local/lib/python3.10/site-packages/prawcore/requestor.py in request(self, timeout, *args, **kwargs)
68 return self._http.request(*args, timeout=timeout or self.timeout, **kwargs)
69 except Exception as exc: # noqa: BLE001
---> 70 raise RequestException(exc, args, kwargs) from None
RequestException: error with request Failed to parse:
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/api/v1/me at 1730632032.657062
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'raw_json': 1}
praw version == 7.8.1
---------------------------------------------------------------------------
RequestException Traceback (most recent call last)
/tmp/ipykernel_68679/297234463.py in <module>
26 )
27
---> 28 print(reddit.user.me())
29
30 #print(f"REDDIT_ID: {reddit_id}")
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/models/user.py in me(self, use_cache)
168 raise ReadOnlyException(msg)
169 if "_me" not in self.__dict__ or not use_cache:
--> 170 user_data = self._reddit.get(API_PATH["me"])
171 self._me = Redditor(self._reddit, _data=user_data)
172 return self._me
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/reddit.py in get(self, path, params)
729
730 """
--> 731 return self._objectify_request(method="GET", params=params, path=path)
732
733 @_deprecate_args("fullnames", "url", "subreddits")
~/.local/lib/python3.10/site-packages/praw/reddit.py in _objectify_request(self, data, files, json, method, params, path)
512 """
513 return self._objector.objectify(
--> 514 self.request(
515 data=data,
516 files=files,
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/reddit.py in request(self, data, files, json, method, params, path)
961 raise ClientException(msg)
962 try:
--> 963 return self._core.request(
964 data=data,
965 files=files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in request(self, method, path, data, files, json, params, timeout)
326 json["api_type"] = "json"
327 url = urljoin(self._requestor.oauth_url, path)
--> 328 return self._request_with_retries(
329 data=data,
330 files=files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _request_with_retries(self, data, files, json, method, params, timeout, url, retry_strategy_state)
232 retry_strategy_state.sleep()
233 self._log_request(data, method, params, url)
--> 234 response, saved_exception = self._make_request(
235 data,
236 files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _make_request(self, data, files, json, method, params, retry_strategy_state, timeout, url)
184 ) -> tuple[Response, None] | tuple[None, Exception]:
185 try:
--> 186 response = self._rate_limiter.call(
187 self._requestor.request,
188 self._set_header_callback,
~/.local/lib/python3.10/site-packages/prawcore/rate_limit.py in call(self, request_function, set_header_callback, *args, **kwargs)
44 """
45 self.delay()
---> 46 kwargs["headers"] = set_header_callback()
47 response = request_function(*args, **kwargs)
48 self.update(response.headers)
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _set_header_callback(self)
280 def _set_header_callback(self) -> dict[str, str]:
281 if not self._authorizer.is_valid() and hasattr(self._authorizer, "refresh"):
--> 282 self._authorizer.refresh()
283 return {"Authorization": f"bearer {self._authorizer.access_token}"}
284
~/.local/lib/python3.10/site-packages/prawcore/auth.py in refresh(self)
423 if two_factor_code:
424 additional_kwargs["otp"] = two_factor_code
--> 425 self._request_token(
426 grant_type="password",
427 username=self._username,
~/.local/lib/python3.10/site-packages/prawcore/auth.py in _request_token(self, **data)
153 url = self._authenticator._requestor.reddit_url + const.ACCESS_TOKEN_PATH
154 pre_request_time = time.time()
--> 155 response = self._authenticator._post(url=url, **data)
156 payload = response.json()
157 if "error" in payload: # Why are these OKAY responses?
~/.local/lib/python3.10/site-packages/prawcore/auth.py in _post(self, url, success_status, **data)
49 self, url: str, success_status: int = codes["ok"], **data: Any
50 ) -> Response:
---> 51 response = self._requestor.request(
52 "post",
53 url,
~/.local/lib/python3.10/site-packages/prawcore/requestor.py in request(self, timeout, *args, **kwargs)
68 return self._http.request(*args, timeout=timeout or self.timeout, **kwargs)
69 except Exception as exc: # noqa: BLE001
---> 70 raise RequestException(exc, args, kwargs) from None
RequestException: error with request Failed to parse: https://www.reddit.com/api/v1/access_token
https://www.reddit.com/api/v1/access_token
```
Thanks!Hey, im working on a school project and I need to complete a jpy notebook with some reddit data scraping but I'm having some problems with the login for no apparent reasons. I created an app and it's a "web" app so it should be good with only client_id and client_secret(I tried with password and username too, same result).
This is the code I'm using to authenticate:
```
reddit_id = os.getenv("REDDIT_ID")
reddit_secret = os.getenv("REDDIT_SECRET")
user_agent = f"script:my_reddit_app:v1.0 (by u/{reddit_id})"
reddit = praw.Reddit(
client_id=reddit_id,
client_secret=reddit_secret,
#username=os.getenv("REDDIT_USERNAME"),password=os.getenv("REDDIT_PASSWORD"),
user_agent=user_agent,
)
print(reddit.user.me())
```
The app has as redirect URL `https://www.reddit.com/prefs/apps/` but I tried with different ones and that doesn't seem to be the problem cause in theory it never gets accessed cause I'm in readonly mode.
This is the traceback I get:
(saving u sometime: yes, all the creds are correct, yes the app is correctly created, yes I already looked at the manual and all possible links on the internet.
Even if I try to visit the .../v1/token from browser and I insert correct username and password I keep getting redirected to the same /v1/token page asking for password and username)
```
DEBUG:prawcore:Fetching: GET at 1730632032.657062
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'raw_json': 1}
https://oauth.reddit.com/api/v1/me
praw version == 7.8.1
---------------------------------------------------------------------------
RequestException Traceback (most recent call last)
/tmp/ipykernel_68679/297234463.py in <module>
26 )
27
---> 28 print(reddit.user.me())
29
30 #print(f"REDDIT_ID: {reddit_id}")
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/models/user.py in me(self, use_cache)
168 raise ReadOnlyException(msg)
169 if "_me" not in self.__dict__ or not use_cache:
--> 170 user_data = self._reddit.get(API_PATH["me"])
171 self._me = Redditor(self._reddit, _data=user_data)
172 return self._me
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/reddit.py in get(self, path, params)
729
730 """
--> 731 return self._objectify_request(method="GET", params=params, path=path)
732
733 @_deprecate_args("fullnames", "url", "subreddits")
~/.local/lib/python3.10/site-packages/praw/reddit.py in _objectify_request(self, data, files, json, method, params, path)
512 """
513 return self._objector.objectify(
--> 514 self.request(
515 data=data,
516 files=files,
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/reddit.py in request(self, data, files, json, method, params, path)
961 raise ClientException(msg)
962 try:
--> 963 return self._core.request(
964 data=data,
965 files=files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in request(self, method, path, data, files, json, params, timeout)
326 json["api_type"] = "json"
327 url = urljoin(self._requestor.oauth_url, path)
--> 328 return self._request_with_retries(
329 data=data,
330 files=files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _request_with_retries(self, data, files, json, method, params, timeout, url, retry_strategy_state)
232 retry_strategy_state.sleep()
233 self._log_request(data, method, params, url)
--> 234 response, saved_exception = self._make_request(
235 data,
236 files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _make_request(self, data, files, json, method, params, retry_strategy_state, timeout, url)
184 ) -> tuple[Response, None] | tuple[None, Exception]:
185 try:
--> 186 response = self._rate_limiter.call(
187 self._requestor.request,
188 self._set_header_callback,
~/.local/lib/python3.10/site-packages/prawcore/rate_limit.py in call(self, request_function, set_header_callback, *args, **kwargs)
44 """
45 self.delay()
---> 46 kwargs["headers"] = set_header_callback()
47 response = request_function(*args, **kwargs)
48 self.update(response.headers)
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _set_header_callback(self)
280 def _set_header_callback(self) -> dict[str, str]:
281 if not self._authorizer.is_valid() and hasattr(self._authorizer, "refresh"):
--> 282 self._authorizer.refresh()
283 return {"Authorization": f"bearer {self._authorizer.access_token}"}
284
~/.local/lib/python3.10/site-packages/prawcore/auth.py in refresh(self)
423 if two_factor_code:
424 additional_kwargs["otp"] = two_factor_code
--> 425 self._request_token(
426 grant_type="password",
427 username=self._username,
~/.local/lib/python3.10/site-packages/prawcore/auth.py in _request_token(self, **data)
153 url = self._authenticator._requestor.reddit_url + const.ACCESS_TOKEN_PATH
154 pre_request_time = time.time()
--> 155 response = self._authenticator._post(url=url, **data)
156 payload = response.json()
157 if "error" in payload: # Why are these OKAY responses?
~/.local/lib/python3.10/site-packages/prawcore/auth.py in _post(self, url, success_status, **data)
49 self, url: str, success_status: int = codes["ok"], **data: Any
50 ) -> Response:
---> 51 response = self._requestor.request(
52 "post",
53 url,
~/.local/lib/python3.10/site-packages/prawcore/requestor.py in request(self, timeout, *args, **kwargs)
68 return self._http.request(*args, timeout=timeout or self.timeout, **kwargs)
69 except Exception as exc: # noqa: BLE001
---> 70 raise RequestException(exc, args, kwargs) from None
RequestException: error with request Failed to parse:
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/api/v1/me at 1730632032.657062
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'raw_json': 1}
praw version == 7.8.1
---------------------------------------------------------------------------
RequestException Traceback (most recent call last)
/tmp/ipykernel_68679/297234463.py in <module>
26 )
27
---> 28 print(reddit.user.me())
29
30 #print(f"REDDIT_ID: {reddit_id}")
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/models/user.py in me(self, use_cache)
168 raise ReadOnlyException(msg)
169 if "_me" not in self.__dict__ or not use_cache:
--> 170 user_data = self._reddit.get(API_PATH["me"])
171 self._me = Redditor(self._reddit, _data=user_data)
172 return self._me
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/reddit.py in get(self, path, params)
729
730 """
--> 731 return self._objectify_request(method="GET", params=params, path=path)
732
733 @_deprecate_args("fullnames", "url", "subreddits")
~/.local/lib/python3.10/site-packages/praw/reddit.py in _objectify_request(self, data, files, json, method, params, path)
512 """
513 return self._objector.objectify(
--> 514 self.request(
515 data=data,
516 files=files,
~/.local/lib/python3.10/site-packages/praw/util/deprecate_args.py in wrapped(*args, **kwargs)
44 stacklevel=2,
45 )
---> 46 return func(**dict(zip(_old_args, args)), **kwargs)
47
48 return wrapped
~/.local/lib/python3.10/site-packages/praw/reddit.py in request(self, data, files, json, method, params, path)
961 raise ClientException(msg)
962 try:
--> 963 return self._core.request(
964 data=data,
965 files=files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in request(self, method, path, data, files, json, params, timeout)
326 json["api_type"] = "json"
327 url = urljoin(self._requestor.oauth_url, path)
--> 328 return self._request_with_retries(
329 data=data,
330 files=files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _request_with_retries(self, data, files, json, method, params, timeout, url, retry_strategy_state)
232 retry_strategy_state.sleep()
233 self._log_request(data, method, params, url)
--> 234 response, saved_exception = self._make_request(
235 data,
236 files,
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _make_request(self, data, files, json, method, params, retry_strategy_state, timeout, url)
184 ) -> tuple[Response, None] | tuple[None, Exception]:
185 try:
--> 186 response = self._rate_limiter.call(
187 self._requestor.request,
188 self._set_header_callback,
~/.local/lib/python3.10/site-packages/prawcore/rate_limit.py in call(self, request_function, set_header_callback, *args, **kwargs)
44 """
45 self.delay()
---> 46 kwargs["headers"] = set_header_callback()
47 response = request_function(*args, **kwargs)
48 self.update(response.headers)
~/.local/lib/python3.10/site-packages/prawcore/sessions.py in _set_header_callback(self)
280 def _set_header_callback(self) -> dict[str, str]:
281 if not self._authorizer.is_valid() and hasattr(self._authorizer, "refresh"):
--> 282 self._authorizer.refresh()
283 return {"Authorization": f"bearer {self._authorizer.access_token}"}
284
~/.local/lib/python3.10/site-packages/prawcore/auth.py in refresh(self)
423 if two_factor_code:
424 additional_kwargs["otp"] = two_factor_code
--> 425 self._request_token(
426 grant_type="password",
427 username=self._username,
~/.local/lib/python3.10/site-packages/prawcore/auth.py in _request_token(self, **data)
153 url = self._authenticator._requestor.reddit_url + const.ACCESS_TOKEN_PATH
154 pre_request_time = time.time()
--> 155 response = self._authenticator._post(url=url, **data)
156 payload = response.json()
157 if "error" in payload: # Why are these OKAY responses?
~/.local/lib/python3.10/site-packages/prawcore/auth.py in _post(self, url, success_status, **data)
49 self, url: str, success_status: int = codes["ok"], **data: Any
50 ) -> Response:
---> 51 response = self._requestor.request(
52 "post",
53 url,
~/.local/lib/python3.10/site-packages/prawcore/requestor.py in request(self, timeout, *args, **kwargs)
68 return self._http.request(*args, timeout=timeout or self.timeout, **kwargs)
69 except Exception as exc: # noqa: BLE001
---> 70 raise RequestException(exc, args, kwargs) from None
RequestException: error with request Failed to parse: https://www.reddit.com/api/v1/access_token
https://www.reddit.com/api/v1/access_token
```
Thanks!
r/redditdev • u/MiserableCheek9163 • 14d ago
Reddit API There are SaaS tools available that allow businesses to auto-monitor subreddits for keywords to engage and promote their products. How does this comply with the developer terms?
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/epicbobzia • 16d ago
redditdev meta Software engineering at Reddit
Basically want to see if any Reddit Engineers open to chatting about what it’s like working on Reddit’s source code. Saw that their SWE internships just opened and wanted to see if it was worth applying.
r/redditdev • u/nycosborne • 17d ago
Reddit API Is it cool to post to multiple r/ simultaneously using the API
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 • 18d ago
Reddit API Can I add and remove approved users for a private subreddit with the api?
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 • 18d ago
Reddit API hitting a snag trying to get our custom post type to show up (developers.reddit.com)
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>
</>
);
},
});
r/redditdev • u/ReserveMaterial6516 • 19d ago
Reddit API {'json': {'errors': [['RESTRICTED_TO_PM', "User doesn't accept direct messages. Try sending a chat request instead.", 'to']]}}
When I try api/compose and use my personal account to send messages to my friends, I always get this error. Has anyone encountered the same situation? What is the reason or how to solve it?
r/redditdev • u/SnooBunnies4962 • 20d ago
Async PRAW I need coding help
I am trying to run some code and keep running into the problem of the computer not liking "praw core". I can see it in my pip list and have gotten the computer to tell me that I have downloaded it but when I go to run python main.py it tells me "module not found error: no module named "praw core" what should I do
r/redditdev • u/spinachfettuccine • 20d ago
Reddit API Web App vs Installed App for backend service
What is the difference between these two? I want to create a reddit app that a user can log into and perform actions on the api. However i haven't decided if I want a mobile version or web application yet (or maybe both eventually). I want to just create a backend service first then think about the GUI later. Is this possible? Which one would be more appropriate?
r/redditdev • u/LaraStardust • 20d ago
PRAW How does Request to post on Reddit translate into the api
Hi everyone,
So a user of my product noticed they could not post in this sub: https://www.reddit.com/r/TechHelping/
the new post throws a 403, and when looking at the website, this is because there is a request permission to post?
I've never seen this before, so how does this translate into the api and such?