aboutsummaryrefslogtreecommitdiff
path: root/apps/docs/add-memories/examples/basic.mdx
blob: 02cac11e0146df607310094c37e57459b23f5afc (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
---
title: "Basic Usage"
description: "Simple examples of adding text content to Supermemory"
---

Learn how to add basic text content to Supermemory with simple, practical examples.

## Add Simple Text

The most basic operation - adding plain text content.

<CodeGroup>

```typescript TypeScript
const response = await client.add({
  content: "Artificial intelligence is transforming how we work and live"
});

console.log(response);
// Output: { id: "abc123", status: "queued" }
```

```python Python
response = client.add(
    content="Artificial intelligence is transforming how we work and live"
)

print(response)
# Output: {"id": "abc123", "status": "queued"}
```

```bash cURL
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Artificial intelligence is transforming how we work and live"
  }'
```

</CodeGroup>

## Add with Container Tags

Group related content using container tags.

<CodeGroup>

```typescript TypeScript
const response = await client.add({
  content: "Q4 2024 revenue exceeded projections by 15%",
  containerTag: "financial_reports"
});

console.log(response.id);
// Output: xyz789
```

```python Python
response = client.add(
    content="Q4 2024 revenue exceeded projections by 15%",
    container_tag="financial_reports"
)

print(response['id'])
# Output: xyz789
```

```bash cURL
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Q4 2024 revenue exceeded projections by 15%",
    "containerTag": "financial_reports"
  }'

# Response: {"id": "xyz789", "status": "queued"}
```

</CodeGroup>

## Add with Metadata

Attach metadata for better search and filtering.

<CodeGroup>

```typescript TypeScript
await client.add({
  content: "New onboarding flow reduces drop-off by 30%",
  containerTag: "product_updates",
  metadata: {
    impact: "high",
    team: "product"
  }
});
```

```python Python
client.add(
    content="New onboarding flow reduces drop-off by 30%",
    container_tag="product_updates",
    metadata={
        "impact": "high",
        "team": "product"
    }
)
```

```bash cURL
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "New onboarding flow reduces drop-off by 30%",
    "containerTag": "product_updates",
    "metadata": {"impact": "high", "team": "product"}
  }'
```

</CodeGroup>

## Add Multiple Documents

Process multiple related documents.

<CodeGroup>

```typescript TypeScript
const notes = [
  "API redesign discussion",
  "Security audit next month",
  "New hire starting Monday"
];

const results = await Promise.all(
  notes.map(note =>
    client.add({
      content: note,
      containerTag: "meeting_2024_01_15"
    })
  )
);
```

```python Python
notes = [
    "API redesign discussion",
    "Security audit next month",
    "New hire starting Monday"
]

for note in notes:
    client.add(
        content=note,
        container_tag="meeting_2024_01_15"
    )
```

```bash cURL
# Add each note with separate requests
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "API redesign discussion", "containerTag": "meeting_2024_01_15"}'
```

</CodeGroup>

## Add URLs

Process web pages, YouTube videos, and other URLs automatically.

<CodeGroup>

```typescript TypeScript
// Web page
await client.add({
  content: "https://example.com/article",
  containerTag: "articles"
});

// YouTube video (auto-transcribed)
await client.add({
  content: "https://youtube.com/watch?v=dQw4w9WgXcQ",
  containerTag: "videos"
});

// Google Docs
await client.add({
  content: "https://docs.google.com/document/d/abc123/edit",
  containerTag: "docs"
});
```

```python Python
# Web page
client.add(
    content="https://example.com/article",
    container_tag="articles"
)

# YouTube video (auto-transcribed)
client.add(
    content="https://youtube.com/watch?v=dQw4w9WgXcQ",
    container_tag="videos"
)

# Google Docs
client.add(
    content="https://docs.google.com/document/d/abc123/edit",
    container_tag="docs"
)
```

```bash cURL
# Web page
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "https://example.com/article", "containerTag": "articles"}'

# YouTube video
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "https://youtube.com/watch?v=dQw4w9WgXcQ", "containerTag": "videos"}'
```

</CodeGroup>

## Add Markdown Content

Supermemory preserves markdown formatting.

<CodeGroup>

```typescript TypeScript
const markdown = `
# Project Documentation

## Features
- **Real-time sync**
- **AI search**
- **Enterprise security**
`;

await client.add({
  content: markdown,
  containerTag: "docs"
});
```

```python Python
markdown = """
# Project Documentation

## Features
- **Real-time sync**
- **AI search**
- **Enterprise security**
"""

client.add(
    content=markdown,
    container_tag="docs"
)
```

```bash cURL
curl -X POST "https://api.supermemory.ai/v3/documents" \
  -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "# Project Documentation\n\n## Features\n- **Real-time sync**\n- **AI search**", "containerTag": "docs"}'
```

</CodeGroup>