Publishing all places of a universe after package mass-update

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

  1. 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.
    Sans titre

  2. 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
  1. 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 !

  2. 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 !

  3. 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 !

16 Likes

not bad I think it helpful for developer

Thanks for this code very useful. But I keep getting {“code”:3,“message”:“API Key has insufficient scopes.”} when the program cycles through all the places in my universe. Could I get some help troubleshooting?

From the error message it looks like your API key is not configured correctly.
Make sure your key:

Let me know if that helped.

1 Like

It was an issue with my IP address but I figured it out. Thank you

1 Like

This is really good thank you, but I keep getting this problem
image

Make sure the API key is enabled and has not expired (in your creator dashboard), or generate a new one.

2 Likes

I have done all that but it still brings up the same error, could it be because I have my Experience inside a group?

I found out that it was because of the group, THANK you for the code. It genuinely helped a lot, but if there is a way to make it work with the groups, please let me know.
:heart:

I also use this script for group games and it works.
Make sure the API key was generated using your group’s profile in the creator dashboard, like below.
image

1 Like