Skip to content

Commit

Permalink
Docs: Update v2 GET ALL endpoint (#2267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-Khant authored Feb 27, 2025
1 parent 48176bd commit 308e79b
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@
"created_at": {"type": "string", "format": "date-time"},
"updated_at": {"type": "string", "format": "date-time"},
"categories": {"type": "array", "items": {"type": "string"}},
"metadata": {"type": "object"},
"keywords": {"type": "string"}
},
"additionalProperties": {
Expand Down
120 changes: 119 additions & 1 deletion docs/platform/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Example: Get all memories using user_id and date filters
Example 1. Get all memories using user_id and date filters
<CodeGroup>
Expand Down Expand Up @@ -1336,6 +1336,124 @@ curl -X GET "https://api.mem0.ai/v1/memories/?version=v2&page=1&page_size=50" \
</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
Get history of how a memory has changed over time.
Expand Down

0 comments on commit 308e79b

Please sign in to comment.