# Accessing the EmeraldAPI Script

{% hint style="warning" %}
**Important:** It is expected that you have C# coding knowledge before proceeding.
{% endhint %}

While Emerald AI's API can be accessed per individual component, this method allows users to access all practical API through a single static class called EmeraldAPI. The only reference that is required is an AI’s EmeraldSystem component that's passed through the EmeraldAPI script and to its functions. It is recommended that you use the EmeraldAI namespace at the top of your scripts to make accessing the Emerald AI scripts easier using:

```csharp
using EmeraldAI;
```

When using the EmeraldAPI script, you can access all of an AI’s internal functions that allow you to control a wide variety of functionality. This is done through categorized classes.

It is recommended that the EmeraldSystem script is cached.

```csharp
EmeraldComponent = GetComponent<EmeraldSystem>();
```

For users who need a working example, please use the following script to get you started. This script will instantly kill the AI this script is assigned to after pressing the H key.

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EmeraldAI;

public class AccessEmeraldExample : MonoBehaviour
{
    EmeraldSystem EmeraldComponent;

    //Cache the EmeraldSystem component
    void Start ()
    {
        EmeraldComponent = GetComponent<EmeraldSystem>();
    }
    
    //Instantly kill the AI this script is assigned to after pressing the H key
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.H))
        {
            EmeraldAPI.Combat.KillAI(EmeraldComponent);
        }
    }
}
```

{% hint style="success" %}
Here's the available sections of API through the EmeraldAPI class.
{% endhint %}

### Table of Contents

* [Movement API](/emerald-ai-wiki/api/available-api/movement-api.md)
* [Combat API](/emerald-ai-wiki/api/available-api/combat-api.md)
* [Faction API](/emerald-ai-wiki/api/available-api/faction-api.md)
* [Sound API](/emerald-ai-wiki/api/available-api/sound-api.md)
* [Animation API](/emerald-ai-wiki/api/available-api/animation-api.md)
* [UI API](/emerald-ai-wiki/api/available-api/ui-api.md)
* [Behaviors API](/emerald-ai-wiki/api/available-api/behaviors-api.md)
* [Health API](/emerald-ai-wiki/api/available-api/health-api.md)
* [Items API](/emerald-ai-wiki/api/available-api/items-api.md)


---

# Agent Instructions: 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:

```
GET https://black-horizon-studios.gitbook.io/emerald-ai-wiki/api/accessing-the-emeraldapi-script.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
