Skip to content

Database API

All routes require JWT via Authorization: Bearer <token>.

Read Table

  • Endpoint: /api/{{ API_VERSION }}/database/read/
  • Function: Retrieve all rows from a table.
  • Method: GET
  • Shell Command:
curl -L "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/read/?tablename=users" \
  -H "Authorization: Bearer <token>"
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/read/"
headers = {"Authorization": "Bearer <token>"}
params = {"tablename": "users"}
resp = requests.get(url, params=params, headers=headers)
print(resp.json())

Read Item

  • Endpoint: /api/{{ API_VERSION }}/database/read_item/
  • Function: Retrieve one row by ID.
  • Method: GET
  • Shell Command:
curl -L "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/read_item/?data=%7B%22tablename%22%3A%22users%22%2C%22item%22%3A%7B%22id%22%3A42%7D%7D" \
  -H "Authorization: Bearer <token>"
  • Python Command:
import requests, json

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/read_item/"
headers = {"Authorization": "Bearer <token>"}
payload = {"tablename": "users", "item": {"id": 42}}
resp = requests.get(url, params={"data": json.dumps(payload)}, headers=headers)
print(resp.json())

Add Item

  • Endpoint: /api/{{ API_VERSION }}/database/add_item/
  • Function: Add a new row.
  • Method: POST
  • Shell Command:
curl -X POST "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/add_item/" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"tablename":"users","item":{"name":"Alice","age":30}}'
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/add_item/"
headers = {"Authorization": "Bearer <token>"}
data = {"tablename":"users","item":{"name":"Alice","age":30}}
resp = requests.post(url, json=data, headers=headers)
print(resp.json())

Delete Item

  • Endpoint: /api/{{ API_VERSION }}/database/delete_item/
  • Function: Remove a row by ID.
  • Method: DELETE
  • Shell Command:
curl -X DELETE "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/delete_item/" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"tablename":"users","item":{"id":42}}'
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/delete_item/"
headers = {"Authorization": "Bearer <token>"}
data = {"tablename":"users","item":{"id":42}}
resp = requests.delete(url, json=data, headers=headers)
print(resp.json())

Update Item

  • Endpoint: /api/{{ API_VERSION }}/database/update_item/
  • Function: Update one column on a row.
  • Method: PUT
  • Shell Command:
curl -X PUT "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/update_item/" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"tablename":"users","item":{"id":42},"attribute":"age","new_value":31}'
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/update_item/"
headers = {"Authorization": "Bearer <token>"}
data = {"tablename":"users","item":{"id":42},"attribute":"age","new_value":31}
resp = requests.put(url, json=data, headers=headers)
print(resp.json())

Clear Table

  • Endpoint: /api/{{ API_VERSION }}/database/clear_table/
  • Function: Delete all rows in a table.
  • Method: DELETE
  • Shell Command:
curl -X DELETE "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/clear_table/?tablename=users" \
  -H "Authorization: Bearer <token>"
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/clear_table/"
headers = {"Authorization": "Bearer <token>"}
params = {"tablename":"users"}
resp = requests.delete(url, params=params, headers=headers)
print(resp.json())

Update Controller Config

  • Endpoint: /api/{{ API_VERSION }}/database/update_controller_config/
  • Function: Update a controller config entry.
  • Method: PUT
  • Shell Command:
curl -X PUT "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/update_controller_config/" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"id":1,"name":"ctrl1","prompt_name":"base","config":{"foo":"bar"}}'
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/update_controller_config/"
headers = {"Authorization": "Bearer <token>"}
data = {"id":1,"name":"ctrl1","prompt_name":"base","config":{"foo":"bar"}}
resp = requests.put(url, json=data, headers=headers)
print(resp.json())

Clear All Data

  • Endpoint: /api/{{ API_VERSION }}/clear_database
  • Function: Remove all data from every table.
  • Method: GET
  • Shell Command:
curl -L "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/clear_database" \
  -H "Authorization: Bearer <token>"
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/clear_database"
headers = {"Authorization": "Bearer <token>"}
resp = requests.get(url, headers=headers)
print(resp.json())

Export Table

  • Endpoint: /api/{{ API_VERSION }}/database/export_table/
  • Function: Dump a table to a CSV file.
  • Method: POST
  • Shell Command:
curl -X POST "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/export_table/" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"path":"/tmp/users.csv","tablename":"users"}'
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/export_table/"
headers = {"Authorization": "Bearer <token>"}
data = {"path":"/tmp/users.csv","tablename":"users"}
resp = requests.post(url, json=data, headers=headers)
print(resp.json())

Import Table

  • Endpoint: /api/{{ API_VERSION }}/database/import_table/
  • Function: Load a CSV into a table.
  • Method: POST
  • Shell Command:
curl -X POST "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/import_table/" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"path":"/tmp/users.csv","tablename":"users"}'
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/import_table/"
headers = {"Authorization": "Bearer <token>"}
data = {"path":"/tmp/users.csv","tablename":"users"}
resp = requests.post(url, json=data, headers=headers)
print(resp.json())

Get DB Connection URL

  • Endpoint: /api/{{ API_VERSION }}/database/get_path/
  • Function: Return the DB connection URL.
  • Method: GET
  • Shell Command:
curl -L "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/get_path/" \
  -H "Authorization: Bearer <token>"
  • Python Command:
import requests

url = "https://<ROBOT_IP>/rest/api/{{ API_VERSION }}/database/get_path/"
headers = {"Authorization": "Bearer <token>"}
resp = requests.get(url, headers=headers)
print(resp.json())