r/redditdev • • Jun 05 '23

Reddit API Lets talk about those API calls

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?

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.

696 Upvotes

104 comments sorted by

33

u/RaiderBDev Jun 05 '23

With my web app I could reduce the majority of API calls if they just provided a basic websocket for new messages. The constant polling is really a pain if you don't want to send notifications ages after they have arrived.

8

u/Meepster23 Jun 05 '23

Yeah I imagine that is one of the main discrepancies in api calls by app is how you handle checking for new messages

3

u/999avatar999 Jun 06 '23

Idk how often Apollo polls but RIF does it every 5 minutes, so 288 times per day per user. Perhaps apollo does it at least 3 times as often? How knows

4

u/Meepster23 Jun 06 '23

So apparently Apollo does push notifications even when you aren't using the app, RiF doesn't. So Apollo has a backend process polling constantly and RiF doesn't

0

u/[deleted] Jun 06 '23

5

u/Meepster23 Jun 06 '23

Yeah I find the whole it's too taxing thing to be bullshit

1

u/Naud1993 Jun 13 '23

What Reddit could do is send the third party app an API request whenever a user of that app gets a message.

→ More replies (4)

16

u/SirensToGo Jun 06 '23

The annoying thing is that Reddit could help third party developers massively reduce their API load simply by providing more sensible modern APIs.

As you point out, polling for mail is very wasteful and it's made even worse when a third party app wants to support push notifications. A typical implementation of such a feature (on iOS) is to have a backend server constantly polling every user for messages every 15-60 seconds in order to check for new messages that need to be delivered. This is enormously wasteful, obviously, because the vast majority of requests do not return new messages. Of course, polling less often would decrease the load but doing so worsens the user experience (what good are push notifications if they take an hour to arrive!). If Reddit wanted to be helpful and reduce their server load at the same time, they could support server to server push so that their backend could just notify third party servers when a user gets mail so that we don't have to poll for messages. This is a win for everyone because it means reddit gets hammered less, third parties don't have to waste so much compute hammering Reddit, and users get faster notifications.

I strongly suspect that that multiple of the ""worst offenders"" are on the list because of this. Of course, instead of trying to help developers reduce their usage, Reddit seems to be just throwing a massive bill at us and telling us to figure it out (which, of course, we can't without either shelling out hundreds of thousands of dollars or massively degrading our app experience).

8

u/Meepster23 Jun 06 '23

Yup! A simple webhook type implementation that registers a call back for new messages would reduce calls drastically. Tie it to the refresh token so it can be revoked along with the API access for an app and you are cooking with gas

2

u/nomdeplume Jun 06 '23

Reducing the cost doesn't mean you still eat lunch for free. The issue is full stop, people are eating lunch for free.

Could it be more efficient? Yes sure. So lunch might get cheaper, but its not free. So you don't get to eat for free.

Making a better API also costs reddit money in developer time, so they make it more efficient to what... make those apps that they don't own or profit from cheaper to run?

0

u/whats_a_monad Jun 08 '23

Waah waah poor Reddit’s IPO value

0

u/semininja Jun 16 '23

It's only "free lunch" if you don't consider the value the third-party apps contribute to Reddit in return. Personally, I wouldn't even be on the site if it weren't for RIF years ago, and I'm sure that many others wouldn't use it nearly as much. Fewer users = less content = less growth of userbase = less value for Reddit.

11

u/Kanzuke Jun 05 '23

Regarding that final quote, Apollo does have quite an extensive serverside portion that handles sending push notifications at least, so it is very possible the developer made a change on that date without publishing a new version of the app. He also didn't suggest otherwise in his reply to that comment

10

u/haykam821 Jun 05 '23

Plus, and u/Meepster23 could mention this, Reddit has the advantage as the first party as they can push notifications directly and not need to poll an API. Same with Apollo's comment live activities feature if that doesn't use the websocket.

5

u/Meepster23 Jun 05 '23

Yup they have a huge advantage there. But Reddit claiming that is taxing their servers is a complete load of shit... Those requests are tiny and should be optimized already by Reddit

→ More replies (4)

2

u/Meepster23 Jun 05 '23

That is a very good point. I haven't dug into Apollo at all, but that's an interesting idea. Does Apollo send push notifications for messages while you aren't using the app? That would make sense and line up with my messages checking theory.

→ More replies (3)

5

u/Thalenia Jun 05 '23

Numbers look good enough, and the cost is stupid as far as I can tell.

One question though - those 135K API calls and whatever data goes through as a result, equates to how much bandwidth? And how much might that cost reddit?

(Assuming any of that makes sense, I don't know much about the behind-the-scenes workings.)

4

u/Meepster23 Jun 05 '23

That's a good question! For the most part the calls aren't that bandwidth intensive. Especially for the frequent calls to check for unread messages etc. Those are in the kilobyte range.

The large ones are mostly large because of Reddit and the sheer amount of bullshit they put into the response. No third party gives a shit if a user is opted in to a Reddit experiment or even what that experiment is lol.

Also it is tiny in comparison to the tracking data being sent back from the official app to Reddit. Which seems to be basically a dump of everything currently visible on your screen including all the text and shit which is odd since it would all be retrievable by id.. but yeah.. their development practices haven't exactly impressed me

10

u/mmmmmmBacon12345 Jun 05 '23

Less than imgur who serves up mainly images and not text like reddit

For 50,000,000 queries imgur charges just $166, Reddit wants to charge $12,000

3

u/quarky_uk Jun 06 '23

No offence to u/Meepster23 and all the excellent info and examples at all, but this simple comparison is probably more impactful on most people.

3

u/nomdeplume Jun 06 '23

Except imgur isn't profitable, doesn't have the same amount of monetization as Reddit has achieved per user (the price is not just the price of the cost, its the price of the profits+opportunity cost+infra cost).

Imgur is investor funded.

Imgur nearly went bankrupt 2 years ago.

Imgur doesn't have nearly as complicated an infrastructure or scaling problems as Reddit because they are vastly different products and user bases.

This comparison is confidently incorrect in so many ways about the reality of what things cost.

4

u/la2eee Jun 06 '23 edited Jun 06 '23

I like how Discord handles their new bot API: You register your app, you provide an https endpoint and Discord will contact your endpoint when an interaction occurs.

This way you don't need a permanently open connection and you can implement your app however you like, you just need to provide that endpoint.

And Discord has the control of the outgoing bandwidth. That's way better for scaling than dealing with uncontrolled incoming bandwidth.

Reddit should try that.

Imagine: Not pulling every 10s for 10 minutes to get one new message. Just one contact on your endpoint when the new message arrives. The endpoint needs to transmit the news to the user's app, sure, but this can be done inside the app owners infrastructure and doesn't cost API fees.

→ More replies (1)

3

u/hellalosses Jun 05 '23

I was developing apps that use the reddit API and this was a wake up call. I cannot rely on 1 API for data.

Luckily I found this piece on techcrunch;

```

It's not a blanket
policy change. As reported by The New York Times, Reddit's API will
remain free to developers who want to build apps and bots that help
people use Reddit, as well as to researchers who wish to study Reddit
for strictly academic or noncommercial purposes.

```

https://techcrunch.com/2023/04/18/reddit-will-begin-charging-for-access-to-its-api/

5

u/Meepster23 Jun 05 '23

I mean... Apollo helps people use Reddit and they want $20 million for it haha

→ More replies (1)

6

u/mmmmmmBacon12345 Jun 05 '23

100 queries/minute is really low for any useful bot. Flairbot u/flair_helper is on probably hundreds of subs and each removal is at least 4 queries, it can't survive on the limited level

So then it's pushed to paid. At a low 1000 removals per day across all the subs it'd do 1.5M queries per year. At $12k/50M queries that's $360/year for a bot that costs subs nothing and earns no money

Tools get rate limited and charged but spammers? Can't risk rate limiting those

→ More replies (1)

4

u/helrazr Jun 06 '23

So what your saying is, that an Admin lied about Apollo being inefficient on API calls when compared to other 3rd Party Apps. It’s just that Apollo users are more frequently using Apollo than perhaps other 3rd Party Apps.

I’m shocked honestly. SHOCKED…..that an Admin isn’t telling the full picture.

¯_(ツ)_/¯

Sincerely, An Apollo User

→ More replies (2)

42

u/flattenedbricks Jun 05 '23

This is a quality post, I hope it reaches far and wide. This whole API mess can be avoided if Reddit decides to be less greedy. That's all it boils down to. Money. Taking away what the community wants and needs will kill the website, making them lose more money. A good reminder is The Lorax movie. He put his ethics aside and tried to make as much money as possible, only to end up with nothing because everyone left. Don't do that to us Reddit. Let that movie serve as an example of what happens when you pursue your API plans the way you are.

→ More replies (4)

25

u/enmlounge Jun 06 '23

Who in their right mind would pay for an API that has zero reporting features? We're supposed to just trust them on what they report and charge us for? No way to verify?

Why do we all have to build into our applications/scripts some method of tracking API call volume? That's Reddit's job if they want us to pay for it.

I mean - they claim to know how many API requests we're all making... so... provide some basic reporting? Or is it the reason they apparently weren't actually rate limiting anyone was because they didn't have any idea what was going on with their API?

Oof. This whole thing is really eye opening.

8

u/Clavis_Apocalypticae Jun 06 '23

See Comcast's ludicrous data caps for more information. You just have to take their word for it, lol.

7

u/awkward_the_turtle Jun 05 '23

Admins being deceptive? On my reddit? Why I never

1

u/John_Yuki Jun 06 '23

How do the new API costs impact generic bots? I have an automoderator bot on my subreddit r/footballmanagergames, as well as a leaderboard bot that is kind of used as a little game/award thing to incentivize higher quality submission, and people really love the latter.

Would I have to end up paying to run these bots now, or is the pay-to-use API model only targeting people like the devs of the 3rd party apps, pushshift, etc, that make hundreds of thousands of API calls?

1

u/Meepster23 Jun 06 '23

Allegedly you'll be fine so long as you stay less than 100 requests per minute per bot.

2

u/John_Yuki Jun 06 '23 edited Jun 06 '23

Okay thanks. Just making sure I have all the necessary info for my subs users for if I announce that r/footballmanagergames is joining the blackout.

1

u/Meepster23 Jun 06 '23

No problem!

2

u/nomdeplume Jun 06 '23

"Allegedly" as if that's not the exact thing Reddit communicated.

2

u/Meepster23 Jun 06 '23

Allegedly because they've provided no info on how they are telling "legit" bots vs third party apps and are insisting mod bots will somehow have address all access to NSFW content but third parties won't

1

u/nomdeplume Jun 06 '23

The first point they communicated in that they track client ids and identify the third party apps manually as enterprise tier.

The second they addressed in a comment about how most bots will continue to function and those that aren't, the mods should reach out to admins directly.

1

u/antidense Jun 06 '23

Can I ask about my bots? u/ModeratelyHelpfulBot and u/ModeratelyUsefulBot?

https://github.com/antidense/moderatelyhelpfulbot

They make thousands of calls an hour to remove posts by people who spam and ignore ratepost limits and remove at least several hundred a day.

Will this still be allowed? What about for nsfw reddits?

2

u/Meepster23 Jun 06 '23

Allegedly all moderator bots are somehow going to be exempt from this but that may mean you'll have to poke the admins about it. In the official thread's there have been a couple links posted to do that.

1

u/FlRE_DEATH Jun 15 '23

what are the 3rd party apps that use the API? never seen any

1

u/Meepster23 Jun 15 '23 edited Jul 05 '23

All of them? Reddit is fun, Apollo, narwhal, bacon reader. Literally any third party tool or website that interacts at all with Reddit

1

u/EcksDee4 Jun 30 '23

I know little about Dev stuff, and this makes sense to me! I don't use Reddit much, I sometimes browse with this anon account but that's about it.

I would fully expect Reddit's team to be lying about this. They've fashioned themselves as incompetent greedy fools for a good while, and are now shining in the buff with this facade.

It's a shame. Here is an upvote chief, can't really do much else. Glad this was notified to me on recommendation!

→ More replies (1)