The Mod upload API is now released and properly documented on the Factorio wiki: https://wiki.factorio.com/Mod_upload_API
Testing the new Experimental Mod Upload API
I'm happy to announce that our new mod portal upload API is ready for public testing! Please tell me what you think about it.It's still in experimental state, so please don't update all your tools and clients just yet. There will be changes, depending on your feedback and stabilty of the process.
The Mod Upload API only supports adding releases to existing mods. Support for publishing mods and editing mod details is planned.
Authentication
To authenticate requests to this new mod portal API you need to create a special API Key on your factorio.com/profile page:
Endpoints
init_upload
URL: https://mods.factorio.com/api/v2/mods/r ... nit_upload
HTTP Method
POST
HTTP Request Headers
Authorization:: Authorization header with the APIKey and a "Bearer " prefix -> "Bearer $APIKey"
HTTP Request Body
mod: Name of the mod, for which a new release should be uploaded
JSON object response
upload_url::string: URL the mod zip file should be uploaded to
upload
URL: $upload_url, URL returned by the init_upload endpoint
HTTP Method
POST
HTTP Request Body
file: Mod zip file
JSON object response
success :: bool: This attribute only appears on successful uploads. It's set to true.
error:: string: This attribute only appears on failed uploads. Can contain details about the problem
message :: string: This attribute can appear on failed uploads. Can contains details about the problem
Python Example
Code: Select all
import sys
import requests
from os import getenv
MOD_PORTAL_URL = "https://mods.factorio.com"
INIT_UPLOAD_URL = f"{MOD_PORTAL_URL}/api/v2/mods/releases/init_upload"
apikey = getenv("MOD_UPLOAD_API_KEY")
modname = getenv("MOD_UPLOAD_NAME")
zipfilepath = getenv("MOD_UPLOAD_FILE")
request_body = data={"mod":modname}
request_headers = {"Authorization": f"Bearer {apikey}"}
response = requests.post(
INIT_UPLOAD_URL,
data=request_body,
headers=request_headers)
if not response.ok:
print(f"init_upload failed: {response.text}")
sys.exit(1)
upload_url = response.json()["upload_url"]
with open(zipfilepath, "rb") as f:
request_body = {"file": f}
response = requests.post(upload_url, files=request_body)
if not response.ok:
print(f"upload failed: {response.text}")
sys.exit(1)
print(f"upload successful: {response.text}")
- docs: fix name of Authorization Header (was documented as Authentication, was in fact called Authorization)
- unify responses of upload endpoint
- change endpoint url to v2 prefix
- document possible error values
- create wiki page
Technical Details
The new upload API is built on a refactored version of the old mod uploader and is hosted on heroku instead of a cloud vm. First the mod portal generates a temporary url for the mod uploader, then the mod uploader takes your zip file, extracts information, uploads it to the CDN, forwards the info to the mod portal and then responds with the mod portal result.