Mod portal API

From Official Factorio Wiki
Jump to navigation Jump to search
Category: Internal API

The Mod Portal API is used to both browse and download all mods available on the official Factorio mod portal. Using the API does not require any kind of authentication or account information and can be viewed simply by following the URLs below in any web browser.

https://mods.factorio.com/api/mods

More detailed information about a particular mod can be obtained by retrieving the following URL, where {name} is the mod's name field in the result object.

https://mods.factorio.com/api/mods/{name}

To get even more information about a mod, you can use the following URL.

https://mods.factorio.com/api/mods/{name}/full

List of bookmarked mods can be accessed from following URL (requires authentication).

https://mods.factorio.com/api/bookmarks?username={username}&token={token}

You can also toggle a bookmark using following URL, with state being on or off.

https://mods.factorio.com/api/bookmarks/toggle?username={username}&token={token}&mod={name}&state={state}

Endpoints

/api/mods

GET Parameters (sent as query parameters):

Key Values Description
hide_deprecated Boolean? Whether to exclude incompatible mods from the results. Defaults to true if absent
page Integer? Page number to fetch, ignored for page_size="max" queries. Defaults to 1 when absent
page_size (Integer | "max")? The amount of results to show per page, or all results when passed "max". Defaults to 25 when absent
sort String? (one of "name", "created_at" or "updated_at") Sort results by this property. Defaults to "name" when absent. Ignored for page_size=max queries
sort_order String? (either "asc" or "desc") Sort results ascending or descending. Defaults to "desc" when absent. Ignored for page_size="max" queries
namelist String[]? Return only mods that match the given names. Response will include releases instead of latest_release
version Factorio Version String (e.g. "2.0.76") Mods incompatible with this Factorio version are marked as deprecated and hidden for hide_deprecated=true queries.


Returns #Mod List Response

/api/mods/{mod_name}

Return short information of a specific mod.

See #Result Entry, "Short" column.

/api/mods/{mod_name}/full

Returns more information of a mod.

See #Result Entry, "Full" column.

/api/bookmarks

Returns array of mod names

/api/search

POST Parameters (sent as json content):

Keys Values Descrption
version Factorio Version String (e.g. "2.0.76") The version of Factorio to search mods for, mods incompatible with this version are marked as "deprecated"
lang Locale Identifier? No effect on response
is_space_age Boolean? No effect on response
username String factorio.com account username to use for the query
token String factorio.com account token to use for the query
query String? The string to filter by, empty or absent does not filter
sort_attribute Sort Attribute? The attribute to sort the results by. Defaults to "relevancy" if absent
only_bookmarks Boolean? Whether to filter results down to only mods bookmarked by the account given by username and token. Defaults to false if absent
show_deprecated Boolean? Whether to show mods incompatible with the Factorio version specified with version. Defaults to false if absent
highlight_pre_tag String? A string to place in front of the matched text for query, defaults to "<em>" if absent. If query is empty or absent, value is ignored
highlight_post_tag String? A string to place behind the matched text for query, defaults to "</em>" if absent. If query is empty or absent, value is ignored
expansion String[]? A whitelist of expansion(s) to filter mods with (currently the only valid value is "space-age")
exclude_expansion String[]? A blacklist of expansion(s) to filter mods with (currently the only valid value is "space-age")
category Category[]? A whitelist of categories to filter mods with
exclude_category Category[]? A blacklist of categories to filter mods with
tag Tag[]? A whitelist of tags to filter mods with
exclude_tag Tag[]? A blacklist of tags to filter mods with
page Integer Page number you would like to show, ignored for page_size="max" queries
page_size Integer or "max" The amount of results to show per page, or all results when passed "max"

JSON Object Types

Sort Attribute

Attribute Sort By
"relevancy" Seemingly identical to "last_updated_at"
"most_downloads" Download count
"last_updated_at" Most recently updated
"trending" Internal metric

Mod List Response

Key Type Description
pagination Pagination See #Pagination
results Result[] A list of mods, matching the filters specified by the query

Pagination

Key Type Description
count Integer Total number of mods that match your specified filters.
links Links? Utility links to mod portal api requests, preserving all filters and search queries. Absent from the /api/search endpoint response
page Integer The current page number.
page_count Integer The total number of pages returned.
page_size Integer The number of results per page.

Pagination Links

Key Type Description
first String(URL) URL to the first page of the results, or null if you're already on the first page
prev String(URL) URL to the previous page of the results, or null if you're already on the first page
next String(URL) URL to the next page of the results, or null if you're already on the last page
last String(URL) URL to the last page of the results, or null if you're already on the last page

Result Entry

Fields returned by the api/mods endpoint are marked with a check (✓) in the "api/mods endpoint" column, those returned by the api/mods/{name} endpoint are marked with a check in the "Short" column and those returned by the api/mods/{name}/full endpoint are marked in the "Full" column. Fields may be absent if there is no data.

Key Type api/mods endpoint Short Full Description
latest_release Release? ✓* The latest version of the mod available for download. *Absent when the namelist parameter is used.
downloads_count Integer Number of downloads.
name String The mod's machine-readable ID string.
owner String The Factorio username of the mod's author.
releases Release[] ✓* A list of different versions of the mod available for download. See #Releases. *Only when using namelist parameter.
summary String A shorter mod description.
title String The mod's human-readable name.
category Category? A single category describing the mod. See Mod_details_API#Category.
score Integer ✓* ✓* The score of the mod. *Only when not 0.
thumbnail String(relative URL)? The relative path to the thumbnail of the mod. For mods that have no thumbnail it may be absent or default to "/assets/.thumb.png". Prepend "assets-mod.factorio.com".
changelog String? A string describing the recent changes to a mod.
created_at String(ISO 8601) ISO 8601 for when the mod was created. (RFC 3339 nano)
updated_at String(ISO 8601) ISO 8601 for when the mod was last updated. (RFC 3339 nano)
last_highlighted_at String(ISO 8601)? ISO 8601 for when the mod was last featured on the "Highlighted mods" tab. (RFC 3339 nano)
description String? A longer description of the mod, in text only format.
source_url String? A URL to the mod's source code.
github_path String? Deprecated: Use source_url instead. A link to the mod's github project page, just prepend "github.com/". Can be blank ("").
homepage String Usually a URL to the mod's main project page, but can be any string.
tags Tag[] A list of tag names that categorize the mod. See #Mod_details_API#Tags.
license #License[] The license that applies to the mod. See #License.
deprecated Boolean? True if the mod is marked as deprecated by its owner. Absent when false.

Releases

Only difference here between the api/mods/{name} endpoint and the api/mods/{name}/full endpoint is that the full one includes an array of dependencies in the info_json object.

Key Type Description
download_url String Path to download for a mod. starts with "/download" and does not include a full url. See #Downloading Mods
file_name String The file name of the release. Always seems to follow the pattern "{name}_{version}.zip"
info_json Object A copy of the mod's info.json file, only contains factorio_version in short version, also contains an array of dependencies in full version
released_at String(ISO 8601) ISO 8601 for when the mod was released. (RFC 3339 nano)
version String The version string of this mod release. Used to determine dependencies.
sha1 String The sha1 key for the file.
feature_flags String[]? The feature flags this mod uses. See FeatureFlags

License

Key Type Description
description String A short description of the license.
id String The unique id of the license. For more information on each, see License
name String The internal name of the license.
title String The human-readable title of the license.
url String Usually a URL to the full license text, but can be any string.

Error

Key Type
message String

Downloading Mods

You can get the full url by appending the download_url to mods.factorio.com, but if you're not authenticated, you will be redirected to mods.factorio.com/login. Logging in to that would give you access to the file. Fortunately, there's a better way to do this. Simply adding username and token parameters to the download url will prevent the redirecting and let you download the file immediately. The token can be acquired from a json file called "player-data.json", located in the User Data directory (see Application_directory#User_data_directory). You can also get the token by using the Web Authentication API.

Example usage: https://mods.factorio.com/{download_url}?username={username}&token={token}