Skip to main content
POST
/
v3
/
memories
/
search
/
cURL
curl -X POST https://api.mem0.ai/v3/memories/search/ \
  -H "Authorization: Token <api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "where does the user live?",
    "filters": {"user_id": "alice"},
    "top_k": 10
  }'
from mem0 import MemoryClient

client = MemoryClient(api_key="your-api-key")

results = client.search(
"where does the user live?",
filters={"user_id": "alice"},
top_k=10,
)
for r in results["results"]:
print(r["memory"], r["score"])
import MemoryClient from "mem0ai";

const client = new MemoryClient({ apiKey: "your-api-key" });

const results = await client.search("where does the user live?", {
filters: { userId: "alice" },
topK: 10,
});
for (const r of results.results) {
console.log(r.memory, r.score);
}
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mem0.ai/v3/memories/search/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => 'where does the user live?',
'filters' => [
'user_id' => 'alice'
],
'top_k' => 10
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.mem0.ai/v3/memories/search/"

payload := strings.NewReader("{\n \"query\": \"where does the user live?\",\n \"filters\": {\n \"user_id\": \"alice\"\n },\n \"top_k\": 10\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.mem0.ai/v3/memories/search/")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"where does the user live?\",\n \"filters\": {\n \"user_id\": \"alice\"\n },\n \"top_k\": 10\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.mem0.ai/v3/memories/search/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"where does the user live?\",\n \"filters\": {\n \"user_id\": \"alice\"\n },\n \"top_k\": 10\n}"

response = http.request(request)
puts response.read_body
{
  "results": [
    {
      "id": "mem-uuid",
      "memory": "User moved to San Francisco from New York in January 2026",
      "score": 0.82,
      "metadata": {},
      "categories": [
        "location"
      ],
      "created_at": "2026-01-15T10:30:00Z",
      "updated_at": "2026-01-15T10:30:00Z"
    }
  ]
}
Relevance-ranked hybrid search across stored memories. V3 uses multi-signal retrieval: semantic, BM25 keyword, and entity matching scored in parallel and fused. The returned score is a combined [0, 1] value. Entity IDs (user_id, agent_id, app_id, run_id) must be passed inside the filters object: top-level entity IDs are rejected with 400. At least one entity ID is required. Expired memories are hidden by default. Pass show_expired: true to include memories whose expiration_date has passed. Python uses show_expired; TypeScript uses showExpired. The filters object supports complex logical operations (AND, OR, NOT) and comparison operators:
  • in: Matches any of the values specified
  • gte: Greater than or equal to
  • lte: Less than or equal to
  • gt: Greater than
  • lt: Less than
  • ne: Not equal to
  • icontains: Case-insensitive containment check
  • *: Wildcard character that matches everything

Search parameter defaults

ParameterDefault
top_k10 (range 1–1000)
threshold0.1 (pass 0.0 to disable)
rerankfalse (pass true to enable)
related_memories = client.search(
    query="What are Alice's hobbies?",
    show_expired=False,
    filters={
        "OR": [
            {
              "user_id": "alice"
            },
            {
              "agent_id": {"in": ["travel-agent", "sports-agent"]}
            }
        ]
    },
)
{
  "results": [
    {
      "id": "ea925981-272f-40dd-b576-be64e4871429",
      "memory": "Likes to play cricket and plays cricket on weekends.",
      "user_id": "alice",
      "metadata": {
        "category": "hobbies"
      },
      "score": 0.82,
      "expiration_date": null,
      "created_at": "2024-07-26T10:29:36.630547-07:00",
      "updated_at": null,
      "categories": ["hobbies"]
    }
  ]
}
# Using wildcard to match all run_ids for a specific user
all_memories = client.search(
    query="What are Alice's hobbies?",
    filters={
        "AND": [
            {
                "user_id": "alice"
            },
            {
                "run_id": "*"
            }
        ]
    },
)
# Example 1: Using 'contains' for partial matching
finance_memories = client.search(
    query="What are my financial goals?",
    filters={
        "AND": [
            { "user_id": "alice" },
            {
                "categories": {
                    "contains": "finance"
                }
            }
        ]
    },
)

# Example 2: Using 'in' for exact matching
personal_memories = client.search(
    query="What personal information do you have?",
    filters={
        "AND": [
            { "user_id": "alice" },
            {
                "categories": {
                    "in": ["personal_information"]
                }
            }
        ]
    },
)

Body

application/json
query
string
required

Natural-language search query.

Minimum string length: 1
filters
object
required

Entity and metadata filters. Must include at least one entity ID (user_id, agent_id, app_id, or run_id). Supports AND, OR, NOT, and comparison operators (in, gte, lte, gt, lt, contains, icontains, ne).

show_expired
boolean
default:false

When true, include memories whose expiration_date has passed. Expired memories are hidden by default.

top_k
integer
default:10

Number of results to return.

Required range: 1 <= x <= 1000
threshold
number
default:0.1

Minimum semantic relevance score. Pass 0.0 to disable filtering.

Required range: 0 <= x <= 1
rerank
boolean
default:false

Apply the managed reranker for better ordering (adds latency).

reference_date

Optional query anchor time for relative temporal interpretation. Accepts Unix epoch, YYYY-MM-DD, or ISO datetime.

Response

Ranked search results.

results
object[]
required