Videos
To my understanding, the changes mean that users with OAuth have 100 requests per minute - which satisfies my requirements. I've been looking around for some proper documentation about all this.
I found the following https://github.com/reddit-archive/reddit/wiki/OAuth2-Quick-Start-Example#first-steps that provides the curl command to get an access token and works fine. Is that all the documentation there is?
Is there anyway I can do the same via Praw (or should I just use the token from the above with Praw)? Additionally, the above resource doesn't show me how to access refresh tokens, is there a separate curl command for them?
I apologize if this is a stupid question but I can't seem to find any coherent docs and haven't used the API for a long time.
I spent waaaay too much time trying to do this. I am trying to use nodejs to make a bit but I can’t figure out how to do the authentication.
Do anyone have any tutorials or documentation I can follow?
Hello All,
I'm trying to learn how to use the Reddit API for non-anonymous API requests. I'm having trouble how to set up a dev environment that lets me actually request data (user, history, read api endpoints). I created a nodejs server that can successfully request authentication for the user and retrieve the appropriate access token, but I don't know how to use this server, or any other method, to use this token on the same dev machine due to CORS errors.
How do I go about developing with the Reddit API for a web app created in React? I'm using this opportunity to try to learn the Reddit API and React. Do I need to host a server elsewhere to be able to develop the actual user-facing web application?
Thanks in advance!
Hey guys! I've been loosely following what's been happening with the Reddit API changes. There's a few things I'm not fully understanding; I was hoping someone on here could help me out.
Disclaimer: I'm a software developer but have never interacted with the Reddit Data API.
From what I understand, Reddit is essentially going to start charging API users for access. I was reading these comments from the latest AMA with u/spez:
Effective July 1, 2023, the rate limits to use the Data API free of charge are:
100 queries per minute per OAuth client id if you are using OAuth authentication and 10 queries per minute if you are not using OAuth authentication.
and:
Effective July 1, 2023, the rate for apps that require higher usage limits is $0.24 per 1K API calls (less than $1.00 per user / month for a typical Reddit third-party app).
Some apps such as Apollo, Reddit is Fun, and Sync have decided this pricing doesn’t work for their businesses and will close before pricing goes into effect.
Just from these comments, it sounds to me like it would be possible to have an app that uses the user's own OAuth to call the API.
100 requests per minute sounds very reasonable. And then I started thinking, how else are these apps working today?
I saw that the Apollo developer made a GH repo available with the code for his app's backend. But, why does an app that is just a frontend for the Reddit API need to interface with its own backend? Do all of these 3rd-party apps have their own backend server that calls the Reddit API? What's the point of doing that?
Am I misunderstanding the free API tier and how a 3rd-party app could use it? Is there a reason why these apps need to use their own API key and not the end-users'?
I feel like I am definitely missing something here.
As of right now, you cannot retrieve a permanent access token. You have 2 options that come close.
The first is to request a "refresh" token when using the standard OAuth flow. That's what you're doing by sending "duration" as "permanent" in your code. The refresh token can be used to automatically retrieve new 1 hour access tokens without user intervention; the only manual steps are on the initial retrieval of the refresh token.
The second alternative, which applies only when writing a script for personal use, is to use the password grant type. The steps are described in more detail on reddit's "OAuth Quick Start" wiki page, but I'll summarize here:
- Create an OAuth client (under https://www.reddit.com/prefs/apps) with type = "script"
- Make a request to
https://www.reddit.com/api/v1/access_tokenwith POST parametersgrant_type=password&username=<USERNAME>&password=<PASSWORD>. Send your client ID and secret as HTTP basic authentication.<USERNAME>must be registered as a developer of the OAuth 2 client ID you send.
A client_id and client_secret can be generated for a reddit account by going to https://www.reddit.com/prefs/apps and creating an app:
The part I have hidden is my client_id.
Then you can use a client like praw to access reddit e.g. with Python:
import praw
r = praw.Reddit(client_id='insert id here',
client_secret='insert secret here',
user_agent='insert user agent')
page = r.subreddit('aww')
top_posts = page.hot(limit=None)
for post in top_posts:
print(post.title, post.ups)
You could use your current browser's user agent, which can be easily found by google searching "what is my user agent" (among other ways).