A ruby wrapper for the repl talk gql api.
Getting Started
Gemfile
gem "repltalk"
Initializing Client
require "repltalk"
client = ReplTalk::Client.newOnce you have your client initialized, you can start getting users, posts, comments etc.
Code Snippets
A few small snippets of examples of what you can do with the repltalk gem
Get CodingCactus' posts from the top 100 posts:
client.get_posts(order: "Top", count: 100).select { |post| post.author.username == "CodingCactus" }Get the 10 most recent ruby post's URLs
client.get_posts(count: 10, languages: ['ruby']).map { |post| post.url }See how many people have forked CodingCactus' classrooms repl
client.get_repl("/@CodingCactus/classrooms").fork_countSee how many comments in a post mention CodingCactus
mentions = 0
client.get_post(33995).get_comments(count: 999999999).each do |comment|
mentions += 1 if comment.content.include?("@CodingCactus")
comment.get_comments.each { |child_comment| mentions += 1 if child_comment.content.include?("@CodingCactus") }
sleep 0.25 # need to be careful with rate limits
endSee how many repls of each language CodingCactus has
lang_count = client.get_user("CodingCactus").get_repls(count: 999999).reduce(Hash.new(0)) do |langs, repl|
langs[repl.language.id] += 1
langs
endAll Methods Documentation
Client
-
#get_user usernameGet a user from their username. ReturnsUser -
#get_user_by_id idGet a user from their id. ReturnsUser -
#search_user query, :countSearch for users whose username start with the query. Returns array ofUsers. Need to be logged in, unfortunately -
#get_post idGet a post from it's id. ReturnsPost -
#get_comment idGet a comment from it's id. ReturnsComment -
#get_repl urlGet a repl from it's url. ReturnsRepl -
#get_repl_comment idGet a repl comment from its id. ReturnsReplComment -
#get_board nameGet a board from it's name. ReturnsBoard -
#get_posts :board, :order, :count, :after, :searchGet posts from repltalk. Returns array ofPosts -
#create_post board_name, title, content, :repl_id, :show_hostedCreate a repl talk post. ReturnsPost -
#get_explore_featured_replsGet the featured repls on explore. Returns array ofRepls -
#get_trending_tags :countGet the tags which are trending on explore. Returns array ofTags -
#get_tag idGet a tag. ReturnsTag
User
-
#idUser's id -
#usernameUser's username -
#nameUser's full name -
#pfpURL of the user's pfp -
#bioUser's bio -
#timestampWhen the account was made -
#is_hackerWhether the user has the hacker plan -
#rolesUser's roles. Returns an array ofRoles -
#languagesLanguages that the user has used. Returns array ofLanguages -
#get_posts :order, :count, :afterGet the user's posts. Returns array ofPosts -
#get_comments :order, :count, :afterGet the user's comments. Returns array ofComments -
get_repls :count, :order, :direction, :before, :after, :pinnedReplsFirst, :showUnnamedGet the user's repls. Returns array ofRepls
Post
-
#idPost's id -
#urlPost's url -
#replRepl attached to the post. Returns nil if there is none. Else returnsRepl -
#boardBoard that the post is from. ReturnsBoard -
#titlePost's title -
#authorPost's author. ReturnsUser -
#contentPost's content -
#previewPreview of the post's content. -
#timestampWhen the post was posted -
#vote_countHow many votes there post has -
#comment_countHow many comments the post has -
#answerThe comment that has been marked as the answer. Returnsnilif there is none, elseComment -
#is_answeredWhether an answer has been selected -
#is_answerableWhether you are able to answer the post -
#is_announcementWhether the post in marked as an announcement -
#is_pinnedWhether the post is pinned -
#is_lockedWhether the post is locked -
#is_hiddenWhether the post is hidden (unlisted) -
#get_upvotes :countGet the users that have upvoted the post. Count defaults to 10. Returns array orUsers -
#get_comments :order, :count, :afterGet the post's comments. Returns array ofComments -
#create_comment contentComment on the post. ReturnsComment -
#edit :title, :content, :repl_id, :show_hostedEdit the post. ReturnsPost -
#deleteDelete the post -
#report reasonReport the post
Comment
-
#idComment's id -
#urlComment's url -
#authorComment's author. ReturnsUser -
#contentComment's content -
#post_idId of the post that the comment is on -
#is_answerWhether the comment has been selected as the answer to a post -
#vote_countHow many votes the comment has -
#timestampWhen the comment was made -
#get_postGet the post that the comment was made on. ReturnsPost -
#get_commentsGet the children comments of the comment. Returns array ofComments -
#get_parentGet the parent comment of a child comment. Returnsnilif it isn't a child, elseComment -
#create_comment contentreply to the comment. ReturnsComment -
#edit contentEdit the comment. ReturnsComment -
#deleteDelete the comment -
#report reasonReport the comment
Repl
-
#idRepl's id -
#urlRepl's URL -
#titleRepl's name -
#authorRepl's author. ReturnsUser -
#descriptionRepl's description -
#timestampWhen the repl was made -
#sizeHow many bytes the repl is -
#run_countHow many times the repl has been run -
#fork_countHow many times the repl has been forked -
#languageRepl's language. ReturnsLanguage -
#image_urlRepl image's url -
#origin_urlUrl of the repl from which this repl was forked -
#is_privateWhether the repl is private -
#is_always_onWhether the repl is always on -
#tagsTags tagged on the repl. Returns array ofTags -
#reactionsReactions reacted on the repl. Returns array ofReactions -
#get_forksRepl's forks. Returns array ofRepls -
#get_commentsRepl's comments. Returns array ofReplComments -
#create_comment contentComment on the repl -
#add_reaction typeAdd a reaction to the repl -
#remove_reaction typeRemove a reaction from the repl -
#publish description, image_url, tags, :enable_commentsPublish the repl. Use this to publish an update too -
#unpublishUnpublish the repl
ReplComment
-
#idComment's id -
#contentComment's content -
#authorComment's author. ReturnsUser -
#replRepl the comment was made on. ReturnsRepl -
#repliesComment's replies. Returns array ofReplComments -
#create_comment contentReply to the repl comment -
#edit contentEdit the repl comment -
#deleteDelete the repl comment
Tag
-
#idTag's id (name) -
#repl_countHow many repls are listed under the tag -
#creator_countHow many different users are listed under the tag -
#is_trendingWhether the tag is trending -
#repls_tagged_today_countHow many repls have been published with the tag today -
#get_repls :count, :afterGet the top 10 repls that have the tag. Returns array ofRepls
Reaction
-
#idReaction's id -
#typeReaction's type (heart, eyes etc.) -
#countHow many people have reacted with this reaction on the repl
Language
-
#idLanguage's id (like 'python3' or 'html') -
#keyLanguage's key -
#nameLanguage's name (like 'Python' or 'HTML, CSS, JS') -
#taglineLanguage's tagline -
#categoryCategory that the language is in -
#iconURL of the language's icon
Role
-
#nameRole's name -
#keyRole's key -
#taglineRole's tagline
Board
-
#idBoard's id -
#nameBoard's name -
#colorBoard's color -
#descriptionBoard's description