r/redditdev • • Jun 05 '23

Reddit API Lets talk about those API calls

696 Upvotes

I'd like to take a couple minutes and talk about what exactly the API requests and app makes to Reddit to function and how fast they can add up.

Reddit's API that is used by third party applications has been around for a long time and hasn't seen all that many changes or improvements over the years, but that hasn't been a huge deal because a couple extra API calls didn't cost anything except bandwidth. For example, it's two separate API calls to check if you have any reddit messages vs your modmail messages. To view someone's profile it's 3 separate requests, one for their user info, one for their posts/comments, and one for their trophies. This wasn't a big deal until now when Reddit wants to start charging for API calls.

Lets take an imaginary journey and count up the API requests! Running total will be in parenthesis

Open up Reddit, API call for your front page, API call for your messages, API call for your modmail. + 3(3)

Upvote a post + 1(4)

Upvote another post + 1(5)

Open up the comments on a post + 1 (6)

Scroll through comment section and "load more" 3 different comment chains that got long +3 requests (9)

Vote on a couple comments +4 (13)

Leave a comment + 1 (14)

Should we check if there are messages again? + 2 (16)

Get another page of your frontpage + 1 (17)

Visit a specific subreddit. API call for the side bar/about. API call for the posts. +2 (19)

Check who the mods are + 1 (20)

Check out one of the poster's profiles. API call for user info, API call for posts/comments, API call for trophies +3 (23)

Follow links into a couple of their other comment sections + 2 (25)

Check for messages again + 2 (27)

Oh look, we got a message! Lets open view it +1 (28)

Okay we viewed it, lets mark the message as read + 1 (29)

Lets respond + 1 (30)

Go view another comment thread + 1 (31)

Oops, well that person is breaking the rules, lets report them + 1 (32)

I want to check for new comments on a thread + 1 (33)

We've done very little and we are up to 33 API requests already. As you can see, these add up in a HURRY when basically everything is an API request. That's not bashing on Reddit's API, that's just how ya know, the internet works... Go open your browser's developer tools sometime and check out the network tab.

But that's only 33 API calls you say! Reddit is only charging (at scale according to the Apollo dev ) ~ $2.50 per 10k requests. Well, lets put that into perspective using this hockey game thread which is maybe a bit larger since it's the Stanley Cup finals, but it's a good example I think.

It has over 10k comments. Since pushshift is dead I can't average the comment scores to get the number of average votes (ish) per comment, but we're gonna ball park it at, I dunno.. say 10. That feels low to me honestly just checking, but I don't want to over inflate this for the drama. Lets just pretend also that every vote was also a page refresh to get the new comments. Lets pad that just a bit for accounting for people loading deep comment threads and say that is another 10k. Give another 5k inbox checks (low I'm sure). And lets total it up..

10k comments + 10k * 10 votes + 10k page refreshes + 10k load more comments + 5k inbox checks = 135k API calls conservatively

(135k API calls / 10k calls) * $2.50 per 10k calls = $33.75

If that was all third party app usage, that thread would cost well north of $33.75 to create. I was honestly trying to dig in to how many ads this would approximately be, but it's not really feasible since the costs vary so wildly. Highly targetted ones can be $6 per 1000 views in the high end of the "recommended" spending range (suggested by reddit's ad system), or $.90 per click.. I dunno, it's all over the place.. needless to say it's a decent chunk of ads served/clicked to make up that kind of amount.

"Well that seems fair, I mean you said there were 10k comments right? So 10k impressions!"

Well, maybe.. viewing that thread on old reddit I'm not seeing any ads at all actually.. And max there might be one that shows up sometimes in the sidebar I don't honestly know. New Reddit I'm also not seeing any ads.. Is my long expired gold status still removing all the ads?? I don't know whats going on. I could have sworn there were at least some ads in the side bar usually.

Anyway.. I was trying to get at the point that not all api requests are equal in processing power or potential for lost ad revenue. I swear to god I will 3d print and blow up a snoo if they ever decided to put ads in my personal message box for example. But a call to get the posts for a subreddit does have a potential hit to displayed ads.

Reddit charging for a commercial third party to use and display their content is not inherently unreasonable. What is unreasonable is the costs that are currently proposed coupled with the ineffecient Reddit API that inflates necessary calls.

My last thing I wanted to address, and I might be burying the lede a bit here, is some of misleading, or downright inaccurate and untruthful claims that the admins have made in regards to these changes..

Apollo could reduce their cost by 3.5x if they were as efficient as these other 3P apps.

So I have not dug into Apollo specifically as I didn't have an iOS rooted device handy. BUT, my guess as to the "increased calls" is due to them more frequently checking if a user has messages, and/or less caching of comment sections and more re-pulling them for the latest on navigation. Could Apollo not check for messages as frequently? Sure.. Reddit is Fun used to check for messages on any refresh it seems, and they sometime somewhat recently seem to have changed that and for game day threads which I frequently use it for, I often miss responses to my comments for a very long time because it seems to only do it now every so often.

Usage graph

This one is kind of hilarious to me. So my (possibly mistaken) previous understanding and experience with the rate limits was that it was not requests per client id, it was requests per user of said client. So it's laughable to try and paint this is thousands of percent over the "limit" when the admins redefined what the limit was and in such a way that makes any multi-user app pretty much guarenteed to be in violation.

We are comparing events / user / day across apps with comparable engagement. Apollo is higher than the norm and higher than us.

Ok.. no... no they are not higher than you.. The only way that you get to claim they are higher than you is if you don't count your GQL api usage at all. Lets take a quick peak at the horrors of the Reddit official apps API calls.

* OAuth call for posts/comments
* OAuth call for categories for subreddit
* OAuth call for structured styles for sub
* OAuth call for similar subreddits
* GQL for pending invites?
* GQL for post guidelines
* GQL for if the subreddit is muted?
* GQL for other? subreddit styles
* GQL for posts/comments ...
* GQL for experiments
* GQL for devplatform
* GQL for user location

Yeah, that's not even close.. And pretty freakin funny when your GQL and Oauth calls overlap for the posts/comments. Also this doesn't even bring up the fact that it appears to spam the shit out of GQL calls for dev platform meta data as you are just scrolling down the comments. And the responses are all the same lol

This comment is a real doozy... Couple highlights...

Google & Amazon don’t tell us how to be more efficient. It’s up to us as users of these services to optimize our usage to meet our budget

Google and Amazon absolutely will help you use their platform effectively and reduce your costs with them. This is a complete and utter LIE.. Reddit you can't even see the number of API calls you are making. Google will literally hop on a call with you with an engineer and work with you to best use their platform....

On March 14th, Apollo made nearly 1 billion requests against our API in a single day, triggered in part by our system outage. After the outage, Apollo started making 53% fewer calls per day. If the app can operate with half the daily request volume, can it operate with fewer?

/preview/pre/xv20d0hp3p3b1.png?width=984&format=png&auto=webp&v=enabled&s=cd9e253d00dcf0c58057200141d66e9312550fd3

Well isn't that interesting.. Because according to the Apple store's page for Apollo, and the version history, the closest releases for Apollo were 2/22 and 4/7... none at all in March. So Reddit... why the decrease? Did you happen to fix something with how your system was logging calls from certain apps maybe? Did you break something? Cause sure doesn't look like it was on Apollo's end like you claim...

Edit: it was brought to my attention that Apollo does push notifications for messages even when you aren't using the app. This is almost certainly the main discrepancy between it and other apps API usage. And it could have been a back end change then related to the polling for those notifications that caused a reduction in API calls

In the end, the admins are currently at best misleading and misunderstanding about their API and it's usage, and at worst, outright lying. Limiting the NSFW adult content available to third party apps is pretty telling since there is literally no reason to do this except to try and drive people to their own official app. So I'm leaning towards they are lying about trying to kill off third party apps, but form your own opinions.

There are many alternative solutions to this and if Reddit was an actual, functional, grown up company, I don't see how they'd continuously wind up in these binds.

There should have been a dashboard at least to view API usage and it should have been in place with 2+ months of "example" billing data to let app developers adjust and figure things out.

Charging for all api requests equally is pretty dumb when your API is as poorly laid out as Reddit's is. Charge based on where you'd actually be losing revenue, not to check if a user has messages.

Have an offering that if the user has gold/premium the API rate limits don't count against the client id / are by user again

Etc etc etc.

Alright, I'm done. Congrats if you made it to the end.


r/redditdev • • Jun 08 '23

Reddit API Takeaways and recommendations after API meeting with /u/spez and Reddit

505 Upvotes

On Wednesday, a group of 18 developers and moderators met with spez and other Reddit staff regarding the upcoming API changes. Call notes were published by Reddit for the RedditModCouncil (here is an authorized public copy) with the action items noted by Reddit.

Several of us believe the officially published meeting notes, while generally following points from the meeting, do not fully express the concerns we shared on the call. Therefore, we would like to add our takeaways and recommendations. Each of these concerns was discussed during the meeting, but some of our recommendations were developed after the call. We are only speaking for ourselves and not for any subreddit or group of users.

Reddit is built as an open platform with a vibrant community of users: content creators, insightful commenters, lurkers, moderators, developers, and more. We don’t want to see that community get broken apart by solvable problems, miscommunication, and harried discussions.

  1. We don't believe enough effort and time has been given to the discussion and negotiation between Reddit and third-party apps and the schedule for these changes is not reasonable. We would like greater effort to find a solution that preserves the openness of Reddit, the utility of non-official implementations (and that utility includes, but is not limited to accessibility and mod tools), while addressing Reddit's concerns about costs being pushed entirely to Reddit and the lack of control around the ads being served with some third-party apps.

  2. The value of content creators, moderator labor, and Reddit's developer community needs to be considered alongside the costs of supporting the API and third-party apps. In our meeting, it was expressed multiple times how valuable we are, but this does not seem to have factored into any decisions about the API or third-party apps. The potential cost to Reddit of all of this labor is orders of magnitude higher than any of the costs that seem to be behind Reddit's decision-making on the API.

It's encouraging that Reddit is trying to improve moderation and accessibility in the official app. However, given past experience with these efforts and recognizing that independent developers have the freedom to solve community problems in ways that official software has been unable to replicate, Reddit should be making it easier for everyone to support their communities. That means supporting third-party apps, external APIs, and devvit.

3. Moderating on Reddit is challenging. Moderators are being told to strap on ankle weights when they are already running uphill. Reddit should not be making it more difficult to moderate healthy communities by forcing us into closed ecosystems and this abusive pattern of springing detrimental changes on moderators and their communities needs to stop.

4. Regarding Apollo, we think it's a mistake to focus this discussion on Apollo; all third-party apps need to be part of the discussion. But since Apollo was such a large part of the discussion, our takeaways were:

  • There was a lot of focus on Apollo's higher API cost compared to other apps. We're not the right group to address that, but it should have been brought to Apollo earlier and we find it hard to believe this is not a solvable issue. Reddit and Apollo should be working together to solve this rather than the current adversarial thing that is happening.

  • We haven't been privy to discussions between Apollo and Reddit, but it seems possible that spez has not received an accurate telling of the history of these discussions for one reason or another. An in-person discussion at a higher level of the company may be beneficial.

  1. There was also some discussion about how to better support accessibility in Reddit development. We are concerned that without dedicated and empowered individuals and teams to handle accessibility, it will continue to fall by the wayside.

  2. We believe the protests that some communities are planning are different from previous protests. The rug is being pulled out on users, developers, moderators, and communities.

Finally, we're just a group of concerned developers and moderators. We can't commit subreddits to do or not do anything. We're not even sure if communities where we moderate will or will not be participating in any protest. If there's a blackout or other protest, we think it's primarily a consequence of the way this has been handled and a failure to address these concerns.

Respectfully,

(names sorted lexicographically)


r/redditdev • • Jun 02 '23

Reddit API An open letter on the state of affairs regarding the API pricing and third party apps and how that will impact moderators and communities.

Thumbnail self.modcoord
347 Upvotes

r/redditdev • • Jun 01 '23

General Botmanship Reddit API pricing leads to the possible death of the Apollo reddit client

Thumbnail
self.apolloapp
316 Upvotes

r/redditdev • • Jun 16 '15

Reddit API reddit will soon only be available over HTTPS

273 Upvotes

Nearly 1 year ago we gave you the ability to view reddit completely over SSL. Now we're ready to enforce that everyone use a secure connection with reddit.

Please ensure that all of your scripts can perform all of their functions over HTTPS by June 29. At this time we will begin redirecting all site traffic to be over HTTPS and HTTP will no longer be available.

If this will be a problem for you, please let us know immediately.

EDIT 2015-08-21: IT IS DONE. You also have HSTS too.


r/redditdev • • Feb 02 '19

PRAW Submission Attributes Missing

256 Upvotes

Hey All,

This is my first time working with Praw and I'm noticing inconsistencies with the returned Submission objects.

Specifically 2 attributes I need, crosspost_parent and post_hint are not always an attribute on the instance.

Is the typical behavior or am I missing something?

It's especially annoying with post_hint since I need to classify the type of post. Out of ~1 million posts I've checked over 20k have not had a post_hint. That number is probably higher but I'm marking posts as Text if it's a self post, even if post_hint is missing.


r/redditdev • • Jun 08 '23

Redd I hope your happy Admins!! Popular Apollo to shutdown!

237 Upvotes

r/redditdev • • Jun 08 '23

Reddit API We're less then a month away from one of the biggest API changes and developers.reddit.com is still in waitlist mode

220 Upvotes

So we're less then a month away from one of the biggest API changes that will impact majority of clients, bots and tools. And yet:

  • developers.reddit.com the supposedly new place for managing your reddit applications is still in waitlist only mode.

  • We have no way of accurately seeing how many API requests our applications are making and to which endpoints. This is kinda a very important information, since you don't have full control over what happens in distributed apps.

  • Even if we want to pay, there's no way to setup payments right now, to guarantee a smooth transition.

If Reddit was actually serious about being "enterprise", this would have all been clear many months ahead.

What a joke.


r/redditdev • • Oct 19 '10

Meta Want to help reddit build a recommender? -- A public dump of voting data that our users have donated for research

197 Upvotes

As promised, here is the big dump of voting information that you guys donated to research. Warning: this contains much geekery that may result in discomfort for the nerd-challenged.

I'm trying to use it to build a recommender, and I've got some preliminary source code. I'm looking for feedback on all of these steps, since I'm not experienced at machine learning.

Here's what I've done

  • I dumped all of the raw data that we'll need to generate the public dumps. The queries are the comments in the two .pig files and it took about 52 minutes to do the dump against production. The result of this raw dump looks like:

    $ wc -l *.dump
     13,830,070 reddit_data_link.dump
    136,650,300 reddit_linkvote.dump
         69,489 reddit_research_ids.dump
     13,831,374 reddit_thing_link.dump
  • I filtered the list of votes for the list of users that gave us permission to use their data. For the curious, that's 67,059 users: 62,763 with "public votes" and 6,726 with "allow my data to be used for research". I'd really like to see that second category significantly increased, and hopefully this project will be what does it. This filtering is done by srrecs_researchers.pig and took 83m55.335s on my laptop.

  • I converted data-dumps that were in our DB schema format to a more useable format using srrecs.pig (about 13min)

  • From that dump I mapped all of the account_ids, link_ids, and sr_ids to salted hashes (using obscure() in srrecs.py with a random seed, so even I don't know it). This took about 13min on my laptop. The result of this, votes.dump is the file that is actually public. It is a tab-separated file consisting in:

    account_id,link_id,sr_id,dir

    There are 23,091,688 votes from 43,976 users over 3,436,063 links in 11,675 reddits. (Interestingly these ~44k users represent almost 17% of our total votes). The dump is 2.2gb uncompressed, 375mb in bz2.

What to do with it

The recommendations system that I'm trying right now turns those votes into a set of affinities. That is, "67% of user #223's votes on /r/reddit.com are upvotes and 52% on programming). To make these affinities (55m45.107s on my laptop):

 cat votes.dump | ./srrecs.py "affinities_m()" | sort -S200m | ./srrecs.py "affinities_r()" > affinities.dump

Then I turn the affinities into a sparse matrix representing N-dimensional co-ordinates in the vector space of affinities (scaled to -1..1 instead of 0..1), in the format used by R's skmeans package (less than a minute on my laptop). Imagine that this matrix looks like

          reddit.com pics       programming horseporn  bacon
          ---------- ---------- ----------- ---------  -----
ketralnis -0.5       (no votes) +0.45       (no votes) +1.0
jedberg   (no votes) -0.25      +0.95       +1.0       -1.0
raldi     +0.75      +0.75      +0.7        (no votes) +1.0
...

We build it like:

# they were already grouped by account_id, so we don't have to
# sort. changes to the previous step will probably require this
# step to have to sort the affinities first
cat affinities.dump | ./srrecs.py "write_matrix('affinities.cm', 'affinities.clabel', 'affinities.rlabel')"

I pass that through an R program srrecs.r (if you don't have R installed, you'll need to install that, and the package skmeans like install.packages('skmeans')). This program plots the users in this vector space finding clusters using a sperical kmeans clustering algorithm (on my laptop, takes about 10 minutes with 15 clusters and 16 minutes with 50 clusters, during which R sits at about 220mb of RAM)

# looks for the files created by write_matrix in the current directory
R -f ./srrecs.r

The output of the program is a generated list of cluster-IDs, corresponding in order to the order of user-IDs in affinities.clabel. The numbers themselves are meaningless, but people in the same cluster ID have been clustered together.

Here are the files

These are torrents of bzip2-compressed files. If you can't use the torrents for some reason it's pretty trivial to figure out from the URL how to get to the files directly on S3, but please try the torrents first since it saves us a few bucks. It's S3 seeding the torrents anyway, so it's unlikely that direct-downloading is going to go any faster or be any easier.

  • votes.dump.bz2 -- A tab-separated list of:

    account_id, link_id, sr_id, direction
  • For your convenience, a tab-separated list of votes already reduced to percent-affinities affinities.dump.bz2, formatted:

    account_id, sr_id, affinity (scaled 0..1)
  • For your convenience, affinities-matrix.tar.bz2 contains the R CLUTO format matrix files affinities.cm, affinities.clabel, affinities.rlabel

And the code

  • srrecs.pig, srrecs_researchers.pig -- what I used to generate and format the dumps (you probably won't need this)

  • mr_tools.py, srrecs.py -- what I used to salt/hash the user information and generate the R CLUTO-format matrix files (you probably won't need this unless you want different information in the matrix)

  • srrecs.r -- the R-code to generate the clusters

Here's what you can experiment with

  • The code isn't nearly useable yet. We need to turn the generated clusters into an actual set of recommendations per cluster, preferably ordered by predicted match. We probably need to do some additional post-processing per user, too. (If they gave us an affinity of 0% to /r/askreddit, we shouldn't recommend it, even if we predicted that the rest of their cluster would like it.)

  • We need a test suite to gauge the accuracy of the results of different approaches. This could be done by dividing the data-set in and using 80% for training and 20% to see if the predictions made by that 80% match.

  • We need to get the whole process to less than two hours, because that's how often I want to run the recommender. It's okay to use two or three machines to accomplish that and a lot of the steps can be done in parallel. That said we might just have to accept running it less often. It needs to run end-to-end with no user-intervention, failing gracefully on error

  • It would be handy to be able to idenfity the cluster of just a single user on-the-fly after generating the clusters in bulk

  • The results need to be hooked into the reddit UI. If you're willing to dive into the codebase, this one will be important as soon as the rest of the process is working and has a lot of room for creativity

  • We need to find the sweet spot for the number of clusters to use. Put another way, how many different types of redditors do you think there are? This could best be done using the aforementioned test-suite and a good-old-fashioned binary search.

Some notes:

  • I'm not attached to doing this in R (I don't even know much R, it just has a handy prebaked skmeans implementation). In fact I'm not attached to my methods here at all, I just want a good end-result.

  • This is my weekend fun project, so it's likely to move very slowly if we don't pick up enough participation here

  • The final version will run against the whole dataset, not just the public one. So even though I can't release the whole dataset for privacy reasons, I can run your code and a test-suite against it


r/redditdev • • Mar 02 '18

I built a website that allows you to download v.redd.it videos

181 Upvotes

Not sure if this is the right place to share, but anyways: I recently built a website/microservice that allows downloading of v.redd.it videos, including videos with audio.

https://redv.co

Since Reddit splits the video and audio signal, I had to build an AWS Lambda function that glues them back together. Maybe this is useful to anybody! If anyone cares to see some code, I'd be happy to share.

Also — if Reddit is not considering changing their current hosting strategy, I might also think about turning it into a public API. Wondering if there's any interest?


r/redditdev • • Jun 02 '23

Reddit API Concerns about Discontinuing Third-Party App Support and Increasing Prices for the Reddit API

156 Upvotes

Dear Reddit Team,

I hope this finds you well. I am writing to express my deep concerns regarding the recent decisions to discontinue support for third-party apps and to increase prices for the Reddit API. As a dedicated Reddit user and someone who values the diverse ecosystem that has flourished around the platform, I believe these actions would have significant negative consequences for the Reddit community as a whole. Allow me to outline my concerns below:

1. Limiting Innovation and User Experience:

Third-party apps have played a crucial role in enhancing the Reddit experience by providing unique features, improved interfaces, and specialized functionalities tailored to different user preferences. They have significantly contributed to the growth and engagement of the platform. By discontinuing support for these apps, you risk stifling innovation and limiting the ability of users to customize their Reddit experience. It is this diversity that has made Reddit such a vibrant and inclusive community.

2. Monopolizing Access and Control:

Increasing prices for the Reddit API could result in monopolizing access to Reddit data and functionality. Higher costs might discourage independent developers, startups, and smaller projects from integrating with Reddit, leading to a concentration of power in the hands of a few large organizations. This monopolization could diminish competition, limit user choice, and potentially create an environment where the platform's development becomes dependent on a single entity. It is important to maintain a level playing field for developers to foster innovation and healthy competition.

3. Fragmenting the Community:

By discontinuing third-party app support, you risk fragmenting the Reddit community. Many users have grown accustomed to specific apps that align with their preferences and needs. Removing these apps without providing viable alternatives could alienate these users and disrupt the sense of community that Reddit has fostered over the years. It is essential to consider the impact on users who have come to rely on these apps for their daily interactions and contributions.

4. Overburdening the Official App:

With the discontinuation of third-party app support, the burden on the official Reddit app would significantly increase. While the official app provides a solid foundation, many users have opted for third-party apps due to their additional features, improved usability, and personalized experiences. The sudden shift to solely relying on the official app could result in performance issues, slower updates, and potential limitations to handle the increased user load, leading to frustration among the user base.

Considering these concerns, I kindly request that Reddit reconsider its decision to stop supporting third-party apps and carefully evaluate the impact of increasing prices for the Reddit API. Instead, I encourage you to explore ways to collaborate with third-party developers, foster innovation, and create a sustainable environment that benefits the entire Reddit community.

I understand that managing a platform like Reddit involves complex decisions, but it is vital to prioritize the interests of the users and the community. By maintaining an open and supportive ecosystem, Reddit can continue to grow, adapt, and provide a unique and enriching experience for its users.

Thank you for taking the time to consider my concerns. I hope we can engage in a constructive dialogue to find solutions that uphold the values of Reddit and its diverse user base.

Sincerely,

The Entire Reddit Community


r/redditdev • • Aug 20 '12

Reddit API Proposed change to the 'users online' count for low values (<100)

126 Upvotes

Hola all,

As of right now, if the number of online users that are on a subreddit totals fewer than 100, the metric simply displays the value as "<100". I purposefully took a very conservative approach to this, as giving a more detailed metric for small count of active users has some potential privacy implications. For example, in a very small subreddit with a limited set of active users, you could do some analysis and an educated guess at when a group of those individuals are on reddit. The less active the subreddit, the more educated the guess. It's a bit of a reach, but I decided to err on the side of caution.

Since the feature was rolled out, the general response seems to be that people want minimum display value lowered. Here's my proposal on how to execute that, while still minimizing the potential privacy problems.

Just as it is now, the metric will be accurate for values of 100 or greater. However, if the true count is fewer than 100, a random jitter will be added to fuzz the true value. The jitter will be the largest for very small counts, and exponentially decreases as the true count increases, reaching a jitter of 0 when the true value is 100. For example, a true value of 0 may display anywhere from 0-6, a true value of 40 may display anywere from 40-43.

Additionally, low values will be cached on the back-end for 5 minutes. This prevents someone from rapidly sampling the fuzzed values to determine the true value.

I also recognize that some subreddits simply want to hide low values. To easily allow for this, I will also be adding a "fuzzed" CSS class to any value less than 100. This will allow subreddits to hide the low value fuzzed numbers, while still displaying higher values. Of course, the count can still be hidden entirely via CSS, just as it is now.

Please let me know any thoughts or concerns you might have regarding this proposed change.

cheers,

alienth

tl;dr Users-online will be display all the way down to zero, but low values will be fuzzed and cached for a period of 5 minutes to protect privacy.


r/redditdev • • Dec 08 '20

PRAW [PRAW] How to post directly to reddit, with a post that has a flair.

123 Upvotes

The title pretty much explains this, I have looked on the docs, but I am still struggling. Any help would be appreciated.

This is my code so far:

            t = subreddit.submit(title, text)
            t.set_flair('hello')
            t

r/redditdev • • Oct 25 '11

Meta Attempt #2: Want to help reddit build a recommender? -- A public dump of voting data that our users have donated for research

118 Upvotes

UPDATE 2: Join the Google Group to stay on top of progress! http://groups.google.com/group/rrecommender

I made a post about the Google Group here: http://www.reddit.com/r/redditdev/comments/mev1j/reddit_recommendor_google_group_to_coordinate/

UPDATE: User killerstorm & qubey are doing the coordination on the project. For admin assistance, please contact chromakode.

Update 3: My original suggestion and overview of the problem a year ago: http://www.reddit.com/r/redditdev/comments/d95ad/request_we_need_to_work_on_a_solution_to_the/


Hello Reddit developers! ketralnis wrote the following message below a year ago. After leaving reddit, the project got put on the back burner. We still have the same problem introducing people to new reddits and the reddit search is still terrible. After reading the recent reddit blog post about introducing more reddits into the default set, this project needs to be revived more than ever.

I am hoping you can help revive this project and make it a reality! Together, we can make reddit a better place.


As promised, here is the big dump of voting information that you guys donated to research. Warning: this contains much geekery that may result in discomfort for the nerd-challenged.

I'm trying to use it to build a recommender, and I've got some preliminary source code. I'm looking for feedback on all of these steps, since I'm not experienced at machine learning.

Here's what I've done

  • I dumped all of the raw data that we'll need to generate the public dumps. The queries are the comments in the two .pig files and it took about 52 minutes to do the dump against production. The result of this raw dump looks like:

    $ wc -l *.dump
     13,830,070 reddit_data_link.dump
    136,650,300 reddit_linkvote.dump
         69,489 reddit_research_ids.dump
     13,831,374 reddit_thing_link.dump
  • I filtered the list of votes for the list of users that gave us permission to use their data. For the curious, that's 67,059 users: 62,763 with "public votes" and 6,726 with "allow my data to be used for research". I'd really like to see that second category significantly increased, and hopefully this project will be what does it. This filtering is done by srrecs_researchers.pig and took 83m55.335s on my laptop.

  • I converted data-dumps that were in our DB schema format to a more useable format using srrecs.pig (about 13min)

  • From that dump I mapped all of the account_ids, link_ids, and sr_ids to salted hashes (using obscure() in srrecs.py with a random seed, so even I don't know it). This took about 13min on my laptop. The result of this, votes.dump is the file that is actually public. It is a tab-separated file consisting in:

    account_id,link_id,sr_id,dir

    There are 23,091,688 votes from 43,976 users over 3,436,063 links in 11,675 reddits. (Interestingly these ~44k users represent almost 17% of our total votes). The dump is 2.2gb uncompressed, 375mb in bz2.

What to do with it

The recommendations system that I'm trying right now turns those votes into a set of affinities. That is, "67% of user #223's votes on /r/reddit.com are upvotes and 52% on programming). To make these affinities (55m45.107s on my laptop):

 cat votes.dump | ./srrecs.py "affinities_m()" | sort -S200m | ./srrecs.py "affinities_r()" > affinities.dump

Then I turn the affinities into a sparse matrix representing N-dimensional co-ordinates in the vector space of affinities (scaled to -1..1 instead of 0..1), in the format used by R's skmeans package (less than a minute on my laptop). Imagine that this matrix looks like

          reddit.com pics       programming horseporn  bacon
          ---------- ---------- ----------- ---------  -----
ketralnis -0.5       (no votes) +0.45       (no votes) +1.0
jedberg   (no votes) -0.25      +0.95       +1.0       -1.0
raldi     +0.75      +0.75      +0.7        (no votes) +1.0
...

We build it like:

# they were already grouped by account_id, so we don't have to
# sort. changes to the previous step will probably require this
# step to have to sort the affinities first
cat affinities.dump | ./srrecs.py "write_matrix('affinities.cm', 'affinities.clabel', 'affinities.rlabel')"

I pass that through an R program srrecs.r (if you don't have R installed, you'll need to install that, and the package skmeans like install.packages('skmeans')). This program plots the users in this vector space finding clusters using a sperical kmeans clustering algorithm (on my laptop, takes about 10 minutes with 15 clusters and 16 minutes with 50 clusters, during which R sits at about 220mb of RAM)

# looks for the files created by write_matrix in the current directory
R -f ./srrecs.r

The output of the program is a generated list of cluster-IDs, corresponding in order to the order of user-IDs in affinities.clabel. The numbers themselves are meaningless, but people in the same cluster ID have been clustered together.

Here are the files

These are torrents of bzip2-compressed files. If you can't use the torrents for some reason it's pretty trivial to figure out from the URL how to get to the files directly on S3, but please try the torrents first since it saves us a few bucks. It's S3 seeding the torrents anyway, so it's unlikely that direct-downloading is going to go any faster or be any easier.

  • votes.dump.bz2 -- A tab-separated list of:

    account_id, link_id, sr_id, direction
  • For your convenience, a tab-separated list of votes already reduced to percent-affinities affinities.dump.bz2, formatted:

    account_id, sr_id, affinity (scaled 0..1)
  • For your convenience, affinities-matrix.tar.bz2 contains the R CLUTO format matrix files affinities.cm, affinities.clabel, affinities.rlabel

And the code

  • srrecs.pig, srrecs_researchers.pig -- what I used to generate and format the dumps (you probably won't need this)

  • mr_tools.py, srrecs.py -- what I used to salt/hash the user information and generate the R CLUTO-format matrix files (you probably won't need this unless you want different information in the matrix)

  • srrecs.r -- the R-code to generate the clusters

Here's what you can experiment with

  • The code isn't nearly useable yet. We need to turn the generated clusters into an actual set of recommendations per cluster, preferably ordered by predicted match. We probably need to do some additional post-processing per user, too. (If they gave us an affinity of 0% to /r/askreddit, we shouldn't recommend it, even if we predicted that the rest of their cluster would like it.)

  • We need a test suite to gauge the accuracy of the results of different approaches. This could be done by dividing the data-set in and using 80% for training and 20% to see if the predictions made by that 80% match.

  • We need to get the whole process to less than two hours, because that's how often I want to run the recommender. It's okay to use two or three machines to accomplish that and a lot of the steps can be done in parallel. That said we might just have to accept running it less often. It needs to run end-to-end with no user-intervention, failing gracefully on error

  • It would be handy to be able to idenfity the cluster of just a single user on-the-fly after generating the clusters in bulk

  • The results need to be hooked into the reddit UI. If you're willing to dive into the codebase, this one will be important as soon as the rest of the process is working and has a lot of room for creativity

  • We need to find the sweet spot for the number of clusters to use. Put another way, how many different types of redditors do you think there are? This could best be done using the aforementioned test-suite and a good-old-fashioned binary search.

Some notes:

  • I'm not attached to doing this in R (I don't even know much R, it just has a handy prebaked skmeans implementation). In fact I'm not attached to my methods here at all, I just want a good end-result.

  • This is my weekend fun project, so it's likely to move very slowly if we don't pick up enough participation here

  • The final version will run against the whole dataset, not just the public one. So even though I can't release the whole dataset for privacy reasons, I can run your code and a test-suite against it


r/redditdev • • Aug 20 '18

Please be a good 'bot' citizen of reddit

117 Upvotes

Hello everyone! I'd like to post a gentle reminder to those writing bots and exploring the API to behave in an appropriate manner.

In /r/redditdev, I love seeing people of all experience levels learning about various programming languages (though mostly python) by way of reddit's API. However, it's important for bot-writers to remember that they are interacting with reddit at large when they make comments or posts, and to add value to the subreddits they participate in.

So please follow a few basic good-bot guidelines.

Please don't write simple reply bots

A "simple reply bot" is one that looks at every comment across all of reddit for a word or phrase, and makes a static reply. For example, a bot that replied to every comment that has the phrase "Hello there" with "General Kenobi" would not be a good bot.

Reply bots are best when they are specifically requested and invoked, and add contextual information. /u/hearthscan-bot is an example of a well-loved reply bot.

Get approval from moderators of specific subreddits when deploying your bot

In general, you should be checking with moderators before deploying your bot to reddit. Send the mods of the subreddit(s) you want your bot to work in a modmail message, and get their approval first.

Use a dedicated subreddit for testing

Make your own subreddit and use it to test your bot. Alternatively, use /r/test.

Please don't use /r/redditdev to test your bot, thanks!

Review the community moderated 'bottiquette' list

It's here, it's quick to read, it's great: https://www.reddit.com/wiki/bottiquette


r/redditdev • • Apr 21 '10

Meta CSV dump of reddit voting data

117 Upvotes

Some people have asked for a dump of some voting data, so I made one. You can download it via bittorrent (it's hosted and seeded by S3, so don't worry about it going away) and have at. The format is

username,link_id,vote

where vote is -1 or 1 (downvote or upvote).

The dump is 29MB gzip compressed and contains 7,405,561 votes from 31,927 users over 2,046,401 links. It contains votes only from users with the preference "make my votes public" turned on (which is not the default).

This doesn't have the subreddit ID or anything in there, but I'd be willing to make another dump with more data if anything comes of this one


r/redditdev • • Oct 13 '10

Meta "Why is Reddit so slow?"

Thumbnail groups.google.com
98 Upvotes

r/redditdev • • Aug 05 '26 Mindblown

Reddit Announcement Our Plans for the Future of Reddit’s Public Data API and the Developer Platform

95 Upvotes

Today u/spez posted about why, among other parts of Reddit, our Public Data API needs to evolve. It wasn’t built for today’s scale, automated abuse, or commercial scraping. We want useful bots, community tools, and good-faith developers to have a clear, well-supported way to build on Reddit without enabling bad actors to scrape, resell, or misuse Reddit data.

Our long-term vision is for all good, trusted automation on Reddit to run within an ecosystem we can support and enforce policy on consistently. That means while we'll continue to support limited public API access, we'll gradually start restricting all new requests and third-party apps will be required to port and operate through our Developer Platform. 

None of this is changing today. It honestly won’t happen this year. We know the only way this works is if the Developer Platform supports the tools communities depend on today. We’re starting by working directly with developers and moderators to ensure we know what capabilities we still need to build before making any broader changes to API access. 

What We’ve Learned So Far

Over the past several months, we’ve been working with developers and moderators to better understand what would help them port some of the most popular Reddit bots and apps to our Developer Platform. We’ve also launched a $1 Million App Migration Program to support developers through this transition and are working directly with some of the top app developers on the platform today. 

Based on those conversations, we've already expanded platform capabilities, including:

  • Reddit API plugin improvements: bringing API calls for methods such as banning and crossposting to full parity, new wiki support (coming soon), and other consistency improvements. We will continue to improve upon this feature over time.

  • New filter APIs allowing content to hit your modqueue for review before full removal. This feature can be used in conjunction with Devvit Event Triggers for event-based workflows.

  • Expanded storage capabilities: in addition to Redis, we also now offer blob storage, completely hosted by Reddit

  • Expanded Fetch allowlisting: for existing Data API moderation bots. If your Data API moderation tool needs domain access beyond what is typically allowlisted, we are offering a pathway to broader Fetch access.

  • App mentions triggers for global mod tools and utilities to respond when an app username is mentioned. This feature is currently in beta. If your app needs access, please let us know here.

  • App account customization for profile images and account overviews.

  • Username migration so developers can convert their existing accounts, retaining karma and name recognition. 

  • External endpoints: to allow servers to call into a Dev Platform app for long running jobs or cross-subreddit workflows. If your app needs access, please let us know here.

A few of the areas in active development include:

  • More granular install allowlists: ability for developers to set limited install lists for their apps to ensure moderation apps do not always need to be public for non-devs to install them

  • Stability improvements: for features such as comment, post, and mod actions triggers, ensuring that events are never lost or dropped, even in the event of an outage

While we’ve heard from mods in the past hoping for Python support, we don’t currently have it on our roadmap. That said, we have new migration resources available to Python developers, including a PRAW migration guide to automate the first parts of your migrations and dedicated support from PRAW experts to provide guidance to folks moving to a new framework. 

Registering your app is the first step. It gives you a direct line to Reddit for updates and migration support, helps users identify trusted apps with an App label, and may make you eligible for programs like Devvit porting bounties, free hosting, and Reddit Developer Funds. During registration, you can also tell us what's blocking migration so we can prioritize the capabilities developers need most.

Going forward, all API apps will need to be registered to remain in good standing. Please register any apps you own by September 30, 2026 to make sure your feedback is considered in our roadmaps and that your developer account is properly established.

What We’re Looking For: Feedback
The most important thing we're looking for right now is feedback. If your community relies on bots, custom tooling, moderation workflows, or integrations built on Reddit's APIs, we want to understand:

  • Which tools are mission-critical for your community?

  • What capabilities are still missing from the Developer Platform?

  • Do you have a mission-critical bot that doesn't have someone to maintain it anymore? 

  • Are there any tools or integrations which don’t fit under the traditional “bot” umbrella or that may not be directly translatable to the Developer Platform?

If you don't maintain the app yourself but your community depends on it, we'd like to hear from you, too.

What Happens Next?
Based on everything we learn in this phase, we’ll come back later this year with an update on the progress we’ve made, what we’re still working on and a clear deadline for porting. 

In the meantime, the team is here for your questions, concerns and feedback in the comments. As always, your input helps us build more secure solutions while preserving the tools and workflows you all depend on every day. 


r/redditdev • • Mar 25 '26

Keeping Reddit Human: A New App Label for Automated Accounts

92 Upvotes

As u/Spez shared last year, Reddit works because it’s human. We are focused on keeping it that way and making sure users know when automation is involved in the conversations they’re having.

Obviously if you’re reading this on r/redditdev, you know as well as we do that automation isn’t inherently bad. Thousands of apps on Reddit help moderators run communities, surface helpful information or create new experiences like games for redditors. But transparency matters. People should be able to easily tell when they’re talking to another person and when they’re not.

So today, u/spez followed up with an update that will help increase this transparency: the App label.

Introducing the App Label 

Starting March 31st, accounts that use automation in allowed ways (what many call “good bots”) will be known as “apps” and show a clear App label. This label will apply to apps built on Reddit’s Developer Platform as well as other non-violating automated accounts we’ve identified across Reddit. Disruptive or spammy bots that violate our rules will continue to be removed. 

For developers already building on the Developer Platform, this label should look familiar. We’ve been labeling app content, but now apps will have the label on their profile instead. Going forward, you’ll see two types of App labels: Developer Platform App, which are apps built on the Developer Platform, and simply App, automated accounts not hosted on our Dev Platform that we’ve either identified or have registered their app.

Registering Your App
For folks not yet building on the Developer Platform, we’ll be notifying accounts we’ve identified as apps in this first phase of labeling today, and whether you receive a notification or not, this is where we could use your help. Register your existing apps here. Registration will help our team better understand usage and have the best way to contact you (and apps that register before the end of June may be eligible to claim a porting bounty). Since accounts with automations will be labeled as Apps, we’ll encourage separate accounts for automations and personal use. 

While we’re talking about Dev Platform, we’ll be offering some new incentives to port eligible apps over to the Dev Platform if you haven’t checked it out in a while (more on this coming soon!).  For current Devvit devs, we’ll be answering questions about what this might mean for you over on r/devvit. 

Expanding Coverage

In the coming months, we’ll also expand this effort to better identify automation across the platform. Accounts running automations that haven’t registered their app will be prompted to complete a simple, privacy-preserving verification flow to check whether there’s a human behind the username. [We’ll be doing this through things like passkeys and will test other solutions with third-party partners as well.] Again, only a very small number of users will ever go through this process, and only if they’re running automations. 

We'll be monitoring this thread for questions! Remember to take a minute to register your app, and we look forward to hearing your feedback as we roll this out.


r/redditdev • • Feb 06 '20

Upcoming API change: POST /api/submit

90 Upvotes

Hello devs!

On the redesign today, moderators are able to define a set of post requirements* for their subreddits. What this means for users is that during post creation, users will have their posts validated to make sure that they meet specific requirements for that subreddit.

We're planning on having these per-subreddit requirements enforced on all platforms in the near future. When we enable this feature, requests to POST /api/submit and POST /api/editusertext will fail with HTTP 400 errors if the submission doesn't meet the requirements set by the moderators of the subreddit.

You can opt into this behavior early to see how it’ll affect your apps and scripts by passing validate_on_submit=True into POST /api/submit and POST /api/editusertext. Note that the set of post requirements that a mod can set may change and expand beyond what's currently available, so make sure to account for that when considering how to show these errors to users! As a best practice, for any validation error that you don't explicitly handle in your app, you should display the error returned from the API next to the indicated field. (In the sample response below, for example, you’d want to show the error "You must have "test", "dog" or "cat" somewhere in your title" near the title field on your app’s post submission page.

Failed validation errors should look similar to existing validation errors** so we expect that most clients won't require changes if you're already showing those errors to your users.

Here's an example JSON response for a simple case of an invalid post:

{
  "json": {
    "errors": [
      ["SUBMIT_VALIDATION_TITLE_REQUIREMENT", "You must have \"test\", \"dog\" or \"cat\" somewhere in your title. ", "title"],
      ["SUBMIT_VALIDATION_FLAIR_REQUIRED", "Post must contain post flair. ", "flair"],
      ["SUBMIT_VALIDATION_MIN_LENGTH", "You must have at least 10 characters in your title. ", "title"]
    ]
  }
}

Additionally, if you’d like to pre-emptively validate a submission against a subreddit's set of requirements, you can fetch them ahead of time using the endpoint GET /api/v1/{subreddit}/post_requirements. For example, you could use this to set the max length of your client's form field for the post title to match the maximum length allowed by the subreddit.

You should expect us to launch this within the next several months, but no sooner than 90 days from now. We'll post an update here at least 1 week ahead of flipping the switch.

Let us know if you encounter any issues or have any feedback about these endpoints!

* These include min/max title lengths, post flair requirements, word requirements for the title and body, and more! You can check these out at https://new.reddit.com/r/SUBREDDIT_YOU_MODERATE/about/settings

** You can compare it to the error that is sent back when users try to submit a title longer than the site-wide max length of 300.

TL:DR; POST /api/submit and POST /api/editusertext endpoints will respond with 400s in additional cases starting in about 3 months. Devs should verify that their error handling/display code works well with the new errors.


r/redditdev • • Apr 23 '23

PRAW Should I be worried about the new Reddit API update?

87 Upvotes

An Update Regarding Reddit’s API

I'm currently doing a crawler for my Bachelor Thesis, which aim is to make a tool for fetching submissions containing information about natural disasters.

I saw that they are making changes to Reddit API and my question is, should I be worried? I've seen that the use of API might be monetized, but as it is very important for my Bachelor, I don't want to miss on anything and just want an opinion from more informed people.

Im using PRAW to access the Reddit API and also PMAW for Pushshift API. My code is not done yet but I don't think I will be producing more request than some well-known apps and tools.

Thanks


r/redditdev • • Mar 02 '21

Reddit API Is it possible to access deleted subreddits?

86 Upvotes

Hi!

I would like to access some deleted subreddits for my academic research. Since it is academic, accessing such data would entail an approval from the ethics committee from my institution.

Is that a possibility? How would I go about it? Any information will be appreciated.


r/redditdev • • Jun 18 '14

Reddit API Will todays announcement regarding visibility of up/down votes affect the api?

84 Upvotes

r/redditdev • • May 21 '14

PRAW submit question

84 Upvotes

hi,

i am trying to submit a link to my sub, but i end up with a text post containing the link.

code i use to submit:

  r.submit('mysub', title, link)

The second problem is that links will be posted even though they exist already. There is a paramter in the submit method ("resubmit") but it doesnt do anything.

can someone help with the two problems?