Files
Baradb/docs/en/api-http.md
T
dimgigov e1bae0c7a0 Add comprehensive documentation with i18n support (EN/BG)
- Add docs/ folder with English (en/) and Bulgarian (bg/) documentation
- Create index.md with language switching and links
- English docs: installation, quickstart, architecture, baraql, storage,
  schema, lsm, btree, vector, graph, fts, columnar, transactions,
  distributed, protocol, udf, api-binary, api-http, api-websocket
- Bulgarian docs: installation, quickstart, architecture, baraql,
  schema, lsm, btree, vector, graph, fts, transactions, distributed
- Update README license to BSD 3-Clause
- Add LICENSE file with BSD 3-Clause text
2026-05-06 16:51:14 +03:00

91 lines
1.3 KiB
Markdown

# HTTP/REST API
JSON-based REST API for web applications.
## Base URL
```
http://localhost:8080/api
```
## Endpoints
### GET /api/users
List all users:
```bash
curl http://localhost:8080/api/users
```
Response:
```json
[
{"id": 1, "name": "Alice", "age": 30},
{"id": 2, "name": "Bob", "age": 25}
]
```
### GET /api/users/:id
Get user by ID:
```bash
curl http://localhost:8080/api/users/1
```
### POST /api/users
Create user:
```bash
curl -X POST http://localhost:8080/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Charlie", "age": 35}'
```
### PUT /api/users/:id
Update user:
```bash
curl -X PUT http://localhost:8080/api/users/1 \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "age": 31}'
```
### DELETE /api/users/:id
Delete user:
```bash
curl -X DELETE http://localhost:8080/api/users/1
```
## Query Endpoint
Execute BaraQL queries via HTTP:
```bash
curl -X POST http://localhost:8080/api/query \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT * FROM users WHERE age > 18"}'
```
## Error Response
```json
{
"error": {
"code": "INVALID_QUERY",
"message": "Syntax error at line 1"
}
}
```
## Authentication
```bash
curl -H "Authorization: Bearer <token>" \
http://localhost:8080/api/users
```