---
title: Get Memories
desc: Paginated query or full export of the memory collection within a specified Cube, with support for type-based filtering and subgraph extraction.
---

**Endpoint**:
* **Paginated Query**: `POST /product/get_memory`
* **Full Export**: `POST /product/get_all`

**Description**: Used to list or export memory assets from a specified **MemCube**. Through these two interfaces, you can retrieve raw memory fragments, user preferences, or tool usage records generated by the system, with support for paginated display and structured export.

## 1. Core Mechanism: Paginated vs. Full Export

In the open-source version, the system provides two different collection access modes via **MemoryHandler**:

* **Paginated Business Mode (`/get_memory`)**:
    * **Design Intent**: Designed for frontend UI lists. Supports `page` and `page_size` parameters.
    * **Features**: Includes preference memories by default (`include_preference`), supports lightweight data loading.
* **Full Export Mode (`/get_all`)**:
    * **Design Intent**: Designed for data migration or complex relationship analysis.
    * **Core Capability**: Supports passing a `search_query` to extract relevant **subgraphs**, or exporting all data by `memory_type` (text/action/parameter).


## 2. Key Parameters

### 2.1 Paginated Query Parameters (`/get_memory`)

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **`mem_cube_id`** | `str` | Yes | Target MemCube ID. |
| **`user_id`** | `str` | No | Unique user identifier. |
| **`page`** | `int` | No | Page number (starting from 1). If set to `None`, attempts a full export. |
| **`page_size`** | `int` | No | Number of entries per page. |
| `include_preference` | `bool` | No | Whether to include preference memories. |

### 2.2 Full/Subgraph Export Parameters (`/get_all`)

| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **`user_id`** | `str` | Yes | User ID. |
| **`memory_type`** | `str` | Yes | Memory type: `text_mem`, `act_mem`, `para_mem`. |
| `mem_cube_ids` | `list` | No | List of Cube IDs to export. |
| `search_query` | `str` | No | If provided, recalls and returns the relevant memory subgraph based on this query. |

## 3. Quick Start

### 3.1 Frontend Paginated Display (SDK Call)

```python
# Retrieve the first page with 10 memories per page
res = client.get_memory(
    user_id="sde_dev_01",
    mem_cube_id="cube_research_01",
    page=1,
    page_size=10
)

for mem in res.data:
    print(f"[{mem['type']}] {mem['memory_value']}")
```
### 3.2 Export a Specific Factual Memory Subgraph
```python
# Extract all factual memories related to "R language"
res = client.get_all(
    user_id="sde_dev_01",
    memory_type="text_mem",
    search_query="R language visualization"
)
```

## 4. Response Structure

The interface returns a standard business response, where `data` contains an array of memory objects. Each memory typically contains the following core fields:

`id`: The unique memory identifier, used for **Get Detail** or **Delete** operations.

`memory_value`: The memory text after algorithmic processing.

`tags`: Associated custom tags.

::note
Developer Tip: If you already know the memory ID and want to view its complete metadata (such as `confidence` or `usage` records), use the **Get Memory Detail** (`Get_memory_by_id`) interface. :::
