# TreeVoyager API

## Introduction

TreeVoyager is a Python-based protocol designed to implement some principles from the papers '[Tree of Thoughts](https://arxiv.org/abs/2305.10601)' (ToT) and '[Minecraft's Voyager](https://voyager.minedojo.org/)' to parse, generate curriculum, select HTML IDs, generate paths, and create skills (memory) for the steps required in the agent trajectory.

We developed TreeVoyager to address the lack of a standardized protocol that allows AI agents to interact with the web. This is just one way of many to mitigate the problem. TreeVoyager aims to solve this issue while also incorporating proven concepts from other agent environments (such as Minecraft's Voyager).

This API serves the TreeVoyager API service, which provides endpoints for running tasks and sequences of actions in a web environment.

**TreeVoyager Functionality Diagram:**

<figure><img src="/files/LhgAWfuwUqTphBWu5Ccc" alt="" width="375"><figcaption></figcaption></figure>

**Inside TreeVoyager:**

<figure><img src="/files/gIgHJQnEs3rcp7SrrPzs" alt=""><figcaption><p>TreeVoyager's Diagram</p></figcaption></figure>

## **How to use this TreeVoyager API?**

You can use the `/run_step` endpoint, and pass the parameters of each step:

```python
task, page, curriculum, prev_code, step
```

If it's the first time you run the step, just pass the "task" and "page" (URL) parameters and TreeVoyager will know it's the first time/step to run and it will create the curriculum and code for the first step.&#x20;

For subsequent steps, pass the "task", "page" (if it's the same URL as the first step, pass it, or if your agent already submitted to a new page, pass the new URL), the "prev\_code" (previous code) generated in the previous step and the "step" (from the curriculum) you want to execute.&#x20;

Note that you can edit the "step", it doesn't need to be the exact one from the curriculum.

## Endpoints:

**Version**: 0.9.0\
**Status**: Development\
**Root Endpoint**: `https://treevoyager.junglegym.ai/`

### TreeVoyager Endpoints

#### 1. Health Check and Welcome Message

* **URL**: `/`
* **Method**: GET
* **Rate Limit**: 500 requests per minute
* **Response**: Returns a welcome message.

```json
jsonCopy code{
    "message": "Hello from TreeVoyager's server. Check the full api documentation at: https://docs.junglegym.ai"
}
```

#### 2. Run a Task Step-by-Step

* **URL**: `/run_step`
* **Method**: GET
* **Rate Limit**: 500 requests per minute
* **Parameters**:
  * `task` (the task you want to accomplish, "buy coffee", "rent a car", etc)
  * `page` (the URL of the page)
  * `curriculum` (leave blank the first time you run it, for subsequent steps, pass the curriculum generated in the first step)
  * `prev_code` (leave blank the first time you run it, for subsequent steps pass the code generated in the first or previous step)
  * `step` (step name from the curriculum; edit step if needed)
* **Response**: Streams a sequence of JSON objects with step-by-step task execution details.

```json
jsonCopy code{
    "task": "buy coffee",
    "curriculum": {...},
    "step_name": "Step 1...",
    ...
}
```


---

# 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://docs.junglegym.ai/junglegym/api-documentation/treevoyager-api.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.
