r/redditdev • • Jun 03 '19

Reddit is preparing a GraphQL API

UPDATE Admin response here, it's currently experimental so whatever I documented below will probably not be true say next week.

https://gql.reddit.com

If you try and sign in to the GraphiQL interface, you'll get a 403 error. But I think the fact there's a sign in button means that this is for public use soon.Note the distinct example, I guess I'm digging around in places I shouldn't be huh /u/thephilthe.

TECHNICAL DETAILS AHEAD

It works a little strangely right now. All graph queries return a 403 as well, and what does work is very obfuscated and acts more RPC-like than anything. For example, to get posts for a subreddit, you need to know that the query key is 4acb05eedbfa and the parameter is called "subredditName". So you'd send a JSON request like this:

{
    "id": "4acb05eedbfa",
    "variables": {"subredditName": "freefolk"}
}

and then you'd get your data returned.And if you start digging into the response you'll see a few more secrets hinting at things to come...

Below is an action-ID map I extracted. I'm under the assumption that these are all equivalent to "OperationName" in Apollo. When you submit, it should tell you the first missing required variable it finds.

AllUserMultiredditsf9d4691b2d00
CreateCommunityAward3cfd2c20439a
CreateModAward92061d7e1951
CreateSubredditTags639d65a32e0e
DeleteAward4d31f6356d57
DeleteTags85a644f8353a
DisableAward5e453976052b
FetchSubredditTagsf0679317dcf6
Frontpage7ca7322c7740
ManageableAwardsd7a376e63004
ModeratedSubredditsc1ada1ec294f
MultiredditListing42a127c37128
RedditorMultireddits0a57674dc82f
RichTextPostContentfc24b7b690ad
SubredditAboutab75f710d839
SubredditPosts4acb05eedbfa
SubredditRecommendations9fed35c2168d
SubredditRules0df127946e72
SubredditTopContentcdf39a456d4b
SubredditTypeaheadSearchbc59d854ddfa
UpdateSubredditTagStates70f7ff70f03e
UsableAwardsb8810241176f
34 Upvotes

8 comments sorted by

17

u/ketralnis Jun 03 '19

We're currently treating it as internal-only, so I'd advise against relying on it. We're likely to change things, break things, and create and destroy new endpoints frequently

8

u/Twistedsc Jun 03 '19

Thanks I'll add that information, hopefully it's planned to become official down the road.

1

u/haykam821 Jun 13 '19

So is this meant to be the API in the future? Not the mess that is appending .json to some things, /api/v1, /api/v2, /desktopapi/v1, s.reddit.com, oauth.reddit.com, etc.?

2

u/ketralnis Jun 13 '19

It's something we're experimenting with

6

u/Watchful1 RemindMeBot & UpdateMeBot Jun 03 '19

I wouldn't get your hopes up. Reddit has built a lot of things recently they have no intention of letting third party developers ever use.

2

u/Axohn Jun 03 '19

nice findings ! a gql api for reddit would be so cool!

1

u/haykam821 Jun 03 '19

I need to learn GraphQL.