Files
Baradb/docs/ru/api-http.md
T

1.4 KiB

HTTP/REST API

JSON-based REST API для веб-приложений.

Base URL

http://localhost:9470/api

Endpoints

GET /api/users

Список всех пользователей:

curl http://localhost:9470/api/users

GET /api/users/:id

Получить пользователя по ID:

curl http://localhost:9470/api/users/1

POST /api/users

Создать пользователя:

curl -X POST http://localhost:9470/api/users \
  -H "Content-Type: application/json" \
  -d '{"name": "Charlie", "age": 35}'

PUT /api/users/:id

Обновить пользователя:

curl -X PUT http://localhost:9470/api/users/1 \
  -H "Content-Type: application/json" \
  -d '{"name": "Alice", "age": 31}'

DELETE /api/users/:id

Удалить пользователя:

curl -X DELETE http://localhost:9470/api/users/1

Query Endpoint

Выполнение BaraQL запросов через HTTP:

curl -X POST http://localhost:9470/api/query \
  -H "Content-Type: application/json" \
  -d '{"sql": "SELECT * FROM users WHERE age > 18"}'

Ответ об ошибке

{
  "error": {
    "code": "INVALID_QUERY",
    "message": "Syntax error at line 1"
  }
}

Аутентификация

curl -H "Authorization: Bearer <token>" \
  http://localhost:9470/api/users