# Flask APIs

## Introduction

{% hint style="info" %}
The Flask API will occupy the robot and block other processes. Make sure to stop the Flask process if you need to use the robot for other tasks.
{% endhint %}

This is the flask api and backend of the command center, to launch this, navigate to the directory and run the launch script:

```sh
launch-flask-api 
```

If successful, you should see something similiar to this:

```
---------------------------------------------
STARTING HACKERBOT FLASK API
---------------------------------------------

---------------------------------------------
SUCCESS! Hackerbot Web Application is Running!
Flask Backend:  http://localhost:5000
                http://10.1.10.110:5000
Log file: /home/bobby/hackerbot/logs/hackerbot_flask_202503251849.txt
---------------------------------------------
```

To stop the process, run the stop script:

```sh
stop-flask-api 
```

You should see something like this in your console:

```
---------------------------------------------
STOPPING HACKERBOT FLASK API
---------------------------------------------
Stopping Flask backend (PID: 101864)...
Force killing Flask backend...
Flask backend stopped.
---------------------------------------------
CHECKING SERIAL PORT /dev/ttyACM1
---------------------------------------------
Serial port /dev/ttyACM1 is not occupied.
---------------------------------------------
HACKERBOT FLASK API STOPPED
```

***

## API Reference

> This section provides a reference for all RESTful endpoints used to control the Hackerbot platform. These APIs are organized by module: `Core`, `Base`, `Head`, and `Arm`.

### 🧪 Quick Examples

#### Ping the Core

```sh
curl -X POST http://<host>/api/v1/core \
  -H "Content-Type: application/json" \
  -d '{"method": "ping"}'
```

#### Start the Base

```sh
curl -X POST http://<host>/api/v1/base \
  -H "Content-Type: application/json" \
  -d '{"method": "start"}'
```

#### Drive the Robot

```sh
curl -X POST http://<host>/api/v1/base/actions \
  -H "Content-Type: application/json" \
  -d '{"linear_velocity": 0.0, "angle_velocity": 65}'
```

**Navigation**

```sh
curl -X POST http://<host>/api/v1/base/maps \
  -H "Content-Type: application/json" \
  -d '{"method": "goto", "x": 0.0, "y": 0.0, "angle": 0.0, "speed":0.4}'
```

#### Make the Robot Speak

```sh
curl -X POST http://<host>/api/v1/base \
  -H "Content-Type: application/json" \
  -d '{"method": "speak", "model_src": "en_GB-semaine-medium", "text": "Tacos!", "speaker_id": null}'
```

**Move the head**

```sh
curl -X POST http://<host>/api/v1/head \
     -H "Content-Type: application/json" \
     -d '{"method": "look", "yaw":180.0, "pitch":180.0, "speed":90}'
```


---

# 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://hackerbot-industries.gitbook.io/documentation-hackerbot-industries/software/flask-apis.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.
