Docs: Update v2 GET ALL endpoint (#2267)
This commit is contained in:
@@ -1091,6 +1091,7 @@
|
|||||||
"created_at": {"type": "string", "format": "date-time"},
|
"created_at": {"type": "string", "format": "date-time"},
|
||||||
"updated_at": {"type": "string", "format": "date-time"},
|
"updated_at": {"type": "string", "format": "date-time"},
|
||||||
"categories": {"type": "array", "items": {"type": "string"}},
|
"categories": {"type": "array", "items": {"type": "string"}},
|
||||||
|
"metadata": {"type": "object"},
|
||||||
"keywords": {"type": "string"}
|
"keywords": {"type": "string"}
|
||||||
},
|
},
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
|
|||||||
@@ -1183,7 +1183,7 @@ Our advanced retrieval allows you to set custom filters when fetching memories.
|
|||||||
|
|
||||||
Here you need to define `version` as `v2` in the get_all method.
|
Here you need to define `version` as `v2` in the get_all method.
|
||||||
|
|
||||||
Example: Get all memories using user_id and date filters
|
Example 1. Get all memories using user_id and date filters
|
||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
|
|
||||||
@@ -1336,6 +1336,124 @@ curl -X GET "https://api.mem0.ai/v1/memories/?version=v2&page=1&page_size=50" \
|
|||||||
|
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
|
Example 2: Search using metadata and categories Filters
|
||||||
|
<CodeGroup>
|
||||||
|
```python Python
|
||||||
|
filters = {
|
||||||
|
"AND": [
|
||||||
|
{"metadata": {"food": "vegan"}},
|
||||||
|
{
|
||||||
|
"categories":{
|
||||||
|
"contains": "food_preferences"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
# Default (No Pagination)
|
||||||
|
client.get_all(version="v2", filters=filters)
|
||||||
|
|
||||||
|
# Pagination (You can also use the page and page_size parameters)
|
||||||
|
client.get_all(version="v2", filters=filters, page=1, page_size=50)
|
||||||
|
```
|
||||||
|
|
||||||
|
```javascript JavaScript
|
||||||
|
const filters = {
|
||||||
|
"AND": [
|
||||||
|
{"metadata": {"food": "vegan"}},
|
||||||
|
{
|
||||||
|
"categories": {
|
||||||
|
"contains": "food_preferences"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
// Default (No Pagination)
|
||||||
|
client.getAll({ version: "v2", filters })
|
||||||
|
.then(memories => console.log(memories))
|
||||||
|
.catch(error => console.error(error));
|
||||||
|
|
||||||
|
// Pagination (You can also use the page and page_size parameters)
|
||||||
|
client.getAll({ version: "v2", filters, page: 1, page_size: 50 })
|
||||||
|
.then(memories => console.log(memories))
|
||||||
|
.catch(error => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash cURL
|
||||||
|
# Default (No Pagination)
|
||||||
|
curl -X GET "https://api.mem0.ai/v1/memories/?version=v2" \
|
||||||
|
-H "Authorization: Token your-api-key" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"filters": {
|
||||||
|
"AND": [
|
||||||
|
{"metadata": {"food": "vegan"}},
|
||||||
|
{
|
||||||
|
"categories": {
|
||||||
|
"contains": "food_preferences"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
|
||||||
|
# Pagination (You can also use the page and page_size parameters)
|
||||||
|
curl -X GET "https://api.mem0.ai/v1/memories/?version=v2&page=1&page_size=50" \
|
||||||
|
-H "Authorization: Token your-api-key" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"filters": {
|
||||||
|
"AND": [
|
||||||
|
{"metadata": {"food": "vegan"}},
|
||||||
|
{
|
||||||
|
"categories": {
|
||||||
|
"contains": "food_preferences"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
```json Output (Default)
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id":"f38b689d-6b24-45b7-bced-17fbb4d8bac7",
|
||||||
|
"memory":"Name: Alex. Vegetarian. Allergic to nuts.",
|
||||||
|
"user_id":"alex",
|
||||||
|
"hash":"62bc074f56d1f909f1b4c2b639f56f6a",
|
||||||
|
"metadata":{"food":"vegan"},
|
||||||
|
"immutable": false,
|
||||||
|
"created_at":"2024-07-25T23:57:00.108347-07:00",
|
||||||
|
"updated_at":"2024-07-25T23:57:00.108367-07:00",
|
||||||
|
"categories": ["food_preferences"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
```json Output (Paginated)
|
||||||
|
{
|
||||||
|
"count": 1,
|
||||||
|
"next": null,
|
||||||
|
"previous": null,
|
||||||
|
"results": [
|
||||||
|
{
|
||||||
|
"id":"f38b689d-6b24-45b7-bced-17fbb4d8bac7",
|
||||||
|
"memory":"Name: Alex. Vegetarian. Allergic to nuts.",
|
||||||
|
"user_id":"alex",
|
||||||
|
"hash":"62bc074f56d1f909f1b4c2b639f56f6a",
|
||||||
|
"metadata":{"food":"vegan"},
|
||||||
|
"immutable": false,
|
||||||
|
"created_at":"2024-07-25T23:57:00.108347-07:00",
|
||||||
|
"updated_at":"2024-07-25T23:57:00.108367-07:00",
|
||||||
|
"categories": ["food_preferences"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</CodeGroup>
|
||||||
|
|
||||||
### 4.5 Memory History
|
### 4.5 Memory History
|
||||||
|
|
||||||
Get history of how a memory has changed over time.
|
Get history of how a memory has changed over time.
|
||||||
|
|||||||
Reference in New Issue
Block a user