aboutsummaryrefslogtreecommitdiff
path: root/apps/docs/list-memories/examples/basic.mdx
blob: e0fa40dc4887dcde2aa51643fe4e8aeef1713129 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: "Basic Listing"
description: "Simple memory retrieval across languages"
---

Simple memory retrieval examples for getting started with the list memories endpoint.

## Basic Usage

<Tabs>
  <Tab title="TypeScript">
    ```typescript
    import Supermemory from 'supermemory';

    const client = new Supermemory({
      apiKey: process.env.SUPERMEMORY_API_KEY!
    });

    const response = await client.documents.list({ limit: 10 });
    console.log(response);
    ```
  </Tab>
  <Tab title="Python">
    ```python
    from supermemory import Supermemory
    import os

    client = Supermemory(api_key=os.environ.get("SUPERMEMORY_API_KEY"))
    response = client.documents.list(limit=10)
    print(response)
    ```
  </Tab>
  <Tab title="cURL">
    ```bash
    curl -X POST "https://api.supermemory.ai/v3/documents/list" \
      -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"limit": 10}'
    ```
  </Tab>
</Tabs>

## With Custom Parameters

<Tabs>
  <Tab title="TypeScript">
    ```typescript
    const response = await client.documents.list({
      containerTags: ["user_123"],
      limit: 20,
      sort: "updatedAt",
      order: "desc"
    });

    console.log(`Found ${response.memories.length} memories`);
    ```
  </Tab>
  <Tab title="Python">
    ```python
    response = client.documents.list(
        container_tags=["user_123"],
        limit=20,
        sort="updatedAt",
        order="desc"
    )

    print(f"Found {len(response.memories)} memories")
    ```
  </Tab>
  <Tab title="cURL">
    ```bash
    curl -X POST "https://api.supermemory.ai/v3/documents/list" \
      -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "containerTags": ["user_123"],
        "limit": 20,
        "sort": "updatedAt",
        "order": "desc"
      }'
    ```
  </Tab>
</Tabs>

<Info>
  Start with small `limit` values (10-20) when testing to avoid overwhelming responses.
</Info>