-
-
Save ading2210/665d4d882e584dd27030e7106d3fe561 to your computer and use it in GitHub Desktop.
reddit.com graphql query ids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AddApprovedTalkHost": "84b1688a0244", | |
"AddPredictionDrafts": "c821ca1db9f1", | |
"AllModerators": "fcd88a3eea91", | |
"AllUserMultireddits": "b65f99b680f5", | |
"AvailableAwards": "4778ed491384", | |
"AvatarListingById": "ecc344086626", | |
"AwardSheetInfo": "e1be3a261389", | |
"AwardSheetInfoForProfile": "3a33281f30db", | |
"AwardSideEffectsDetails": "e10d7f0411a4", | |
"BadgeIndicators": "fbbc7389e1ff", | |
"BlockAwarder": "9769ffbb7031", | |
"CancelEconRecurringPayment": "ac36f7489268", | |
"CancelPrediction": "fac88c91fec8", | |
"ChangePrediction": "614dbb8a54d2", | |
"ChangePredictionVote": "90c7b71fa93f", | |
"ChangeStripePaymentMethod": "ce700fb9b230", | |
"ChatBadgeIndicators": "051a1d7b8755", | |
"ChatTabLiveChats": "5a6325a84444", | |
"ChatUnitDetails": "0e3adbb8d3c9", | |
"ClaimAwardOffer": "7264b2ee2ded", | |
"CommentToxicity": "445164f0825f", | |
"CommentsPageExtra": "abbb27126771", | |
"CommentsPageLastAuthorModNotes": "1b7d106afc6c", | |
"CompleteCommunityProgressCard": "de7c5c2c6959", | |
"CompleteCommunityProgressModule": "662c7500e8b7", | |
"ConfirmPaypalPayment": "4a9f7376235b", | |
"ConfirmStripePaymentNewCard": "e4d2b27d6d30", | |
"ConfirmStripePaymentSavedCard": "0095edf93db4", | |
"CountrySiteHomeFeed": "e36801651a7f", | |
"CreateChatChannelInviteLink": "d5d2819a6186", | |
"CreateChatMessage": "b0bb6207e12d", | |
"CreateComment": "f0b0ca6701b9", | |
"CreateCommunityAward": "38852e4f82b0", | |
"CreateCustomEmoji": "e443629d50b0", | |
"CreateEconOrder": "b1f066bd7137", | |
"CreateGlobalAward": "c11324579f8c", | |
"CreateLiveAudioRoomOnProfile": "e35a47c6aa21", | |
"CreateLiveAudioRoomOrError": "f1f366237119", | |
"CreateLiveChatAssociation": "b51c6a74ca72", | |
"CreateMediaUploadLease": "64163dab0622", | |
"CreateModAward": "a04c85b4e964", | |
"CreateModUserNote": "10ad38be41ae", | |
"CreatePaymentIntent": "e7836733c043", | |
"CreatePaypalPayment": "91f215ec5196", | |
"CreatePredictionTournament": "cb5e7bbde98a", | |
"CreateScheduledPost": "737d59db38fc", | |
"CreateStripePaymentWithProvidedCard": "179702814d8f", | |
"CreateStripePaymentWithProvidedNonAuthCard": "6d178a1662ba", | |
"CreateStripePaymentWithSavedCard": "9fc54f6de447", | |
"CreateSubredditTags": "80c9a3cd96b8", | |
"CreatorStats": "556ffe7b3296", | |
"CrowdControlLevelInfo": "0100b521f182", | |
"CustomerSurveyConfig": "89970a6dad30", | |
"CustomerSurveySteps": "679f44f9a458", | |
"DeclineChatChannelInvite": "52783a3ba2dd", | |
"DeleteCustomEmoji": "c13d195ee7ca", | |
"DeleteInboxNotifications": "ce2deb9deef7", | |
"DeleteLiveChatAssociation": "5e895dfecc97", | |
"DeleteModUserNote": "c44e6467c4d7", | |
"DeleteSavedStripeCard": "87230cb9dec2", | |
"DeleteScheduledPost": "dea861ad7f0d", | |
"DeleteSocialLinks": "7eb2600cd927", | |
"DeleteSubredditMuteSettings": "c518a45f60a5", | |
"DestroyInviteLink": "af738125be66", | |
"DirectChatRoom": "ee14c9f5e092", | |
"DisableAwardInCommunity": "689f37138ede", | |
"DismissCommunityProgressCard": "d43940dddaf7", | |
"DismissCommunityProgressCardV2": "af0a685394e2", | |
"DoesUserHavePostModPermission": "124d4a37eca2", | |
"EconAdminPanelQuery": "d47c78bc4284", | |
"EnableAwardInCommunity": "3c2210d8ba4b", | |
"EndPredictionTournament": "50c0ba265137", | |
"EventPostsBySubredditName": "604fe2a6f1f6", | |
"ExperimentVariants": "34910619f1e9", | |
"ExperimentVariantsShort": "bc53b55777c5", | |
"FetchBlockedRedditorsInfo": "1e9183c00f76", | |
"FetchContentControls": "58b71dbd3384", | |
"FetchEligibleUXExperiences": "388d61b2a794", | |
"FetchGlobalTags": "f4a581740c21", | |
"FetchLiveDiscoveryContent": "f33b3c9cb73a", | |
"FetchModerationLogActions": "bf67bf218716", | |
"FetchPostGuidanceConfig": "8a6cc0e63320", | |
"FetchSpecialEvents": "6c73f2f0b64f", | |
"FetchSubredditTags": "bac623887684", | |
"FetchSubredditTrafficStats": "d2b39ab0293a", | |
"FetchSubredditUserFlairTemplates": "d12ae751b65c", | |
"FetchSubredditsNotificationSettings": "5d042135b4c5", | |
"Frontpage": "d45d9e249839", | |
"GeneralSearch": "8e8ea0cefd5f", | |
"GeneralSearchOptimized": "c81c1aa1f9f8", | |
"GenerateCustomEmojiUploadLease": "cbcafcbff9c6", | |
"GeoContributableSubreddits": "4dfcd615cce5", | |
"GeoPlaceAutocomplete": "8a89fd7c7db1", | |
"GetAccountGender": "1508e05ea2ee", | |
"GetArtistById": "69cc2c455368", | |
"GetAvailableAudioRoomTopics": "05271fef4b69", | |
"GetCommentById": "b499034a4b88", | |
"GetDevPlatformMetadata": "fbfb3b396dfe", | |
"GetDynamicLayout": "9d622b078536", | |
"GetIsLiveContentAvailable": "fd06b588e238", | |
"GetModPnSettingsLayout": "7e96f2bfcc6c", | |
"GetModUserNotes": "0eb0efc0bf02", | |
"GetNearbySubreddits": "1ea6a2fd1417", | |
"GetPostReactInfo": "72e76fc8e5c5", | |
"GetPredictionChipPackages": "5ce83e513fa5", | |
"GetPredictionCreationAllowance": "d9fb5ec5128f", | |
"GetPredictionToken": "26b911e67a5f", | |
"GetRelatedCommunityRecommendations": "1a3f607eabf6", | |
"GetSubredditAllowedPostTypes": "f65cf1eba776", | |
"GetSubredditCountrySiteSettings": "abd8b9be540b", | |
"GetSubredditQuestions": "15c4ad40a0bc", | |
"GetSubredditSettings": "b75531b20155", | |
"GetSubredditWelcomeMessage": "ba4eb4e2972f", | |
"GetTopKarmaSubreddits": "6a81cf281cfc", | |
"GetTotalModNoteCount": "bb325c103c55", | |
"GetTournaments": "15c20a93ed51", | |
"GetTournamentsBaseInfo": "cebfc8734cec", | |
"GetTrendingChatGifs": "5b4e0d028600", | |
"GetUserProfileAllowedPostTypes": "34fa0ef8e099", | |
"GildComment": "c25f21e6351f", | |
"GildPost": "496275fd4bb6", | |
"GiveAward": "b8028be05f59", | |
"GiveCoins": "385450867622", | |
"GlobalAwards": "16101a740cd7", | |
"GlobalProductOffers": "5b1dd85fe475", | |
"HideAwardOnTarget": "4e43964bff6f", | |
"InterestTopics": "7637265b3b63", | |
"InterestTopicsByIds": "c79807b42f04", | |
"LanguageSelections": "40df26b7117b", | |
"LastModActionInSubreddit": "7888d2d30843", | |
"LeaveChatChannel": "3a709cd80f6d", | |
"ManageableAwards": "bce139cc4904", | |
"ManageableAwardsForProfile": "f2dc00a6f019", | |
"MatrixChatNotifications": "2fe60a4b5c2a", | |
"MaybeDeleteTagsAndUpdateItemTags": "023547ccdaf6", | |
"ModActivitySummaryByID": "d968e053a7b8", | |
"ModApprove": "660e0733e963", | |
"ModInsightsModQueueEntrypoint": "963b46029a60", | |
"ModQueueItems": "6fea93cb6fbb", | |
"ModQueueTriggers": "0ac619d6eb7e", | |
"ModRemove": "6a4c2bda9036", | |
"ModeratedSubreddits": "516667a2fa51", | |
"ModerationActionCategories": "45bc34defbb5", | |
"MultiredditListing": "008f85bde0ad", | |
"MutedSubreddits": "c09ff0d041c1", | |
"NotificationInboxFeed": "be3e43b15ada", | |
"NotificationInboxFeedSlimmed": "916e9e9be5e0", | |
"NotificationSettingsLayoutByChannel": "d03522f8a8d4", | |
"OpenAISubRecWithDetail": "aab58d632d84", | |
"OtherDiscussions": "a67c9b37646a", | |
"PerformEconAdminAction": "de8b0fb0be5d", | |
"PersonalizedYearInReview": "157109a04b67", | |
"PollVote": "a20cc8dd230d", | |
"PopularFeedElements": "11db30728cfb", | |
"PostFeedAndOtherDiscussions": "41973b2a5a8f", | |
"PostGuidanceValidation": "f61154c007f1", | |
"PostIsTrackingCrossposts": "a362f62253e5", | |
"PostSetById": "1a642522ae6a", | |
"PremiumProductOfferSubscriptions": "d0a53057e3e8", | |
"PrepareLiveAudioRoom": "a04297924fc8", | |
"PrepareLiveAudioRoomOnProfile": "649e9f8bd6d9", | |
"ProductOffers": "ddb1f9f5717c", | |
"ProfileDownvoted": "42616342e99c", | |
"ProfileFeed": "e8d58a13151d", | |
"ProfileFollowers": "5fc67bec507f", | |
"ProfileGivenGildings": "48cc7f05ceee", | |
"ProfileHidden": "e15294d413b1", | |
"ProfileHistoryPosts": "75c9f18c044f", | |
"ProfileModHubPage": "f77274630047", | |
"ProfileReceivedGildings": "5e560e39ad16", | |
"ProfileSaved": "e355dad0c712", | |
"ProfileTrophies": "3c59e5ed6f14", | |
"ProfileUpvoted": "5b90e18285c7", | |
"ProxyAuthor": "695a72c78215", | |
"PurchaseCatalogProductOffers": "098518521d5b", | |
"RecordCommunityAnswer": "fea84f5739a4", | |
"RedditorIdByName": "a24cf5c8adf7", | |
"RedditorKarma": "db6eb1356b13", | |
"RedditorMultireddits": "3d04e2bb92b5", | |
"RedditorNameById": "7206aafc3965", | |
"RedditorsInfoByIds": "b722cdefdc5c", | |
"RegisterWebPushToken": "197650c1946c", | |
"RemoveApprovedTalkHost": "e016564e243a", | |
"RemoveAward": "f7c06f2127c3", | |
"RemoveCoins": "1011718c41db", | |
"RemoveCommunityAward": "973872832463", | |
"ReportChatMessage": "fd819ca5f0fa", | |
"ReportComment": "cec8e7309a27", | |
"ReportForm": "404920cc0308", | |
"ReportMessage": "ae01229e1caa", | |
"ReportPost": "08c43db238fd", | |
"ReportTalk": "139ca5b89cf9", | |
"RequestUserDataExport": "f3bf387093f2", | |
"ResolvePrediction": "d742e3019cfe", | |
"RichTextPostContent": "fc24b7b690ad", | |
"SearchChatGifs": "01a298f0be11", | |
"SearchChatMessageReactionIcons": "e44f60cbfc09", | |
"SearchTypeahead": "26f251bf8753", | |
"SearchTypeaheadByType": "e39d1d540f0a", | |
"SendbirdChannels": "8b56e5ac7057", | |
"SetSocialLinks": "5064afb1fbe2", | |
"SetSubredditGeoPlace": "ece6b91ed02d", | |
"SingleCommentById": "7e1a2a69e2d6", | |
"SinglePostInfoById": "7226f3bb6e27", | |
"SocialLinks": "11a239b07f86", | |
"StartLiveAudioRoom": "6e7ab4bd4873", | |
"StoreUxTargetingAction": "e734e21836ec", | |
"SubmitContentRatingSurvey": "8cd4e428e688", | |
"SubmitMediaUpload": "6a1841b659af", | |
"SubmitScheduledPost": "6f9e584d390a", | |
"SubredditAbout": "4016ffe922f6", | |
"SubredditAchievementFlairs": "97fec841c778", | |
"SubredditApprovedTalkHosts": "86107f5fbae2", | |
"SubredditChatChannelRecommendations": "d10c19519bc0", | |
"SubredditCoins": "a82ef253ed10", | |
"SubredditCustomEmojis": "76faa900e33f", | |
"SubredditFlairedRedditorByName": "11aba1560164", | |
"SubredditFlairedRedditors": "d343c3cad2d0", | |
"SubredditGeoRecommendationViaFocusVertical": "be09d1d59e65", | |
"SubredditInfo": "29aee4089528", | |
"SubredditPage": "e111e3a11997", | |
"SubredditPageExtra": "abb696a96055", | |
"SubredditPostFlairStyleTemplates": "9a87d9b91dc4", | |
"SubredditPosts": "2c1754c5026c", | |
"SubredditRecommendations": "abcab38cb71c", | |
"SubredditRules": "c398abb500f1", | |
"SubredditScheduledPosts": "2289de7a3370", | |
"SubredditStyles": "059a51904852", | |
"SubredditTopContent": "c80367dee46a", | |
"SubredditTopPredictors": "a9f7697930b7", | |
"SubredditTournamentLeaderboard": "e14e6d1892e6", | |
"SubredditTypeaheadSearch": "20edc5ee12df", | |
"SubredditUserAchievements": "7288c5f50973", | |
"SubredditWiki": "5834be60ee7a", | |
"SubredditWikiBannedContributors": "9b728f1ed735", | |
"SubredditWikiContributors": "6ff60c2af7f1", | |
"SubredditWikiPageSettings": "03acb455993d", | |
"SubredditsCarousel": "a818d17baafc", | |
"SubredditsPosts": "e289f23cc495", | |
"SubredditsWithAboutInfo": "b00857778f9c", | |
"SubscribedSubreddits": "ca83defc2e15", | |
"SuggestSubredditGeoPlace": "aea8f624d4b7", | |
"TopAwardedPosts": "8de8e31af067", | |
"TopAwardersLeaderboard": "750ff4a757de", | |
"TopicBySlug": "da075aebbc25", | |
"TrendingSearches": "7dfebe087245", | |
"UpdateAccountGender": "670e8e8d3018", | |
"UpdateAchievementFlairPreference": "1bc1df66f049", | |
"UpdateChatMessageReaction": "2a0ff72d302a", | |
"UpdateChatMessagesAsRead": "bfc6fe51708d", | |
"UpdateComment": "3d83ef4f0375", | |
"UpdateCommentDistinguishState": "e1f407c8ceba", | |
"UpdateCommentFollowState": "0a2ed51664c5", | |
"UpdateCommentStickyState": "236938d65d55", | |
"UpdateCrowdControlFilter": "8d7cddda8fe5", | |
"UpdateCrowdControlLevel": "e403278013c8", | |
"UpdateHatefulContentFilters": "026bf4f1acc7", | |
"UpdateInboxActivitySeenState": "85d656894a08", | |
"UpdateModPnSettingStatus": "fb41cb5f551a", | |
"UpdateModPnSettingThreshold": "7fc476f8098b", | |
"UpdateNotificationPreferences": "129085be0500", | |
"UpdatePostDistinguishState": "e869489c84a4", | |
"UpdatePostFollowState": "6491fda8f22b", | |
"UpdatePostNsfwState": "741b655f3e85", | |
"UpdatePostRequirements": "8732ab4560ce", | |
"UpdatePostStickyState": "13de9d1fcbe3", | |
"UpdatePredictionTournament": "87a472f54aa6", | |
"UpdateRecommendationPreferences": "fa7b23e7dbc7", | |
"UpdateReportState": "9d437bfa4b8b", | |
"UpdateScheduledPost": "db256acfa640", | |
"UpdateSocialLinks": "c558e604581f", | |
"UpdateSpokenLanguagesPreference": "6d0707c83164", | |
"UpdateSubredditCountrySiteSettings": "c21fac68db2d", | |
"UpdateSubredditMuteAndNotificationLevelSettings": "2620d72fd633", | |
"UpdateSubredditMuteSettings": "432f6b475ece", | |
"UpdateSubredditNotificationSettings": "0af4f630a2e1", | |
"UpdateSubredditPrimaryTag": "a2d0aa1efdbc", | |
"UpdateSubredditSettings": "ff76dffeb500", | |
"UpdateSubredditTagStatesRelevance": "ee43ccb6e5eb", | |
"UpdateSubredditWelcomeMessage": "1e4c7b58a2a4", | |
"UpdateTopicPreferences": "a48d141a1878", | |
"UpdateVideoContentPermissionsSetting": "5f706173ed69", | |
"UploadV2Events": "2c3efcfc2552", | |
"UserDataExportEligibility": "3817c69d7a39", | |
"UserSavedStripeCards": "d29c51cfbfe6", | |
"UserSubredditsNotificationsLevel": "775bcf2e4ca3", | |
"ValidateCreateSubreddit": "4c43ed06b3c2", | |
"VotePrediction": "484780ada6a2", | |
"WhereToPostSubRec": "11eb5d0b3ee3", | |
"WikiComparisonDiff": "37afdc03bbf6", | |
"WikiRevisions": "83e11ebf7cbf" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install deps | |
#pip3 install curl-cffi quickjs | |
import re | |
import threading | |
import sys | |
import json | |
import time | |
import logging | |
import quickjs | |
from curl_cffi import requests | |
from pathlib import Path | |
#this script scrapes graphql query names and ids from reddit.com | |
#this is basically regex spam until someone figures out a better alternative | |
#running this file directly will save the scraped data to the current directory | |
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.5621.0 Safari/537.36" | |
tls_spoof = "chrome107" | |
scraper_threads = 25 | |
base_path = Path(__file__).parent | |
headers = { | |
"User-Agent": user_agent | |
} | |
def get_script_urls(): | |
r = requests.get("https://www.reddit.com/", headers=headers, impersonate=tls_spoof) | |
urls_regex = r'<script async="" data-chunk="\w+" src="(https://www\.redditstatic\.com/desktop2x/.+?js)"' | |
urls = re.findall(urls_regex, r.text) | |
runtime_regex = r'https://www\.redditstatic\.com/desktop2x/runtime~Reddit\.[0-9a-f]{20}\.js' | |
runtime_url = None | |
for url in urls: | |
if re.match(runtime_regex, url): | |
runtime_url = url | |
if not runtime_url: | |
return urls | |
r2 = requests.get(runtime_url, headers=headers, impersonate=tls_spoof) | |
scripts_regex = r'.*}\[e\]\|\|e\)\+"\."\+(.*?)\[\w\]\+"\.js"}' | |
js_string = re.findall(scripts_regex, r2.text)[0] | |
context = quickjs.Context() | |
json_str = context.eval(f"({js_string})").json() | |
scripts_dict = json.loads(json_str) | |
for name, script_id in scripts_dict.items(): | |
urls.append(f"https://www.redditstatic.com/desktop2x/{name}.{script_id}.js") | |
urls = list(set(urls)) | |
return urls | |
def download_all_scripts(): | |
print("Downloading homepage and runtime script...") | |
session = requests.Session(impersonate=tls_spoof) | |
session.headers.update(headers) | |
urls = get_script_urls() | |
total = len(urls) | |
scripts = [] | |
threads = [] | |
print(f"Starting {scraper_threads} threads...") | |
start = time.time() | |
def script_download_thread(): | |
while True: | |
if not urls: | |
break | |
url = urls.pop(0) | |
remaining = total - len(urls) | |
print(f"[{remaining}/{total}] Downloading {url}") | |
r = session.get(url) | |
if not r.ok: | |
print(f"Recieved {r.status_code} while downloading {url}") | |
scripts.append(r.text) | |
for i in range(scraper_threads): | |
thread = threading.Thread(target=script_download_thread, daemon=True) | |
threads.append(thread) | |
for thread in threads: | |
thread.start() | |
for thread in threads: | |
thread.join() | |
end = time.time() | |
print(f"Downloaded {len(scripts)} files in {round(end-start, 2)} seconds.") | |
return scripts | |
def extract_ids(): | |
gql_regex = r'"\./src/redditGQL/operations/(\w+?)\.json":function\(\w\){\w\.exports=JSON\.parse\(\'{"id":"([0-9a-f]+?)"}\'\)}' | |
gql_queries = {} | |
retrieved_scripts = download_all_scripts() | |
print(f"Parsing JS files...") | |
for script in retrieved_scripts: | |
matches = re.findall(gql_regex, script) | |
for name, id in matches: | |
gql_queries[name] = id | |
return gql_queries | |
def export_data(path): | |
print(f"Exporting data to {path}") | |
gql_queries = extract_ids() | |
queries_path = path / "queries.json" | |
with open(queries_path, "w") as f: | |
f.write(json.dumps(gql_queries, indent=2, sort_keys=True)) | |
print(f"Wrote query IDs to {queries_path}") | |
if __name__ == "__main__": | |
export_data(base_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment