Get started with RestApi!


With this guide, you will be able to learn how to integrate and use RestAPI in your Minecraft mods, regardless of your knowledge of Java or Minecraft mods. We will teach you how to integrate the API, make it compatible with Forge, Fabric, and Quilt, and show you where you can find all the documentation and examples to follow.

Author: restonic4

Published on: 21/11/2023

What you need


To create a mod (or integrate one you already have) with our API, you will need a code editor, install a plugin in the editor to facilitate the work, integrate Architectury API, and finally integrate RestApi.

We recommend using IntelliJ IDEA as your code editor; there is a free version of this editor that is very powerful. You can find it here.

Editor Installation


For this guide, we will focus on IntelliJ IDEA. If you are using another editor, skip this part. The problem is that you won't have access to the plugin that automatically installs Architectury API, and you will need to copy a template from the internet.

When you go to IntelliJ IDEA's website, you will need to click on download. On that page, you will find two versions of IntelliJ IDEA. The first one is paid, but the Community Edition is completely free:

Download IntelliJ IDEA

Once you have the editor, you'll need to install it, configure it to your liking, and finally, install the plugins we need.

Plugin Installation


Now we need to install 2 plugins to make everything work.

First, we need Minecraft Development, a very popular plugin for mod and plugin development in Minecraft.

Once you have Minecraft Development, you will need to install Architectury.

By installing Architectury, you can now create projects that include its API, meaning you can create mods for Forge, Fabric, Quilt, etc., all at the same time.

Create a Project


Now that we have everything related to installation ready, it's time to create a project and configure it to use RestApi.

The first thing we'll do is create a new project in IntelliJ IDEA and select Minecraft. Then, choose Mod, Architectury, and enable ArchitecturyApi:

Create new project on IntelliJ IDEA
Create new project on IntelliJ IDEA

Project Verification


After you have created the project, give IntelliJ IDEA a few minutes to prepare all the files. You will see a blue progress bar in the bottom right corner.

When the editor finishes, check that you have these files and folders. If you don't have them, the editor may still be adding them, or there might be an issue with the setup.

Necessary files marked in blue:

New project on IntelliJ IDEA

Preparation and Installation of RestApi and Architectury


Almost there! Now we need to edit some files to install RestApi and configure Architectury correctly.

First, let's go to gradle.properties, and you will have something like this:

                                        
org.gradle.jvmargs=-Xmx2G

archives_base_name=SlimeBoots
mod_version=1.1
maven_group=me.restonic4

###########################

minecraft_version=1.19.3

architectury_version=7.1.86

fabric_loader_version=0.14.22
fabric_api_version=0.76.1+1.19.3

forge_version=1.19.3-44.1.23

rest_api_version=0.10
                                        
                                    

As you can see, I've added a dividing line of # and moved "minecraft_version=1.19.3" down. Everything above this line is the basic data for your mod, such as its name, version, main folder, and the RAM it will use when exporting the mod. Below, we have Minecraft versions and other dependencies/mod loaders/apis.

I've also added "rest_api_version=0.10"; this specifies the version of RestApi, and you can choose the one that suits you best.

If you want to change your mod's version, it can be confusing and messy since you have to change many version numbers. So, I've prepared a table with the Minecraft version and the versions of Forge, Fabric, Quilt, and Architectury they require.

Versions


minecraft_version 1.19.3 1.19.4 1.20 1.20.1 1.20.2 1.20.4 1.20.5
fabric_loader_version 0.14.22 0.14.22 0.14.22 0.14.22 0.14.22 0.15.3 -
fabric_api_version 0.76.1+1.19.3 0.86.1+1.19.4 0.83.0+1.20 0.88.1+1.20.1 0.89.1+1.20.2 0.93.1+1.20.4 -
forge_version 1.19.3-44.1.23 1.19.4-45.2.0 1.20-46.0.14 1.20.1-47.1.47 1.20.2-48.0.13 1.20.4-49.0.19 -
Forge version range (mods.toml) 44 45 46 47 48 49 -
architectury_version 7.1.86 8.2.89 9.1.12 9.1.12 9.1.12 11.0.11 -
quilt_loader_version 0.22.0-beta.1 0.22.0-beta.1 0.22.0-beta.1 0.22.0-beta.1 - - -
quilt_fabric_api_version 5.0.0-beta.9+0.76.0-1.19.3 6.0.0-beta.9+0.83.0-1.19.4 7.2.2+0.88.1-1.20.1 7.4.0+0.90.0-1.20.1 - - -
neoforge_version - - - - 20.2.88 20.4.83-beta -

Now we need to configure the build.gradle file. To do that, open it and go to the following marked section:

                                        
allprojects {
    apply plugin: "java"
    apply plugin: "architectury-plugin"
    apply plugin: "maven-publish"

    archivesBaseName = rootProject.archives_base_name
    version = rootProject.mod_version
    group = rootProject.maven_group

    repositories {
        #####################################################################
        //This zone should be empty or full of comments, delete everything.//
        #####################################################################
    }

    tasks.withType(JavaCompile) {
        options.encoding = "UTF-8"
        options.release = 17
    }

    java {
        withSourcesJar()
    }
}
                                        
                                    

You will need to find the "allprojects" section and within that section, look for "repositories." Inside repositories, you will find many comments; delete them and insert the following code:

                                        
     repositories {
        exclusiveContent {
            forRepository {
                maven {
                    name = "Modrinth"
                    url = "https://api.modrinth.com/maven"
                }
            }
            filter {
                includeGroup "maven.modrinth"
            }
        }

        maven {
            // location of the maven that hosts JEI files since January 2023
            name = "Jared's maven"
            url = "https://maven.blamejared.com/"
        }
    }
                                        
                                    

The code we just inserted is capable of going to Modrinth and downloading the RestApi files for when we start using RestApi.

Configure RestApi with Forge


For Forge to recognize RestApi, you will have to open the Forge folder and edit build.gradle. In that file, you only need to add one line of code in a specific place:

                                        
dependencies {
    forge "net.minecraftforge:forge:${rootProject.forge_version}"
    // Remove the next line if you don't want to depend on the API
    modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"

    ##########################################################################################################
    modImplementation "maven.modrinth:rest-api:${project.rest_api_version}-${project.minecraft_version}-forge"
    ##########################################################################################################

    common(project(path: ":common", configuration: "namedElements")) { transitive false }
    shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
}
                                        
                                    

As you can see, you'll need to find the "dependencies" section and add the line that is between the ####. Only remove the ##### to make the code work.

Once you've edited the Forge build.gradle, you'll need to open the src folder inside Forge, then resources, META-INF, and open the mods.toml file.

This file configures your mod for Forge. Here you will have to configure different parameters depending on the Minecraft version you choose, and you'll also need to include RestApi. Here's an example:

                                        
modLoader="javafml"
loaderVersion="[44,)"
license="MIT"
issueTrackerURL="https://marco/SlimeBoots/issues"

[[mods]]
modId="slimeboots"
version="${version}"
displayName="SlimeBoots"
logoFile="icon.png"
description='''

'''
[[dependencies.slimeboots]]
   modId="forge"
   mandatory=true
   versionRange="[44,)"
   ordering="NONE"
   side="BOTH"
[[dependencies.slimeboots]]
   modId="minecraft"
   mandatory=true
   versionRange="[1.19.3]"
   ordering="NONE"
   side="BOTH"
[[dependencies.slimeboots]]
   modId="restapi"
   mandatory=true
   versionRange="[0.10-1.19.3-forge]"
   ordering="NONE"
   side="BOTH"
                                        
                                    

As you can see, there is a section that looks like this:

                                        
[[dependencies.slimeboots]]
   modId="restapi"
   mandatory=true
   versionRange="[0.10-1.19.3-forge]"
   ordering="NONE"
   side="BOTH"
                                        
                                    

This tells Forge to prompt the user to install RestApi. If you don't include it and a user doesn't install RestApi, Forge will crash without informing the user that they need to install RestApi, which may lead the user to think that your mod is broken.

Configure RestApi with Fabric


For Fabric to recognize RestApi, you will need to open the Fabric folder and edit build.gradle. In that file, you only need to add one line of code in a specific place:

                                        
dependencies {
    modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
    modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
    // Remove the next line if you don't want to depend on the API
    modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"

    ###########################################################################################################
    modImplementation "maven.modrinth:rest-api:${project.rest_api_version}-${project.minecraft_version}-fabric"
    ###########################################################################################################

    common(project(path: ":common", configuration: "namedElements")) { transitive false }
    shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
}
                                        
                                    

You will need to find the "dependencies" section and add the line that is between the ####. Only remove the ##### to make the code work.

Once you've edited the Fabric build.gradle, you'll need to open the src folder inside Fabric, then resources, and open the fabric.mod.json file.

This file configures your mod for Fabric. Here you will have to configure different parameters depending on the Minecraft version you choose, and you'll also need to include RestApi. Here's an example:

                                        
{
  "schemaVersion": 1,
  "id": "slimeboots",
  "version": "${version}",

  "name": "SlimeBoots",
  "description": "",
  "authors": [],
  "contact": {},

  "license": "MIT",
  "icon": "icon.png",

  "environment": "*",
  "entrypoints": {
    "main": [
      "me.restonic4.slimeboots.fabric.SlimeBootsFabric"
    ]
  },
  "depends": {
    "fabricloader": ">=0.14.22",
    "minecraft": "=1.19.3",
    "architectury": ">=7.1.86",
    "restapi": "=0.9-1.19.3-Fabric"
  }
}

                                        
                                    

As you can see, there is a section that looks like this:

                                        
"depends": {
    "fabricloader": ">=0.14.22",
    "minecraft": "=1.19.3",
    "architectury": ">=7.1.86",
    "restapi": "=0.10-1.19.3-fabric"
  }
                                        
                                    

This informs Fabric of the mods it needs; put the versions you require. The plugin may not have configured the "fabricloader" version correctly, so double-check it; otherwise, your mod may not work.

Another error that often occurs with the plugin is that it may not place the "entrypoints" or leave it empty. To fix this, you will need to follow the example above and put something like this, but changing it to match your project's names:

                                        
"entrypoints": {
    "main": [
      "YOUR.PATH.TO_THE_MOD.fabric.MAIN_SCRIPT_NAME_Fabric"
    ]
  },
                                        
                                    

Configure RestApi with Quilt


Adding Quilt is a more complex and lengthy process, so we won't discuss how to do it in this post. However, stay tuned because very soon, you will have a post on our website dedicated to integrating RestApi with Quilt.

Very soon? It's right here! Read how to add Quilt to your project.

Finish the Configuration


Finally, we are getting closer to the end. It might have seemed like a lengthy process, but in reality, it gets easier, and you'll become faster with time.

Now, to finish the configuration, you will need to open the "common" folder. Inside it, open build.gradle and edit it, something like this:

                                        
dependencies {
    // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
    // Do NOT use other classes from fabric loader
    modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
    // Remove the next line if you don't want to depend on the API
    modApi "dev.architectury:architectury:${rootProject.architectury_version}"

    ###########################################################################################################
    modImplementation "maven.modrinth:rest-api:${project.rest_api_version}-${project.minecraft_version}-fabric"
    ###########################################################################################################
}
                                        
                                    

You need to go to dependencies and add the line marked by the ####. Again, remove the #### to make the code work.

Finished!


When you've completed everything, all you have to do is click on the icon that will appear in the upper right corner: IntelliJ IDEA reload project

Clicking on it will start the installation process, and you will be ready to use RestApi.

I hope this post has been helpful in getting started with RestApi. Here is the documentation for you to learn how to use RestApi.