Files
Baradb/docs/en/api-binary.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

74 lines
1.5 KiB
Markdown

# Binary Protocol API
Low-level wire protocol for high-performance client connections.
## Message Format
All messages use big-endian byte order:
```
┌────────┬────────┬────────┬────────┬─────────────┐
│ Length │ Type │ Seq │ Status │ Payload │
│ 4 bytes│ 1 byte │ 2 bytes│ 1 byte │ N bytes │
└────────┴────────┴────────┴────────┴─────────────┘
```
## Message Types
### Query (0x01)
```nim
let msg = makeQueryMessage(seq, "SELECT * FROM users")
```
### Insert (0x02)
```nim
let msg = makeInsertMessage(seq, "users", data)
```
### Update (0x03)
```nim
let msg = makeUpdateMessage(seq, "users", updates, where)
```
### Delete (0x04)
```nim
let msg = makeDeleteMessage(seq, "users", where)
```
### Ready (0x05)
```nim
let msg = makeReadyMessage(seq)
```
### Error (0x06)
```nim
let msg = makeErrorMessage(seq, code, message)
```
## Response Codes
| Code | Name | Description |
|------|------|-------------|
| 0x00 | OK | Success |
| 0x01 | ERROR | General error |
| 0x02 | AUTH_REQUIRED | Authentication needed |
| 0x03 | INVALID_QUERY | Query syntax error |
| 0x04 | NOT_FOUND | Resource not found |
## Serialization
```nim
import barabadb/protocol/wire
# Serialize value
let bytes = serializeValue(Value(kind: vkString, strVal: "test"))
# Deserialize value
let value = deserializeValue(bytes)
```