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

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

Can you get the online or offline status of the player?

1 Like

I would assume so using the Presence API in it

2 Likes

I’m still working on Presence - I’ll update you when I’m 100% done, as it should be in less than a week.

1 Like

Hey! Great module you’ve made, and I’m in need of some help. I’m not that good with Python, so how would I join a game using this? I read the documentation, but couldn’t understand. Thanks in advance!

What exactly is your use case? Why do you need to join a game using ro.py?

That’s still pretty malicious…

Is it, though? All it’s supposed to do is join a game and sit there lol

Yes. Premium pay. I’m sure that’s against TOS

1 Like

But don’t premium payouts only work for premium users? The client/bot I’m wanting to use doesn’t have Premium

What’s your use case? Why do you want to programmatically payout users?