CONTEXT
Packages have an “Update all” feature that enables you to update all occurrences of this package within places of a universe. Yet, the places are only saved and not published, meaning you have to open every places in Roblox Studio and publish manually. This can be very time-consuming if your game has many places. An “AutoPublish” feature was already requested there and there, but with no response so far.
Thankfully, Roblox recently introduced the Open Cloud with which you can publish places by calling the Place Management API.
This tutorial will tell you how to take advantage of this new feature to publish all places of your universe after you made a package mass-update using a simple Python script.
PREREQUISITES
-
Download and install Python 3.8.10 here. For Windows users, I recommend you download the Windows installer 64-bit, or 32-bit if your system does not support 64-bit.
During the installation, make sure you check the “Add Python to environment variables” to make it easier to run the script later.
-
Install the Python package “requests” that will enable you make HTTP requests to the Roblox API. To do so, open your operating system’s terminal (cmd on Windows) and run the following command:
pip install requests
-
Generate an API key that has “Write” permission on the universe you want to publish the places by following the Open Cloud tutorial. DO NOT SHARE THE API KEY !
-
Get your .ROBLOSECURITY cookie. This cookie will be required for the script to download the latest place file for publishing. In Firefox, you can access this cookie by accessing any Roblox website (like home page) and pressing F12 (or right-click → Inspect Element) → Storage → Cookies → https://www.roblox.com → .ROBLOSECURITY. Copy the content of the cell. As written in the cell, DO NOT SHARE THIS COOKIE !
-
Get your universe’s ID. It can be access in the URL of the “Configure Experience” page.
STEPS
- Paste in a .py file you create the following script:
import requests
API_KEY = "YOUR API KEY HERE"
UNIVERSE_ID = YOUR UNIVERSE ID HERE
COOKIES = {".ROBLOSECURITY": "YOUR .ROBLOXSECURITY COOKIE HERE"}
places = requests.get("https://develop.roblox.com/v1/universes/" + str(UNIVERSE_ID) + "/places?sortOrder=Asc&limit=100").json()["data"]
for i in range(len(places)):
print("getting place file for", places[i]["name"], places[i]["id"])
place_data = requests.get("https://assetdelivery.roblox.com/v1/asset/?id=" + str(places[i]["id"]), cookies=COOKIES)
version = int(place_data.history[0].headers["roblox-assetversionnumber"])
print("publishing version", version, "as version", version + 1)
response = requests.post("https://apis.roblox.com/universes/v1/" + str(UNIVERSE_ID) + "/places/" + str(places[i]["id"]) + "/versions?versionType=Published", data=place_data.content, headers={"x-api-key": API_KEY})
print("published", response.text)
print()
-
Put the credentials (API key, universe ID, .ROBLOXSECURITY cookie) you got in the prerequisites in the constants at the beginning of the script where asked.
-
In a terminal, navigate to the path where your .py script is (cd PATH on Windows) and run the script by running the following command:
python FILENAME.py
- That’s it ! All places of the universe are now published !
KEEP IN MIND
-
The .ROBLOXSECURITY cookie has an expiration date and possibly your API key if you set an expiration date to it. Therefore, you need to update those in your script when they change.
-
The script I wrote does not handle HTTP errors. If anything fails, try running the script again, or feel free to fork for your needs.
I hope this tutorial was helpful !