kevinta893 / factorio-recipes-json

A JSON file containing factorio recipes. Designed to be recursively browsable.
https://kevinta893.github.io/factorio-recipes-json
MIT License
19 stars 6 forks source link

factorio-recipes-json

Build Status [license]() [factorio version]()

A database of Factorio Recipes in JSON designed for HTML visualizations of the game's recipes. Recursive algorithms can be used to determine item dependancies. Of course, this repository has automated build, test, and deployment in honour of Factorio's style. :smile:

Please note that the database is still under development, there may be signficant changes before the complete version is released

See the demo recipe browser here.

Recipe Data sourced from the Official Factorio Wiki and the official game's Lua recipe files. Send me pull requests if you find any inconsistencies or errors.

How to use

The database is a JSON list of all the recipes in the game. Recipe dependancies can be searched by their IDs. It also includes some item types like Resources (e.g. Iron) and Liquids (e.g. Water) to help recursive algorithms terminate properly. See Addtional Notes below for more information

1. Import the file

You can use one of the two flavors of the database: Array or Dictionary. The Array list is the canonical used for development. The dictionary uses the id of the recipe as the key. Use one of the following links below to get the file for your project:

CDN coming soon.

2. Using the file

In JQuery, You can fetch the latest version of the JSON file from GitHub:

$.getJSON("https://kevinta893.github.io/factorio-recipes-json/recipes.min.json", function (json, err){
    if (err != "success"){
        console.log("Error cannot load json\n" + err);
        return;
    }

    var recipesList = json;
    //TODO your code here
});

In Node.js, you can synchronously or asynchronously get the file from your machine locally (synchronous example below):

var recipesList = JSON.parse(fs.readFileSync('recipes.json', 'utf8'));          //synchronous

Data Fields

Field Description
id The internal name of the item
name The user friendly name
type The item type of the resulting item. One of: Machine, Resource, Liquid, Intermediate product, Item, Science Pack, Combat, Process, Tool, null
wiki_link A link to the Factorio Wiki
recipe The item's recipe (normal mode)
recipe->ingredients A list of ingredients to make the recipe, each ingredient has is an item with an id and amount.
recipe->time The factorio time to produce the object
recipe->yield The amount of the product produced by this recipe

Addtional Notes

Here is a list of exceptions to take note of in the database:

Tips & Tricks