const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
q: 'machine learning concepts',
containerTag: 'user_123',
threshold: 0.5,
filters: {OR: ['<unknown>']},
include: {
documents: false,
summaries: false,
relatedMemories: false,
forgottenMemories: false,
chunks: false
},
limit: 10,
rerank: false,
rewriteQuery: false
})
};
fetch('https://api.supermemory.ai/v4/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"results": [
{
"id": "mem_abc123",
"memory": "John prefers machine learning over traditional programming",
"metadata": {
"source": "conversation",
"confidence": 0.9
},
"updatedAt": "<string>",
"similarity": 0.89,
"version": 3,
"context": {
"parents": [
{
"relation": "updates",
"memory": "Earlier version: Dhravya is working on a patent at Cloudflare.",
"updatedAt": "<string>",
"version": -1,
"metadata": {}
}
],
"children": [
{
"relation": "extends",
"memory": "Later version: Dhravya has filed the patent successfully.",
"updatedAt": "<string>",
"version": 1,
"metadata": {}
}
]
},
"documents": [
{
"id": "doc_xyz789",
"createdAt": "<string>",
"updatedAt": "<string>",
"title": "Introduction to Machine Learning",
"type": "web",
"metadata": {
"category": "technology",
"isPublic": true,
"readingTime": 5,
"source": "web",
"tag_1": "ai",
"tag_2": "machine-learning"
},
"summary": "A comprehensive guide to understanding the basics of machine learning and its applications."
}
],
"chunks": [
{
"content": "This is a chunk of content from the document...",
"score": 0.85,
"position": 0,
"documentId": "doc_xyz789"
}
]
}
],
"timing": 245,
"total": 5
}Search memory entries - Low latency for conversational
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
q: 'machine learning concepts',
containerTag: 'user_123',
threshold: 0.5,
filters: {OR: ['<unknown>']},
include: {
documents: false,
summaries: false,
relatedMemories: false,
forgottenMemories: false,
chunks: false
},
limit: 10,
rerank: false,
rewriteQuery: false
})
};
fetch('https://api.supermemory.ai/v4/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"results": [
{
"id": "mem_abc123",
"memory": "John prefers machine learning over traditional programming",
"metadata": {
"source": "conversation",
"confidence": 0.9
},
"updatedAt": "<string>",
"similarity": 0.89,
"version": 3,
"context": {
"parents": [
{
"relation": "updates",
"memory": "Earlier version: Dhravya is working on a patent at Cloudflare.",
"updatedAt": "<string>",
"version": -1,
"metadata": {}
}
],
"children": [
{
"relation": "extends",
"memory": "Later version: Dhravya has filed the patent successfully.",
"updatedAt": "<string>",
"version": 1,
"metadata": {}
}
]
},
"documents": [
{
"id": "doc_xyz789",
"createdAt": "<string>",
"updatedAt": "<string>",
"title": "Introduction to Machine Learning",
"type": "web",
"metadata": {
"category": "technology",
"isPublic": true,
"readingTime": 5,
"source": "web",
"tag_1": "ai",
"tag_2": "machine-learning"
},
"summary": "A comprehensive guide to understanding the basics of machine learning and its applications."
}
],
"chunks": [
{
"content": "This is a chunk of content from the document...",
"score": 0.85,
"position": 0,
"documentId": "doc_xyz789"
}
]
}
],
"timing": 245,
"total": 5
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Search query string
1"machine learning concepts"
Optional tag this search should be containerized by. This can be an ID for your user, a project ID, or any other identifier you wish to use to filter memories.
"user_123"
Threshold / sensitivity for memories selection. 0 is least sensitive (returns most memories, more results), 1 is most sensitive (returns lesser memories, accurate results)
0 <= x <= 10.5
Show child attributes
If true, include forgotten memories in search results. Forgotten memories are memories that have been explicitly forgotten or have passed their expiration date.
false
If true, fetch and return chunks from documents associated with the found memories. Performs vector search on chunks within those documents.
false
Maximum number of results to return
1 < x <= 10010
If true, rerank the results based on the query. This is helpful if you want to ensure the most relevant results are returned.
false
If true, rewrites the query to make it easier to find documents. This increases the latency by about 400ms
false
Memory search results
Array of matching memory entries with similarity scores
Show child attributes
Memory entry ID
"mem_abc123"
The memory content
"John prefers machine learning over traditional programming"
Memory last update date
Similarity score between the query and memory entry
0 <= x <= 10.89
Version number of this memory entry
3
Object containing arrays of parent and child contextual memories
Show child attributes
Show child attributes
Relation type between this memory and its parent/child
updates, extends, derives "updates"
The contextual memory content
"Earlier version: Dhravya is working on a patent at Cloudflare."
Contextual memory last update date
Relative version distance from the primary memory (-1 for direct parent, -2 for grand-parent, etc.)
-1
Show child attributes
Relation type between this memory and its parent/child
updates, extends, derives "extends"
The contextual memory content
"Later version: Dhravya has filed the patent successfully."
Contextual memory last update date
Relative version distance from the primary memory (+1 for direct child, +2 for grand-child, etc.)
1
Associated documents for this memory entry
Show child attributes
Document ID
"doc_xyz789"
Document creation date
Document last update date
Document title (only included when documents=true)
"Introduction to Machine Learning"
Document type (only included when documents=true)
"web"
Document summary (only included when summaries=true)
"A comprehensive guide to understanding the basics of machine learning and its applications."
Relevant chunks from associated documents (only included when chunks=true)
Show child attributes
Content of the chunk
"This is a chunk of content from the document..."
Similarity score between the query and chunk
0 <= x <= 10.85
Position of chunk in the document (0-indexed)
0
ID of the document this chunk belongs to
"doc_xyz789"
Search execution time in milliseconds
245
Total number of results returned
5
Was this page helpful?