Download API: Difference between revisions
Line 45: | Line 45: | ||
You can grab a list of Factorio versions available for download by sending a GET request to the endpoint at | You can grab a list of Factorio versions available for download by sending a GET request to the endpoint at | ||
<code>https://www.factorio.com/download</code> | <code>https://www.factorio.com/download/stable</code> | ||
Experimental releases have their own page, which has the same interface, and can be found at: | Experimental releases have their own page, which has the same interface, and can be found at: |
Revision as of 21:13, 19 November 2017
This API allows you to download official releases of stand-alone Factorio from the Factorio servers. It's not so much of an API as it is web scraping, but it's documented here for completeness. Please update this page if you utilize it and the information becomes outdated. Also note that's there's a separate, (semi)official API for upgrading between releases, which should be used when possible to lighten the load on the Factorio servers. (I'll document that later, promise!)
Authenticating
Downloading Factorio requires an authenticated session with the web server, which is different than the typical API authentication mechanism. Authentication uses the HTML endpoint at
https://www.factorio.com/login
Login in procedure:
- Create an HTTP session and send a GET request. You'll get some HTML in return.
There's a CSRF token you'll need to grab which can be found using one of the following selectors:- CSS1:
input[name=csrf_token]
(and then take the "value" attribute). - XPATH1:
//input[@name="csrf_token"]/@value
- CSS1:
- Then send a POST request with the following parameters:
csrf_token
: the CSRF token you grabbed earlier.username_or_email
: your username or email address.password
: your password.
Downloading
Download Factorio releases at
https://www.factorio.com/get-download/{version}/{build}/{distro}
- Where {version} is the version string of the release you wish to grab - e.g. "0.15.31".
- {build} is the release build, which currently comprises of:
alpha
- the current standard full-featured build.demo
- the free, publicly accessible demo versions.headless
- for running servers on machines without graphical interface.
- and {distro} is the os / type of release you wish to download, currently:
win64
- EXE installer for 64 bit Windows.win64-manual
- ZIP package for 64 bit Windows.win32
- EXE installer for 32 bit Windows. No longer supported.win32-manual
- ZIP package for 32 bit Windows. No longer supported.osx
- DMG package for 64 bit Mac OS.linux64
- tar.gz or tar.xz package for 64 bit Linux.linux32
- tar.gz or tar.xz package for 32 bit Linux. No longer supported.
Factorio servers will correctly respond with a 404 if the requested download isn't available. Experimental builds are taken down quickly after they become obsolete, so it's best to check what versions are available before hand (documented below).
Note: Windows 32 bit and 64 bit installers are Inno Setup formatted packages (I'll document that somewhere someday).
Version Listings
You can grab a list of Factorio versions available for download by sending a GET request to the endpoint at
https://www.factorio.com/download/stable
Experimental releases have their own page, which has the same interface, and can be found at:
https://www.factorio.com/download/experimental
There is also another endpoint available that filters to only headless releases. (Does not contain experimental releases)
https://www.factorio.com/download-headless
Then a list of version number and build combinations can be grabbed by using either of the selectors:
- CSS1:
h3
- XPATH1:
//h3
Alternatively, you can skip straight to selecting all of the download links, and parsing out the version numbers and such from there. (I actually recommend this method)
- CSS1:
body>div>ul a
(and then take the "href" attribute) - XPATH1:
//body/div/ul//a/@href