> For the complete documentation index, see [llms.txt](https://tfagaming.gitbook.io/homestead/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tfagaming.gitbook.io/homestead/developers/api.md).

# API

To access the Homestead API in your plugin, download the Homestead **.jar** file from SpigotMC and upload it as a third-party JAR to your project.\
[Click here](https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project?page=1) or [here](https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html) for the guide to installing the dependency.

{% hint style="danger" %}
**Caution:** This documentation explains the API from **version 4.0.2**. Try to make a condition in your plugin to verify that the installed Homestead version is 4.0.2 or higher.
{% endhint %}

## Example plugin

This is an example plugin that uses the Homestead API.

```java
import java.util.logging.Logger;
import org.bukkit.plugin.java.JavaPlugin;

import tfagaming.projects.minecraft.homestead.Homestead;
import tfagaming.projects.minecraft.homestead.api.API;
import tfagaming.projects.minecraft.homestead.api.HomesteadAPI;

public class Plugin extends JavaPlugin {
	private static final Logger logger = Logger.getLogger("Example");

	public void onEnable() {
		logger.info("Example plugin is enabled");
		
		try {
			// Get the instance (verifies if the plugin is installed and enabled)
			Homestead instance = Homestead.getInstance();

			// Showing Homestead's installed version on the server
			logger.info("Homestead's version = " + Homestead.getVersion());

			// Getting the API
			HomesteadAPI api = new API();

			api.getRegionsManager();
			api.getChunksManager();
		} catch (NoClassDefFoundError e) {
			logger.warning("Unable to find Homestead plugin!");
		}
	}

	public void onDisable() {
		logger.info("Example plugin is disabled");
	}
}

```

Package your Java project and then export it as a **.jar** file. You will notice a new **.jar** file appears in the main directory of your project, upload it to your server's plugins folder, and then restart the server!

<figure><img src="/files/h6Fn2GUFwgxZdZjTQEDP" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tfagaming.gitbook.io/homestead/developers/api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
