Use Python to interact with the Roblox API with ro.py!

GitHub | Discord | PyPI | Documentation | Examples | License

Overview

Welcome to ro.py! ro.py is an asynchronous, object-oriented wrapper for the Roblox web API.

Features

The key features are:

  • Asynchronous: ro.py works well with asynchronous frameworks like FastAPI and
    discord.py.
  • Easy: ro.py’s client-based model is intuitive and easy to learn for both the beginner and expert developer. It
    abstracts away API requests and leaves you with simple objects that represent data types on the Roblox platform.
  • Flexible: ro.py’s builtin Requests object allows the user to do things that we haven’t already implemented
    ourselves without dealing with advanced Roblox-specific concepts.

Installation

:warning: ro.py is in the process of being completely rewritten for the v2.0 release.
All ro.py releases on PyPI (both the ro-py and roblox packages) are using the v1.2.0.5 release, which is not compatible with the documentation found here.

To install ro.py from PyPI, you can install with pip:

pip install roblox

To install the latest unstable version of ro.py, install git-scm and run the following:

pip install git+git://github.com/ro-py/ro.py.git

Tutorial

Learn how to use ro.py in our docs:
https://ro.py.jmk.gg/dev/tutorial/

125 Likes

Something else I’ve ought to mention:
ro.py works very well with other asynchronous libraries like discord.py, which means it can be used very easily to create Roblox-to-Discord bots, verification systems, and more! You won’t even need to set up a web server for it.

I’m planning on making a tutorial for this in the future.

12 Likes

Been searching for a Roblox py lib for ages, def will take a look into this

3 Likes

Sounds great! Please let me know if you need any help with using it.

1 Like

I know I may sound dumb, but could you please explain ro.py more? I’m not sure what it really does.

2 Likes

It wraps up the Roblox API in a neat little bow that lets you interact with Roblox in Python code.

For example, you could

  • view information about a user
  • manage trades
  • accept join requests
  • respond to chat messages
  • hundreds of other actions I can’t be bothered to put here

without ever dealing with an API request yourself.
What might take 5 or 6 API requests to handle in the background can be turned into a piece of Python code that handles everything for you.

tldr: ro.py is a tool for creating bots and other Roblox applications through Python code.

5 Likes

So if I were to open Pycharm right now, open the terminal, and type

pip install ro-py

I could use all its modules (or whatever it’s called)?

EDIT:
The “Get Started” summaries are too advanced for me. However, when I get more skilled in Python, I will be sure to use ro.py!

pip install ro-py

installs ro.py from the Python Package Index. It won’t do anything on it’s own, it’ll just install all the parts of ro.py

Next, you can write a Python file and import ro.py and use it in your projects.

I wish you luck on learning Python, and please let me know if you have any questions about ro.py in the future.

2 Likes

Hey man, I’m just wondering have you found a way to keep the cookies from expiring when logging out? With Roblox’s cookies they expire when you log out of the account, which means if I were to make a group ranking bot I would need to have the ranking account logged in 24/7, I’m trying to find a way around that.

1 Like

Create an incognito tab, then login and get the cookie. Incognito doesn’t save cookies.

1 Like

Well the .ROBLOSECURITY cookie does not expire for years, I am assuming it is Roblox that invalidates the session from their end over some time. Try this - implement some logic to request an authticket every now and then and then redeem said authticket for a new cookie.

2 Likes

I suggest logging in and then either deleting the cookie or just using an incognito window and closing the window (which deletes all cookies)

The only reason logging out invalidates a token is because a logout request is sent to their servers. Just removing the cookie will log you out and allow you to use that cookie theoretically forever (as far as we know, they are never invalidated on the server side. the cookie lasts 30 years on the client side.)

2 Likes

Well the thing is I don’t log out, when I close my incognito tab it automatically logs me out. Do you think i can just delete the cookie with editthiscookie and just log me out but not change the cookie?

1 Like

It doesn’t log you out when you close the incognito window. The cookie is only invalidated if a request is sent to Roblox servers (you must press the logout button)

You should just grab the cookie, put it somewhere, and then close the window. If you grab it and then log out, that cookie’s gone and can’t be used.

1 Like

Ive used this before but I decided that sending requests to the roblox api using the in-built requests package would be easier for my use case. If this awesome package doesn’t suit you then try using the requests module. But make sure you try out this package for yourself though as the devs put lots of work into it. :slight_smile:

1 Like

The requests module is a blanket module that is used for sending API requests, and isn’t particular to Roblox. If you don’t want to use a library that makes it easier and you want to write general Python code that accesses the API, sure, go with that.

However, ro.py allows you to use the Roblox API without using actual ro.py components, and you can send requests without the extra hassle of ROBLOSECURITY cookies, X-CSRF, and other Roblox API quirks. As an example:

from ro_py.client import Client
import asyncio

client = Client("TOKENHERE")
requests = client.requests

async def main():
    await requests.get()  # GET request
    await requests.post()  # POST request
    await requests.patch()  # PATCH request
    await requests.delete()  # DELETE request


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

All of these requests will be authenticated and X-CSRF will be handled, which means requests will just be made easier, even if you aren’t using ro.py-specific objects.

Consider this if you don’t feel like using ro.py. (I promise, it’s easier than raw requests!)

5 Likes

This is a great library which is the successor to @iranathan’s robloxapi with a bunch more features,
I’m glad you two teamed up to create this and hopefully you’ll be able to eventually expand to every endpoint!

1 Like

Glad you like it! We do have plans to implement much more in the future. For some context: ro.py was originally created independently from robloxapi and we merged them later on.

1 Like

I’ve been using this library to give my Discord bot some more features, and I’m very happy with the result. At first I worried it would take a lot of work to implement this into the code which I already have written, as I am using different cogs and have many commands, but it was extremely easy to implement and get to work with my pre-existing code. The “Getting Started” tutorial was informative and the examples in the documentation were very useful. This is an easy to use, overall great resource which will be useful for many different purposes. :+1:

1 Like

I’m glad you found it helpful! We tried our best to keep ro.py fairly easy to understand while also supporting new features, and it’s nice to know that our work payed off.
I’m also working on a tutorial for specifically Discord-Roblox bots with ro.py, which will release soon. I assume you’re already past that point, given you already have a bot, but it might be a nice read when it does release.

1 Like