The API module provides a complete REST API specification for Semantic Dropdown Search, enabling HTTP-based access to indexing, querying, and schema operations.
-
api/openapi.yaml- Complete OpenAPI 3.0 specification- 11 endpoints across 5 categories
- Comprehensive schemas and examples
- Request/response documentation
- Error handling specifications
-
api/examples/index_request.json- Index operation examples- 10 diverse indexing scenarios
- From minimal to complex requests
- Validation tips and notes
-
api/examples/search_request.json- Search operation examples- 20 search patterns
- Simple to complex queries
- Query pattern templates
-
api/README.md- API documentation- Quick start guide
- Endpoint reference
- Usage examples
- Best practices
| Method | Endpoint | Description |
|---|---|---|
| POST | /index |
Add text to index |
| GET | /index |
List indexed items (paginated) |
| GET | /index/{id} |
Get specific item |
| PUT | /index/{id} |
Update item |
| DELETE | /index/{id} |
Delete item |
| Method | Endpoint | Description |
|---|---|---|
| POST | /search |
Execute search query |
| POST | /search/explain |
Explain query without executing |
| Method | Endpoint | Description |
|---|---|---|
| POST | /validate |
Validate descriptor |
| GET | /schema |
Get schema info |
| GET | /schema/{field} |
Get field-specific schema |
| Method | Endpoint | Description |
|---|---|---|
| GET | /export |
Export index (JSON/NDJSON/CSV) |
| POST | /import |
Import items bulk |
| Method | Endpoint | Description |
|---|---|---|
| GET | /stats |
Get index statistics |
Total: 13 endpoints
- Standard HTTP methods (GET, POST, PUT, DELETE)
- Resource-based URLs
- Proper status codes
- JSON request/response bodies
- Machine-readable API definition
- Auto-generate client SDKs
- Interactive documentation (Swagger UI)
- Type-safe contracts
- 10 index request examples
- 20 search request examples
- Common query patterns
- Edge cases covered
{
"filters": {
"domain": "Science → Biology",
"domain_exact": false,
"intent": "Research",
"intent_exact": false,
"stability": "Peer-reviewed"
},
"text_search": "CRISPR",
"metadata": {"author": "Dr. Smith"},
"created_after": "2024-01-01T00:00:00Z",
"sort_by": "created",
"sort_order": "desc",
"limit": 20,
"offset": 0
}- Query explanations (
/search/explain) - Human-readable query descriptions in responses
- Field distribution statistics
- Validation with helpful errors
Request:
POST /api/v1/index
Content-Type: application/json
{
"text": "Novel findings in systems biology...",
"descriptor": {
"domain": "Science → Biology → Systems Biology",
"intent": "Research → Conceptual → Early-stage",
"tone": "Analytical / Cautious",
"audience": "Researchers",
"stability": "Hypothesis (Not yet validated)"
},
"metadata": {
"author": "Dr. Smith",
"tags": ["systems biology", "hypothesis"]
}
}Response (201 Created):
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"text": "Novel findings in systems biology...",
"descriptor": {...},
"metadata": {...},
"created_at": "2024-01-18T10:30:00Z",
"updated_at": "2024-01-18T10:30:00Z",
"content_hash": "abc123..."
}Request:
POST /api/v1/search
Content-Type: application/json
{
"filters": {
"domain": "Science → Biology",
"domain_exact": false,
"intent": "Research",
"intent_exact": false,
"stability": "Peer-reviewed"
},
"limit": 20
}Response (200 OK):
{
"items": [...],
"total": 42,
"query_explanation": "SELECT items WHERE (domain under 'Science → Biology' AND intent under 'Research' AND stability = 'Peer-reviewed')",
"limit": 20,
"offset": 0,
"statistics": {
"field_distribution": {...}
}
}Request:
POST /api/v1/validate
Content-Type: application/json
{
"domain": "Fake Domain",
"intent": "Research"
}Response (200 OK):
{
"valid": false,
"errors": [
"The value 'Fake Domain' is not allowed for field 'domain'. Did you mean one of these?\n • Science\n • Engineering\n • Philosophy"
],
"warnings": []
}Request:
GET /api/v1/schemaResponse (200 OK):
{
"version": "v1",
"fields": {
"domain": {
"required": true,
"description": "Subject domain or field",
"type": "hierarchical"
},
"intent": {
"required": true,
"description": "Purpose or intent",
"type": "hierarchical"
},
...
}
}- Full CRUD operations on indexed items
- Complex query building via search endpoint
- Descriptor validation
- Schema introspection
- Bulk import/export
- Statistics and analytics
- Hierarchical field matching
- Exact vs. prefix matching
- Full-text search
- Metadata filtering
- Date range filtering
- Sorting (created, updated, relevance)
- Pagination (limit/offset)
- Query explanation
- OpenAPI 3.0 specification
- Comprehensive examples
- Clear error messages
- Validation hints
- Auto-generated documentation
- Type-safe contracts
Single Item (200/201):
{
"id": "...",
"text": "...",
"descriptor": {...},
"metadata": {...},
"created_at": "...",
"updated_at": "...",
"content_hash": "..."
}List (200):
{
"items": [...],
"total": 100,
"limit": 20,
"offset": 0
}Search Results (200):
{
"items": [...],
"total": 42,
"query_explanation": "...",
"limit": 20,
"offset": 0,
"statistics": {...}
}Bad Request (400):
{
"error": "Invalid request",
"details": "Missing required field: text"
}Not Found (404):
{
"error": "Item not found",
"details": "No item with id: abc123"
}Validation Error (422):
{
"error": "Validation failed",
"details": {
"valid": false,
"errors": ["Invalid domain value"],
"warnings": []
}
}{
"filters": {
"domain": "Science → Biology",
"domain_exact": false,
"intent": "Research",
"intent_exact": false
}
}{
"filters": {
"stability": "Peer-reviewed"
}
}{
"filters": {
"intent": "Documentation → Tutorial",
"audience": "Beginners"
}
}{
"filters": {
"stability": "Hypothesis (Not yet validated)",
"intent": "Research → Conceptual → Early-stage",
"tone": "Analytical / Cautious"
}
}{
"text_search": "machine learning",
"filters": {
"domain": "Science → Computer Science",
"domain_exact": false
}
}{
"metadata": {
"author": "Dr. Smith"
}
}{
"created_after": "2024-01-01T00:00:00Z",
"sort_by": "created",
"sort_order": "desc"
}- Validates descriptors using core validation
- Returns validation errors with explanations
- Leverages semantic field structure
- Maps to IndexedText operations
- Supports all serialization formats
- Uses IndexManager for persistence
- Translates REST queries to QueryBuilder
- Returns query explanations
- Provides result statistics
OpenAPI spec enables auto-generation of:
- Python SDK
- JavaScript/TypeScript SDK
- Java/Kotlin SDK
- Go SDK
- Any language with OpenAPI tooling
GET /export?format={format}
| Format | Content-Type | Use Case |
|---|---|---|
| JSON | application/json |
General purpose, human-readable |
| NDJSON | application/x-ndjson |
Streaming, line-by-line processing |
| CSV | text/csv |
Spreadsheet analysis, Excel |
- OpenAPI 3.0 spec
- Request/response schemas
- Example requests
- Documentation
- Flask/FastAPI server
- Request validation
- Response formatting
- Error handling
- Storage integration
- Python client
- JavaScript/TypeScript client
- CLI tool
- Testing utilities
- Authentication (API keys, OAuth)
- Rate limiting
- Caching
- Monitoring
- Logging
- OpenAPI 3.0 compliant
- 13 well-designed endpoints
- Comprehensive examples (30+)
- RESTful conventions
- Proper status codes
- Clear error messages
- Explainability built-in
- Auto-documentable
- Client SDK ready
- Production considerations
- No tracking or profiling
- Transparent operations
- Open specification
- Semantic-based querying
- No hidden ranking algorithms
- Explainable results
- Simple, RESTful design
- Obvious endpoint purposes
- Clear request/response formats
- Helpful error messages
- Query explanations
- Validation hints
- Comprehensive examples
POST /search
{
"filters": {
"domain": "Science",
"intent": "Research",
"stability": "Peer-reviewed"
}
}POST /search
{
"filters": {
"intent": "Discussion → Question",
"audience": "Developers"
},
"text_search": "Python memory optimization"
}POST /search
{
"filters": {
"intent": "Documentation",
"stability": "Stable"
}
}POST /search
{
"filters": {
"domain": "Science → Computer Science → Artificial Intelligence"
},
"sort_by": "created",
"limit": 50
}- Swagger Editor: https://editor.swagger.io
- Redoc: https://redocly.github.io/redoc/
- Postman: Import OpenAPI spec
- Insomnia: Import OpenAPI spec
# View spec
cat api/openapi.yaml
# Validate spec
swagger-cli validate api/openapi.yaml
# Generate docs
redoc-cli bundle api/openapi.yamlStatus: API specification complete
Dependencies: Core, Indexer, Query modules
Ready for: Implementation, client generation, production deployment