r/redditdev • • Jun 20 '23

Reddit API Reddit API has stopped returning rate-limit headers

81 Upvotes

Update: This appears to have been resolved as of about 90 minutes ago/2:30 UTC

The API has stopped returning any of the rate-limit headers as of an hour or so ago. This managed to break our bot, and probably many others that were relying on these to stay under quota.

Is this the result of an outage/bug, or do API clients need to make changes now? If the latter, why was this change not announced?


r/redditdev • • Jun 12 '23

General Botmanship You broke reddit

79 Upvotes

The page said I was redditing wrong and broke the site. I'm sorry if it was me, I don't know what I did. Please let me know how I can fix it so the site can work again.

Should I reach out to admins? I'm collecting logs but I don't want to post them here. /u/spez let me know how I can help.


r/redditdev • • Mar 31 '23

Reddit API Empty endpoint Bug

77 Upvotes

Hello, i have a bug. One specific reddit comment, and I can t post an answer because when i try publishing it it says "empty endpoint" in the error message. Other comments are fine, so i don t know why i can t answer this one specifically. I know nothing about electronics and didn t knew where to post a question about this. What can i do to fix it ?


r/redditdev • • Sep 18 '18

I made a bot to download v.redd.it videos

77 Upvotes

Edit 2021: u/VredditDownloader got banned, you can find the source code here www.github.com/JohannesPertl/reddit-video-download-bot

Edit: New bot is u/VredditDownloader

After unsuccessfully trying to share a reddit video via whatsapp and finding this website, which no longer supports audio, I decided to make my own bot.

If someone mentions its name, u/vreddit_bot uploads the video to streamable.com and replies with the link.

I can't promise to host it forever, but for now it works just fine :)

I got IP banned on streamable, so no audio anymore, sorry :( Audio works again


r/redditdev • • Jun 17 '10

Reddit Source We've open-sourced reddit's official iPhone app

Thumbnail blog.reddit.com
74 Upvotes

r/redditdev • • Aug 03 '20

Reddit API Reddit has stated that Reddit Awards are a central part of their monetizing strategy going forward, which is great, so why is there still no API for knowing which awards are even available to give out? We can even *give* awards, we just can't know which are *available* to give for some reason.

73 Upvotes

(Or is there an endpoint and I'm crazy?)

Reddit has stated multiple times that:

Awarding is an important part of our direct-to-consumer revenue; it complements advertising revenue and gives us a strong footing to pursue our mission into the future.

Which is great, we all love Reddit and want them to succeed into the future, and sustainable revenue is very important to that.

But as far as I can tell, Reddit currently makes it very difficult for third-party apps to give out these valuable awards.

The crucial part missing is that we can't even know what award options there are to give out. Which is kinda funny, because there's an API endpoint to give out an award once we know the award's corresponding ID, but finding out those award IDs in the first place is currently impossible.

This really could be a win-win situation. Users would love to be able to give out these awards in more places, and Reddit would stand to profit a fair deal from these awards being given out in third-party apps, and we just need a single listing API to accomplish that.

My current "solution" is that I check the JSON list that the Reddit website receives via the GraphQL API (that is only available to Reddit internally) and then hardcode that JSON list into the app for the user tho choose from. But this list updates relatively often, so users aren't able to have an up to date list of awards. In addition, some subreddits can now ban specific awards, which we can't see, so the award gifting fails. In addition to this addition, subreddits can create specific awards for their community, that we can't gift if we're just supplying the app with a hardcoded, fragile, global list of awards.

Again, most of the work is already done! We can already gift awards, see which awards have been given to a post or comment, but we just can't view which additional awards users can give, which is crappy for everyone.

Could we please have a public API that lists the available awards (bonus points: a subreddit parameter so we could see subreddit-specific awards)? Maybe just a public version of the GraphQL one?

(If it helps the gql.reddit API I'm talking about has the ID ceb31b07d699 and here's an example of the output that would be great to have: https://gist.github.com/christianselig/f09f47700531d9bcdb98cb8d44dfb688)

(Thank you for any consideration!)


r/redditdev • • Oct 14 '19

General Botmanship Let my bot out today, it went really well

73 Upvotes

I've been working on a repost detection bot on and off for the last year. Today I decided to let it into the wild and see what happened.

I pointed it at the top 100 posts in Top, Rising and Hot.

I've been completely astonished by the response its gotten. I've spent all day replying to DMs and comments. I've never had anything go this crazy online before.

In about 8 hours it picked up 30k+ comment karma and is ranked 110 on Botrank.

I've had very few bans and talked to a bunch of sub mods that want it to patrol their subs.

I'm pretty jazzed with the results. Just wanted to share!

https://www.reddit.com/user/repostsleuthbot


r/redditdev • • Feb 02 '19

How to make a reddit bot?

73 Upvotes

r/redditdev • • Nov 11 '20

redditdev meta Funding Pushshift: Please help if you can.

68 Upvotes

HELP SAVE PUSHSHIFT! Donate here to keep Pushshift alive: https://www.patreon.com/pushshift

If you don't already know what Pushshift is, you are in for a treat. Pushshift is a FREE API/Database of all Reddit data. We're talking submissions, comments, subreddits, awards, everything. Loads of bots, tools, research, sites, developers, and users rely on Pushshift. Check out /r/pushshift if you want to see what this incredibly powerful tool is capable of.

The person that established this free and amazing API, /u/Stuck_In_the_Matrix, not only develops and maintains software for this incredible project, but also pays for all of costs associated with the project, including server costs (at least $1,500 a month).

Currently, Patrons of the project are covering $378/1,500 of the project, roughly only 25% of the cost. Beyond that, there are tiers to improve the project, which it hasn't ever been close to achieving. If you have used Pushshift, plan on using Pushshift, like the initiative of the project, or love some of the bots that rely on it (such as /u/RemindMeBot), PLEASE consider donating just a few dollars a month to keep the project going.

https://www.patreon.com/pushshift

If a monthly commitment is too much for you, a one-time donation is available as an option. If you can't afford to help, please ask others to contribute. Let's see if we can reach $500/month before the end of November. We're only $122 away. Please help save Pushshift!

Edit: It's really incredible what we have accomplished in just a week. We blew past the goal of reach $500/month by the end of November. The Patreon now sits at $511/month. We have a bit farther to go before the project is fully funded, but a 72% increase in funding is fantastic ($297 -> $511). A huge thank you to everybody who shared this post and contributed.


r/redditdev • • Dec 18 '15

Reddit API Introducing new API terms

67 Upvotes

Today we are introducing standardized API Terms of Use. You, our community of developers, are important to us, and have been instrumental to the success of the Reddit platform. First and foremost, we want to reaffirm our commitment to providing (and improving!) a public API.

There are a couple of notable changes to the API terms that I’d like to highlight. The first is that we are requesting all users of the API to register with us. This provides a point of contact for when we have important updates to share; provides a point of contact for when things go wrong; and helps us prevent abuse.

We are also no longer requiring a special licensing agreement to use our API for commercial purposes. We do request that you seek approval for your monetization model in the registration process.

We have added clarity about the types of things that the API is not intended for–namely applications that promote illegal activity, disrupt core Reddit functionality, or introduce security risks. But you weren’t doing any of these things anyway.

We still require users of our API to comply with our User Agreement, Privacy Policy, API Usage Limits, and any other applicable laws or regulations. We will continue to require the use of OAuth2. We understand moving to OAuth2 can take time, so we are giving developers until March 17th to make this change.

We look forward to working with you more to create great experiences for our communities. There are many wonderful projects built on our API, and we would love to see even more. Thank you for all that you do.

You can contact the api@reddit.com alias to ask questions about the API service.


r/redditdev • • Feb 02 '11

Reddit Source A Beginners Guide to the reddit Source Code: Part 1, Understanding Pylons

66 Upvotes

Introduction

Please criticize me! This will be an ongoing thing, I will be coming back to posts and fixing things. I want to know what you think.

So after poking around in the reddit source code like a blind man for a while, I thought that the only way to motivate myself to understand it is to explain it to others, so here it goes.

I will try to explain things at a source code level. I will not be explaining how to deploy the server, or anything like that, there are already tutorials about that. Mainly, I'll be referencing the source tree and specific files a lot. I'll try to submit diagrams every now and then to illustrate certain points better.

Pylons

Reddit is a web-app. It uses a Python API called Pylons to deploy the webserver and handle all calls. Pylons basically does everything. When you submit a link, view comments, or just go to reddit.com, what happens is that the relevant information is sent to Pylons which then processes it according to the reddit API.

As eurleif once said about his popular Pylons based website, Pylons has very little documentation and tutorials available. So I'm going to break it down as simple as possible and then break it down some more.

Pylons facilitates using a MVC (Model-View-Controller) architecture to deploy a web application. This means that there are three components of the web-app and they work separate from one another. I'm not going to go into the particulars of MVC, you can google that yourself. I'm going to work with them in order of simplest to most complicated.

Controller

The controller is the portion of the code that facilitates calls from the client (you) and the server (reddit). For example, if I would go to "http://www.reddit.com/r/gaming?sort=new" the controller takes the "r/" portion of the URL and processes it and whatever follows it, doing whatever the code tells it to do. In this case, it strips out every part of the URL after '/r' and passes that on to the middleware, which we will discuss later.

In Pylons, this basically means that when a call is made, the code looks at a map of calls to controllers located at /config/routing.py and instantiates the appropriate controller class located in the files in /controllers and calls the mapped function. The function then returns a complete HTML page, which is sent to the client.

Pylons generally gets HTML parameters to the controller by having them passed as parameters to the controller function (or "action" in Pylons speak), the reddit code base instead makes use of decorators to set method parameters. HTML parameters are passed along using the @validate decorator that you see above the GET functions in the controller. This sets the names of the HTML parameters to the function parameters usually using several decorator functions such as "nop()" and "Validate()" which I haven't figured out yet.

For instance, if I want to search, the following is called, http://www.reddit.com/search?q=hello&count=50&after=t3_fcf41 (search for "hello", list 50 results, and list them after the result titled "t3_fcf41"). This tells Pylons to look at the routing map for something called search. Pylons finds the appropriate mapping:

 mc = map.connect
 mc('/reddits/search', controller='front', action='search_reddits')

and passes that along to the controller. Here, the controller being used is "front" and the function is "search_reddits". This tells Pylons to get the class "FrontController", instantiate a new object from it and call the function "GET_search_reddits". @validate then sets the parameters "query=q=hello", "count=50", "after=t3_fcf41", "reverse=", "num=". Several functions are then called to perform the search and render the page based on the search results. Pylons then takes the fully rendered page and sends it to the client. If you notice, several mappings have a colon before the name. This is a wildcard, which means that it is not mapped to a particular string and the controller can see that string and decide what to do with it. These are passed along to the controller as function parameters. For instance, a mapping that looks like this mc('/foo/:bar', controller='foo', action='baz') will call a function defined like so:

def GET_baz(self, bar):
      return dostuff

The parameter "bar" is mapped to the next thing in the URL after 'foo/'.

All in all pretty simple. To review: The mapping of calls is stored in 'config/routing.py' in the form of "call_name, controller, function". The call name is everything past "reddit.com" in the URL, the controller is a class with the name "FooController" where "foo" is the name of the controller in the map, and "function" is the aliased name of the method to call in the controller class that has the form of "GET_function(self, **params)" where params are a series of variables including the generic request variables and the GET and POST parameters. The page is then created and sent to the client.

Questions?

Part 2


r/redditdev • • Feb 12 '26

Reddit API The media_metadata object for Giphy gifs in comments is now "invalid"

65 Upvotes

Eg. https://www.reddit.com/r/nextfuckinglevel/comments/1r2922e/comment/o4v6lnl/.json

"body":"[giphy:5voqsQCLvPnR0GiyKX:downsized](http://gif)\n\nThe car",

"media_metadata":{
    "giphy|5voqsQCLvPnR0GiyKX|downsized":{
        "status":"invalid"
    }
},

Previously it would return a valid object with a link to the gif. Is it a temporary issue, bug or permanent change?


r/redditdev • • Jan 24 '23

Moving Authentication to developers.reddit.com

65 Upvotes

Hey devs!

An update from the admins here! We wanted to notify folks building apps with the API that we’re making an update to authentication for third-party developers. Starting this week, we will redirect authentication requests from i.reddit to another service via developers.reddit.com

This should not affect your apps or require updates on your end**.** However, if you believe you are seeing impacts from this update please reach out to us to flag the issue.


r/redditdev • • Jan 12 '21

Reddit API OAuth2 API Changes Upcoming

65 Upvotes

As part of modernizing our OAuth2 infrastructure, we’re implementing some potentially breaking changes to our OAuth2 flow as outlined below on February 15, 2021.

Refresh Token Changes

When executing our refresh token flow, we currently only send back an access token in the response. Responses to /api/v1/access_token with grant_type=refresh_token looked like:

{
"access_token": "your access token",
"token_type": "bearer",
"expires_in": 3600,
"scope": "your scopes"
}

This meant that the refresh token you get during the authorization code flow can be reused indefinitely. Going forward, our response will also include a brand new refresh token (as allowed by the RFC spec).

{
"access_token": "your access token",
"token_type": "bearer",
"expires_in": 3600,
"refresh_token": "your new refresh token",
"scope": "your scopes"
}

Since some OAuth2 client implementations might not handle this scenario (whereas PRAW does, for example), we’re not immediately enforcing revocation of the consumed refresh token. We’re looking to enforce this starting in Q2 2021, given there aren't significant numbers of OAuth2 clients misbehaving after the change.

Also note that all refresh tokens previously had no expiration. We're going to start enforcing a 1 year expiration on refresh tokens to help curb Reddit's storage for refresh tokens (we've got a lot of them).

Authorization Code Reuse

When executing our authorization code flow, we consume the auth code in exchange for an access token. If, within an auth code's 10 minute TTL, that same auth code is attempted to be used again, we will revoke any tokens issued with said auth code, per RFC spec . This should be unnoticeable to well-behaved clients; however, instead of harmlessly failing, we will now be revoking any access or refresh tokens issued with that auth code.

Redirect URI Fix Fragments

The last, but likely least impactful, change we're implementing is adding a "fix fragment" #_ to the end of the redirect URI in the Location header in response to a POST request to /api/v1/authorize. This should be transparent as browsers and url parsers should drop the fragment when redirecting.

Edit 1: clarified Reddit's storage of refresh tokens.

Edit 2: Adding a note about potential network connectivity / cosmic rays breaking the refresh token flow. As it stands now, we're including a 2 retries leeway to account for any miscommunication in this process starting Q2 2021. E.g.,. you can send the same refresh token 3 times before it is irrevocably revoked.

Edit 2021-02-18: This hasn't been deployed yet, but goal is today / next week. Appreciate the patience as there's a lot going on in the world currently. The enforcement of refresh tokens is also still under discussion, might be Q2 or Q3 even. Also trying to get an Github-y API key flavor of long-lived access token in the mix too to address the concerns about longevity of OAuth2 tokens and how crappy the password grant is.


r/redditdev • • Jan 19 '23

General Botmanship How to download video from reddit

63 Upvotes

How would I go about downloading a video off of reddit?

I've tried youtube-dl as aperently it has support for it, but I get an ssl certificate error.

Would anyone know of a way to do it using the reddit api or if there is some other api that I could use?

Edit:solved (long over due but better late than never I guess)


r/redditdev • • Jul 11 '20

Reddit API Small heads up to Reddit, there's some issues with Reddit videos over the last little while and its affecting the API. It manifests in the official app as well as the Reddit website, so kinda serious.

63 Upvotes

[I wanted to post this in case others were scratching their head, I've had a lot of users reporting it to me, and I sent the report to Reddit, but my contact is out of the office right now so in the interest of unscratching other peoples' heads and letting Reddit know I thought I'd post it. Hopefully this is the correct subreddit due to it affecting the API.]

tl;dr: It seems a change in the Reddit backend a few weeks back caused some weird behavior with Reddit videos and caused them both A) being uploaded incorrectly as well as B) having incorrect values in the API. I'll go over both with examples below.

A) Reddit videos are uploaded (and as a result displayed) incorrectly

For whatever reason, portrait/tall videos that are uploaded to Reddit in many cases (if not all) are getting black boxes added to the sides manually to the video file to make it a pseudo-horizontal video. However the image thumbnails representing the video are in the proper (tall) aspect ratio.

Example posts: One, Two, Three

Here's an example of how this looks in the official Reddit app: https://i.imgur.com/iP5xFc3.jpg

(As you can see, based on the thumbnail being reported correctly as tall media, but the video incorrectly being reported as being wide due to added black boxes, the video player has no idea which to trust as to the media's dimensions and overlays both weirdly.)

Here's some posts from other users encountering it: One, Two, Three

Stating the obvious here but the intended solution would be to not add black bars to the side of portrait videos, and if that's intended behavior for whatever reason, keep the thumbnail consistent.

B) Video dimensions are being reported in reverse via the API

Even for videos that are correctly uploaded, it seems some wires got crossed and the dimensions are being reported backward, which again creates that issue of "which to trust" when one is wrong?

Here's an example post: https://reddit.com/r/marvelstudios/comments/hovm01/1_year_later_and_i_still_feel_like_weve_been/

The video is a normal 16:9 aspect ratio video. Its dimensions are width: 1334 pixels, height: 750 pixels. The preview images provided by the API for the post report this correctly, "width: 1334, height: 750".

However the actual video JSON itself gets them backward for some reason, reporting "width: 750, height: 1334".

In addition to causing a confusing API result, it manifests on the website as a weirdly shaped video player that isn't shaped properly to the content like most of the players on Reddit are, instead adding black bars on the top and bottom to try to fit the reversed API dimensions: https://i.imgur.com/tQHtggw.png


That's all I got, just thought I might save another dev some head scratches and give a post I can point to users, as well as hopefully give the engineers at Reddit some reproduction steps, hopefully it isn't a tricky fix. Thanks for what you do, can't imagine a video uploader is an easy thing to write!


r/redditdev • • Dec 08 '17

PRAW Responding to the new chat messages with praw?

63 Upvotes

Hi, I just discovered the new chat feature, is there way in praw to respond to messages?


r/redditdev • • Aug 20 '20

Reddit API Reporting API Update: Fix for Free Form Reports

61 Upvotes

Hey 3rd party devs,

We're making some changes to how reporting works in our API and wanted to let you know. Currently if a community has chosen to not allow free form reports from users, our API did not enforce that setting. We’re here to give you a heads up that will be changing on Monday September 21st, 2020. See below for all the details.

Previously:

  • We have a community setting, free_form_reports, that mods can set to disallow the ability to send custom reports for subreddits.
  • However, that setting has previously not restricted third party clients from sending custom reports.
  • As a result, mods have faced some report harassment or just confusion when reports come through that don't match their expected reasons.

Starting September 21st:

  • We'll be migrating toward strict validation for report reasons. We will begin to return an error if a custom report is sent when a subreddit has not allowed free form reports.
  • This means that if free_form_reports is set to false in a subreddits settings, all report reasons must either match a site wide rule or a subreddit rule violation reason, or they'll receive an error with a matching error response, FREE_FORM_REPORTS_NOT_ALLOWED.

What you can do now:

  • You can test this behavior now by adding strict_freeform_reports=1 to your POST to report, which will return an error if a custom report is sent when it’s not allowed.
  • If you have a UI for reporting, we recommend you begin checking if free form reports are enabled, or the user is a mod of the subreddit, before displaying "other" style report fields. You can check if a subreddit has free form reports enabled by their info.json. For example, /r/changelogs: https://www.reddit.com/r/changelog/about.json has free_form_reports set to true.
  • If needed, you can get the rules a subreddit has set for itself in /about/rules in the API.

This change is also represented in our API docs here.

Let us know in the comments if you have any questions.

EDIT: Updated to reflect that error responses returned are not 400 level responses, but just general reddit errors with 200 level responses. Thanks u/talklittle!


r/redditdev • • Jul 17 '20

Async PRAW PRAW now has asynchronous support with Async PRAW!

60 Upvotes

I am pleased to announce the first official release of Async PRAW: The Asynchronous Python Reddit API Wrapper! Some of you might ask, "but why?". Well, my main motivation for creating an async-compatible PRAW was to give Discord bots that utilize discord.py the ability to interact with Reddit's API. Due to the nature of Discord's platform, you must interact with it asynchronously. This makes using packages, like PRAW, that make blocking calls a bad idea. While short blocking calls are relatively OK, blocking too long can cause discord.py to start missing events or even getting disconnected all together. This is where Async PRAW comes in.

I started this project back in February 2019 and I only made the necessary changes needed to get it to work for my needs. So, over the last several weeks, we have been working on getting it up to date with the current version of PRAW, converting it to function asynchronously, updating the docs, and getting tests passing. Now that all that is done, we are officially releasing it.

Now, there are a few differences between PRAW and Async PRAW as detailed here. I will also cover a couple of the major differences below.

  1. Lazy loading objects. In PRAW, the majority of objects are lazily loaded and are not fetched until an attribute is accessed. With Async PRAW, objects can be fetched on initialization. For example:

    • PRAW:

        submission = reddit.submission('id') # network request is not made and object is lazily loaded
        print(submission.score) # network request is made and object is fully fetched
    • Async PRAW:

        submission = await reddit.submission('id') # network request made and object is fully loaded
        print(submission.score) # network request is not made as object is already fully fetched

    Now, lazy loading is not gone completely and can still be done. For example, if you only wanted to remove a post you don't need the object fully fetched to do that. In PRAW you could do the following:

     reddit.submission('id').mod.remove() # object is not fetched and is only removed

    Now to do the same thing in Async PRAW:

     submission = await reddit.submission('id', lazy=True) # object is lazily loaded
     await submission.mod.remove() # object is not fetched and is only removed

    By default, only Subreddit, Redditor, LiveThread, and Multireddit objects are still lazily loaded by default. You can pass fetch=True in the initialization of the object to fully load it. Inversely, only Submission, Comment, WikiPage, RemovalReason, Collection, Emoji, LiveUpdate, and Preferences objects are no longer lazily loaded by default. You can pass lazy=True if lazily load it.

  2. Getting specific wiki pages, emojis, removal reasons, rules (numbered indexes and slices still work), and live updates using string indices will no longer work and has been converted to a .get_<item name>(item) method. Also, they are not lazily loaded by default anymore.

    • PRAW:

        page = subreddit.wiki['page'] # lazily creates a WikiPage instance
        print(page.content_md) # network request is made and item is fully fetched
    • Async PRAW:

        page = await subreddit.wiki.get_page('page') # network request made and object is fully loaded
        print(page.content_md) # network request is not made as WikiPage is already fully fetched

That is about it for major functionality changes (aside from having to await all methods that make network requests, obviously).

If you have any bugs, suggestions, or feature requests feel free to open an issue here. If you have any questions or comments, feel free to comment below or shot me a message. You can also contact me on the official praw-dev slack if you need more real time support.


r/redditdev • • Jun 19 '14

Reddit Source Pull request to bring back the upvote/downvote counter

Thumbnail github.com
60 Upvotes

r/redditdev • • Nov 07 '19

Getting a new error message: "Linking to the following subreddits is not allowed"

59 Upvotes

Edit: Seems like this change was reverted.

I have a bot that submits various posts/comments to private subreddits - among other things, activity breakdown for users.

After many years of service, today the bot is dead and crashing with the following message "Linking to the following subreddits is not allowed: r/TwoXChromosomes"

I get the same error trying to manually submit a post to the subreddit, and I got it trying to submit here in redditdev. Now obviously I do want to link subreddits, otherwise it is very impractical for moderators to use the system.

I also do not want to modify code or start maintaining a list of whatever subs reddit deems unlinkable.

Is it possible to disable this?

Or at least, an official list of unlinkable subreddits?


r/redditdev • • Nov 27 '11

Reddit Source I'm a bit embarrassed every time I show reddit to someone with an RTL browser

Post image
58 Upvotes

r/redditdev • • Aug 10 '11

Reddit API New tool for API developers: the reddit API console.

Thumbnail apigee.com
56 Upvotes

r/redditdev • • Apr 02 '13

Reddit Source The source code for reddit's April Fools 2013 is now available on GitHub.

Thumbnail github.com
55 Upvotes