POST
/
v2
/
memories
# To use the Python SDK, install the package:
# pip install mem0ai

from mem0 import MemoryClient
client = MemoryClient(api_key="your_api_key", org_id="your_org_id", project_id="your_project_id")

# Retrieve memories with filters
memories = client.get_all(
    filters={
        "AND": [
            {
                "user_id": "alex"
            },
            {
                "created_at": {
                    "gte": "2024-07-01",
                    "lte": "2024-07-31"
                }
            }
        ]
    },
    version="v2"
)

print(memories)
[
  {
    "id": "<string>",
    "name": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z",
    "owner": "<string>",
    "immutable": false,
    "expiration_date": null,
    "organization": "<string>",
    "metadata": {}
  }
]

The v2 get memories API is powerful and flexible, allowing for more precise memory listing without the need for a search query. It supports complex logical operations (AND, OR) and comparison operators for advanced filtering capabilities. The comparison operators include:

  • 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
memories = m.get_all(
    filters={
        "AND": [
            {
                "user_id": "alex"
            },
            {
                "created_at": {"gte": "2024-07-01", "lte": "2024-07-31"}
            }
        ]
    },
    version="v2"
)

Authorizations

Authorization
string
header
required

API key authentication. Prefix your Mem0 API key with 'Token '. Example: 'Token your_api_key'

Query Parameters

filters
object

Filters to apply to the memories. Available fields are: user_id, agent_id, app_id, run_id, created_at, updated_at, categories, keywords. Supports logical operators (AND, OR) and comparison operators (in, gte, lte, gt, lt, ne, contains, icontains)

fields
string[]

A list of field names to include in the response. If not provided, all fields will be returned.

org_id
string

Filter memories by organization ID.

project_id
string

Filter memories by project ID.

page
integer

Page number for pagination. Default: 1

page_size
integer

Number of items per page. Default: 100

Response

200
application/json
id
string
required
name
string
required
created_at
string
required
updated_at
string
required
owner
string
required
organization
string
required
immutable
boolean
default:false

Whether the memory is immutable.

expiration_date
string | null

The date and time when the memory will expire. Format: YYYY-MM-DD

metadata
object