API Reference
Query

Query

POST

/v1/query

Advanced query endpoint with support for complex filters, aggregations, and full-text search. Use this for programmatic access to your memories.

Request Body

ParameterTypeRequiredDescription
querystringNoSearch query text
filtersobjectNoComplex filter conditions
sortobjectNoSort configuration
limitnumberNoMax results (default: 20, max: 100)
offsetnumberNoPagination offset
fieldsstring[]NoFields to return
aggregateobjectNoAggregation settings

Filter Operators

OperatorDescriptionExample
$eqEquals{"tag": {"$eq": "important"}}
$neNot equals{"status": {"$ne": "archived"}}
$gtGreater than{"score": {"$gt": 0.8}}
$gteGreater than or equal{"score": {"$gte": 0.5}}
$ltLess than{"createdAt": {"$lt": "2024-01-01"}}
$lteLess than or equal{"createdAt": {"$lte": "2024-12-31"}}
$inIn array{"tag": {"$in": ["a", "b"]}}
$ninNot in array{"tag": {"$nin": ["spam"]}}
$andLogical AND{"$and": [{...}, {...}]}
$orLogical OR{"$or": [{...}, {...}]}

Examples

Basic Query

curl -X POST https://api.hypersave.io/v1/query \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "project updates",
    "limit": 10
  }'

Complex Filter Query

curl -X POST https://api.hypersave.io/v1/query \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filters": {
      "$and": [
        {"tags": {"$in": ["important", "urgent"]}},
        {"createdAt": {"$gte": "2024-01-01"}},
        {"metadata.status": {"$ne": "archived"}}
      ]
    },
    "sort": {"createdAt": -1},
    "limit": 20
  }'

Query with Field Selection

Return only specific fields to reduce response size:

curl -X POST https://api.hypersave.io/v1/query \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "meetings",
    "fields": ["id", "title", "createdAt"],
    "limit": 50
  }'

Query with Aggregation

Get statistics about your memories:

curl -X POST https://api.hypersave.io/v1/query \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "aggregate": {
      "countByTag": true,
      "dateHistogram": {
        "field": "createdAt",
        "interval": "week"
      }
    }
  }'

Response

Basic Response

{
  "success": true,
  "results": [
    {
      "id": "doc_abc123",
      "content": "Weekly project update: Completed milestone 3...",
      "title": "Project Update Week 4",
      "tags": ["project", "weekly-update"],
      "createdAt": "2024-01-28T10:00:00Z"
    }
  ],
  "pagination": {
    "limit": 10,
    "offset": 0,
    "total": 45,
    "hasMore": true
  }
}

Response with Aggregations

{
  "success": true,
  "results": [...],
  "aggregations": {
    "countByTag": {
      "project": 25,
      "meeting": 18,
      "research": 12
    },
    "dateHistogram": [
      {"date": "2024-01-01", "count": 15},
      {"date": "2024-01-08", "count": 22},
      {"date": "2024-01-15", "count": 18}
    ]
  },
  "pagination": {...}
}

Sorting

Sort results by any field:

{
  "sort": {
    "createdAt": -1  // -1 for descending, 1 for ascending
  }
}

Multiple sort fields:

{
  "sort": {
    "metadata.priority": -1,
    "createdAt": -1
  }
}

Default sort is by relevance score when a query is provided, otherwise by createdAt descending.

Error Responses

Invalid Filter

{
  "success": false,
  "error": "VALIDATION_ERROR",
  "message": "Invalid filter operator: $unknown"
}

Invalid Field

{
  "success": false,
  "error": "VALIDATION_ERROR",
  "message": "Unknown field in filters: invalidField"
}