Share your repls and programming experiences

← Back to all posts
✨⭐ Repl Talk API for Python ⭐✨ (With documentation)
h
mat1 (3290)

Repl Talk API (unofficial)

Easily communicate with the GraphQL Repl Talk API with this project.
https://pypi.org/project/repltalk/


Features

  • Beautiful asynchronous goodness
  • Easy to use
  • Documentation
  • Also it uses the Repl.it GraphQL API so there's no web scraping going on here.
  • Allows logging in (for verified bots to prevent spammers)
  • The only Repl Talk API that works in Python
  • Implements pretty much every Repl Talk route
  • Made by mat™
  • Can be imported
  • Leave a comment if you want to request a feature!*

Examples

# Print the titles of the top Repl Talk posts
import asyncio
import repltalk


client = repltalk.Client()

async def main():
	top_posts = await client.boards.all.get_posts()
	for post in top_posts:
		print(post.title)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
# Gets the amount of cycles for a user
import asyncio
import repltalk

client = repltalk.Client()

async def main():
	username = input('Enter a username\n> ')
	user = await client.get_user(username)
	print(f'{user.name} has {user.cycles} cycles')
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Leave a comment if you have an example!

API Reference

The documentation below may be outdated, please use the documentation on pypi instead

Client

class repltalk.Client()

  • coroutine login(username, password)
    Logs in to Repl.it with your username and password. Your bot must be verified in order to use this function.
  • coroutine get_post(post_id)
    Gets the post with that id.
    Returns Post
  • coroutine post_exists(post_id)
    Returns whether or not the post exists.
    Returns Bool
  • coroutine get_leaderboard(limit=30)
    Gets the top users from the Repl Talk leaderboard.
    Returns list of Users
  • coroutine get_all_comments()
    Gets all the recent comments from Repl Talk.
    *returns list of Comments
  • coroutine get_user(username)
    Gets the user with that username.
    returns User
  • boards
    See Board.

Board

class client.boards


  • all
    The All board on Repl Talk
  • share
    The Share board on Repl Talk
  • ask
    The Ask board on Repl Talk
  • announcements
    The Announcements board on Repl Talk
  • challenge
    The Challenge board on Repl Talk
  • learn
    The Learn board on Repl Talk

  • coroutine get_posts(sort='top', search='')
    Gets the most recent posts from that board.
    Sort is the sorting order (top|hot|new) and search is the search query.
    returns PostList

Post

  • id
    The post ID
  • title
    The post title
  • content
    The post content
  • board
    The board the post was made on.
  • votes
    The amount of upvotes the post has.
  • author
    The post author. Will be a User object.
  • datetime
    The time the post was created at.
  • url
    The post url in Repl Talk.
  • repl
    The repl attached to the post.
  • show_hosted
    Indicates if the post has a hosted repl linked to it.
  • is_announcement
    If the post is marked as an announcement.
  • can_edit
    Indicates if the user can edit the post. This will be False unless you created the post.
  • can_comment
    If the user can comment on the post.
  • can_vote
    Indicates if the user can upvote the post.
  • has_voted
    Indicates if the user has already voted on the post.
  • is_locked
    Indicates if the post is locked.
  • coroutine get_comments()
    Gets the comments on the post.
  • coroutine post_comment(content)
    Posts a comment on the post

Comment

  • id
    The post ID.
  • content
    The post body.
  • time_created
    The time the comment was created at.
  • can_edit
    Indicates if the user can edit the comment.
  • can_comment
    Whether or not the user can post a comment.
  • url
    The comment's url.
  • votes
    Gets the amount of upvotes the comment has.
  • can_vote
    Indicates if the user can vote on the comment.
  • has_voted
    Indicates if the user has already upvoted the post.
  • coroutine reply(content)
    Replies to the comment with the content

User

  • id
    The user ID. Pretty useless since you can't get the user from their id.
  • name
    The user's username.
  • avatar
    The user's avatar url
  • url
    The user's profile link
  • cycles
    The amount of cycles that user has
  • roles
    The roles the user has set on their profile.

PostList

Acts basically like a normal list

  • coroutine next()
    Gets the next page of posts

Make sure to upvote this post and leave a comment if you think this is cool!

-mat

Commentshotnewtop
Codemonkey51 (834)

@mat1 HALP I'm trying to get the leader board and i get this error:

Traceback (most recent call last): 
File "main.py", line 6, in <module> asyncio.run(test())
File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run 
return loop.run_until_complete(main)
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 612, in run_until_complete
return future.result() 
File "main.py", line 5, in test
await repltalk.Client.getleaderboard(limit=30)
TypeError: get_leaderboard() missing 1 required positional argument: 'self'
RomeroSchwarz (264)

How can you login to accounts that use google verification?

MatReiner (106)

Make available for nodejs and php

MatReiner (106)

HOW DO YOU WHITELIST BOTS!?

ebest (639)

is there a way to use this to figure out the username of the person using the program?

ebest (639)

@ebest if there isn't, there should be one.

mat1 (3290)

@ebest I'm not sure what you mean. You can get a user from their username using await client.get_user('username') and you can get the author name of a post by doing print(post.author.name).

ebest (639)

@mat1 Wait this might be the wrong place to put it but I want to get the username of the person running my program.

mat1 (3290)

@ebest That's not possible at the moment due to how Repl.it works.

Tacoman500 (1)

You should add a vote method for comments, posts, and boards.

mat1 (3290)

@Tacoman500 it used to, but I removed it because I don't want people using upvote bots.

Mooopy (62)

I tried importing it and my computer blew up

mat1 (3290)

Please upvote and leave a comment if you have any suggestions!