Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 83 additions & 8 deletions fern/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4041,6 +4041,16 @@
"required": true,
"description": "Resource collection to list: source documents, extracted chunks, or learned memories"
},
{
"in": "query",
"name": "cursor",
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 2048
},
"description": "Opaque cursor from a previous response's `pagination.nextCursor`. When present, `page` is ignored and results continue after the last item of the previous page. Filters, sort, order and limit must match the request that produced the cursor."
},
{
"in": "query",
"name": "page",
Expand Down Expand Up @@ -4419,12 +4429,25 @@
"totalPages": {
"type": "number",
"description": "Total pages available at the selected limit"
},
"hasMore": {
"type": "boolean",
"description": "Whether more items exist after this page"
},
"nextCursor": {
"description": "Opaque cursor for the next page. Pass it back as `cursor` with the same filters, sort, order and limit. Null when there are no more items. Cursor requests skip the per-page count and avoid deep offsets.",
"type": [
"string",
"null"
]
}
},
"required": [
"currentPage",
"totalItems",
"totalPages"
"totalPages",
"hasMore",
"nextCursor"
],
"description": "Page metadata for the selected resource collection"
}
Expand Down Expand Up @@ -4497,17 +4520,17 @@
{
"lang": "typescript",
"label": "TypeScript SDK",
"source": "import { Supermemory } from \"supermemory\";\n\nconst client = new Supermemory(); // reads SUPERMEMORY_API_KEY\n\nconst page = await client.list(\"user_123\", \"documents\", {\n page: 1,\n limit: 20,\n sort: \"createdAt\",\n order: \"desc\",\n filter: { field: \"type\", operator: \"eq\", value: \"conversation\" },\n});\nconsole.log(page.documents.length, page.pagination.totalPages);"
"source": "import { Supermemory } from \"supermemory\";\n\nconst client = new Supermemory(); // reads SUPERMEMORY_API_KEY\n\n// Follow pagination.nextCursor instead of page numbers to avoid deep offsets.\nlet cursor: string | undefined;\ndo {\n const page = await client.list(\"user_123\", \"documents\", {\n limit: 100,\n cursor,\n filter: { field: \"type\", operator: \"eq\", value: \"conversation\" },\n });\n console.log(page.documents.length, page.pagination.totalItems);\n cursor = page.pagination.nextCursor ?? undefined;\n} while (cursor);"
},
{
"lang": "python",
"label": "Python SDK",
"source": "from supermemory import Supermemory\n\nclient = Supermemory() # reads SUPERMEMORY_API_KEY\n\npage = client.list(\n \"user_123\",\n \"documents\",\n page=1,\n limit=20,\n sort=\"createdAt\",\n order=\"desc\",\n filter={\"field\": \"type\", \"operator\": \"eq\", \"value\": \"conversation\"},\n)\nprint(len(page.documents), page.pagination.total_pages)"
"source": "from supermemory import Supermemory\n\nclient = Supermemory() # reads SUPERMEMORY_API_KEY\n\ncursor = None\nwhile True:\n page = client.list(\n \"user_123\",\n \"documents\",\n limit=100,\n cursor=cursor,\n filter={\"field\": \"type\", \"operator\": \"eq\", \"value\": \"conversation\"},\n )\n print(len(page.documents), page.pagination.total_items)\n cursor = page.pagination.next_cursor\n if not cursor:\n break"
},
{
"lang": "bash",
"label": "cURL",
"source": "curl -X POST \"https://api.supermemory.ai/ns/user_123/list/documents?page=1&limit=20&sort=createdAt&order=desc\" \\\n -H \"Authorization: Bearer $SUPERMEMORY_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{ \"filter\": { \"field\": \"type\", \"operator\": \"eq\", \"value\": \"conversation\" } }'"
"source": "curl -X POST \"https://api.supermemory.ai/ns/user_123/list/documents?limit=100\" \\\n -H \"Authorization: Bearer $SUPERMEMORY_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{ \"filter\": { \"field\": \"type\", \"operator\": \"eq\", \"value\": \"conversation\" } }'\n# then repeat with &cursor=<pagination.nextCursor> until hasMore is false"
}
]
}
Expand Down Expand Up @@ -5013,6 +5036,17 @@
},
"totalPages": {
"type": "number"
},
"hasMore": {
"description": "Whether more items exist after this page",
"type": "boolean"
},
"nextCursor": {
"description": "Opaque cursor for the next page. Pass it back as `cursor`. Null when there are no more items.",
"type": [
"string",
"null"
]
}
},
"required": [
Expand All @@ -5025,7 +5059,9 @@
"currentPage": 1,
"limit": 10,
"totalItems": 100,
"totalPages": 10
"totalPages": 10,
"hasMore": true,
"nextCursor": "<opaque cursor>"
}
}
},
Expand Down Expand Up @@ -6075,6 +6111,17 @@
},
"totalPages": {
"type": "number"
},
"hasMore": {
"description": "Whether more items exist after this page",
"type": "boolean"
},
"nextCursor": {
"description": "Opaque cursor for the next page. Pass it back as `cursor`. Null when there are no more items.",
"type": [
"string",
"null"
]
}
},
"required": [
Expand All @@ -6087,7 +6134,9 @@
"currentPage": 1,
"limit": 10,
"totalItems": 100,
"totalPages": 10
"totalPages": 10,
"hasMore": true,
"nextCursor": "<opaque cursor>"
}
}
},
Expand Down Expand Up @@ -7757,6 +7806,17 @@
},
"totalPages": {
"type": "number"
},
"hasMore": {
"description": "Whether more items exist after this page",
"type": "boolean"
},
"nextCursor": {
"description": "Opaque cursor for the next page. Pass it back as `cursor`. Null when there are no more items.",
"type": [
"string",
"null"
]
}
},
"required": [
Expand All @@ -7769,7 +7829,9 @@
"currentPage": 1,
"limit": 10,
"totalItems": 100,
"totalPages": 10
"totalPages": 10,
"hasMore": true,
"nextCursor": "<opaque cursor>"
}
}
},
Expand Down Expand Up @@ -7977,6 +8039,17 @@
},
"totalPages": {
"type": "number"
},
"hasMore": {
"description": "Whether more items exist after this page",
"type": "boolean"
},
"nextCursor": {
"description": "Opaque cursor for the next page. Pass it back as `cursor`. Null when there are no more items.",
"type": [
"string",
"null"
]
}
},
"required": [
Expand All @@ -7989,7 +8062,9 @@
"currentPage": 1,
"limit": 10,
"totalItems": 100,
"totalPages": 10
"totalPages": 10,
"hasMore": true,
"nextCursor": "<opaque cursor>"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "supermemory"
version = "5.0.1"
version = "5.0.2"
description = "The official Python library for the Supermemory API"
readme = "README.md"
license = "Apache-2.0"
Expand Down
8 changes: 8 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,14 @@ client.list(
<dl>
<dd>

**cursor:** `typing.Optional[str]` — Opaque cursor from a previous response's `pagination.nextCursor`. When present, `page` is ignored and results continue after the last item of the previous page. Filters, sort, order and limit must match the request that produced the cursor.

</dd>
</dl>

<dl>
<dd>

**page:** `typing.Optional[int]` — One-based page number

</dd>
Expand Down
12 changes: 12 additions & 0 deletions src/supermemory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ConnectorInclude,
ConnectorLink,
ConnectorList,
ConnectorListPagination,
ConnectorProvider,
ConnectorRun,
ConnectorRunStatus,
Expand Down Expand Up @@ -124,6 +125,7 @@
NamespaceDeleted_Queued,
NamespaceDetails,
NamespaceList,
NamespaceListPagination,
NamespaceSystem,
Organization,
Pagination,
Expand Down Expand Up @@ -180,6 +182,7 @@
ConnectorConfigValueParams,
ConnectorDeletedParams,
ConnectorLinkParams,
ConnectorListPaginationParams,
ConnectorListParams,
ConnectorParams,
ConnectorRunParams,
Expand Down Expand Up @@ -261,6 +264,7 @@
NamespaceDeleted_DeletedParams,
NamespaceDeleted_QueuedParams,
NamespaceDetailsParams,
NamespaceListPaginationParams,
NamespaceListParams,
NamespaceParams,
NamespaceSystemParams,
Expand Down Expand Up @@ -313,6 +317,8 @@
"ConnectorLink": ".types",
"ConnectorLinkParams": ".requests",
"ConnectorList": ".types",
"ConnectorListPagination": ".types",
"ConnectorListPaginationParams": ".requests",
"ConnectorListParams": ".requests",
"ConnectorParams": ".requests",
"ConnectorProvider": ".types",
Expand Down Expand Up @@ -499,6 +505,8 @@
"NamespaceDetails": ".types",
"NamespaceDetailsParams": ".requests",
"NamespaceList": ".types",
"NamespaceListPagination": ".types",
"NamespaceListPaginationParams": ".requests",
"NamespaceListParams": ".requests",
"NamespaceParams": ".requests",
"NamespaceSystem": ".types",
Expand Down Expand Up @@ -623,6 +631,8 @@ def __dir__():
"ConnectorLink",
"ConnectorLinkParams",
"ConnectorList",
"ConnectorListPagination",
"ConnectorListPaginationParams",
"ConnectorListParams",
"ConnectorParams",
"ConnectorProvider",
Expand Down Expand Up @@ -810,6 +820,8 @@ def __dir__():
"NamespaceDetails",
"NamespaceDetailsParams",
"NamespaceList",
"NamespaceListPagination",
"NamespaceListPaginationParams",
"NamespaceListParams",
"NamespaceParams",
"NamespaceSystem",
Expand Down
10 changes: 10 additions & 0 deletions src/supermemory/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def list(
namespace: str,
type: ListType,
*,
cursor: typing.Optional[str] = None,
page: typing.Optional[int] = None,
limit: typing.Optional[int] = None,
sort: typing.Optional[ListSort] = None,
Expand All @@ -396,6 +397,9 @@ def list(
type : ListType
Resource collection to list: source documents, extracted chunks, or learned memories

cursor : typing.Optional[str]
Opaque cursor from a previous response's `pagination.nextCursor`. When present, `page` is ignored and results continue after the last item of the previous page. Filters, sort, order and limit must match the request that produced the cursor.

page : typing.Optional[int]
One-based page number

Expand Down Expand Up @@ -439,6 +443,7 @@ def list(
_response = self._raw_client.list(
namespace,
type,
cursor=cursor,
page=page,
limit=limit,
sort=sort,
Expand Down Expand Up @@ -891,6 +896,7 @@ async def list(
namespace: str,
type: ListType,
*,
cursor: typing.Optional[str] = None,
page: typing.Optional[int] = None,
limit: typing.Optional[int] = None,
sort: typing.Optional[ListSort] = None,
Expand All @@ -914,6 +920,9 @@ async def list(
type : ListType
Resource collection to list: source documents, extracted chunks, or learned memories

cursor : typing.Optional[str]
Opaque cursor from a previous response's `pagination.nextCursor`. When present, `page` is ignored and results continue after the last item of the previous page. Filters, sort, order and limit must match the request that produced the cursor.

page : typing.Optional[int]
One-based page number

Expand Down Expand Up @@ -965,6 +974,7 @@ async def main() -> None:
_response = await self._raw_client.list(
namespace,
type,
cursor=cursor,
page=page,
limit=limit,
sort=sort,
Expand Down
2 changes: 1 addition & 1 deletion src/supermemory/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_headers(self) -> typing.Dict[str, str]:
import platform

headers: typing.Dict[str, str] = {
"User-Agent": "supermemory/5.0.1",
"User-Agent": "supermemory/5.0.2",
"X-Fern-Language": "Python",
"X-Fern-Runtime": f"python/{platform.python_version()}",
"X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
Expand Down
10 changes: 10 additions & 0 deletions src/supermemory/raw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ def list(
namespace: str,
type: ListType,
*,
cursor: typing.Optional[str] = None,
page: typing.Optional[int] = None,
limit: typing.Optional[int] = None,
sort: typing.Optional[ListSort] = None,
Expand All @@ -509,6 +510,9 @@ def list(
type : ListType
Resource collection to list: source documents, extracted chunks, or learned memories

cursor : typing.Optional[str]
Opaque cursor from a previous response's `pagination.nextCursor`. When present, `page` is ignored and results continue after the last item of the previous page. Filters, sort, order and limit must match the request that produced the cursor.

page : typing.Optional[int]
One-based page number

Expand Down Expand Up @@ -539,6 +543,7 @@ def list(
f"ns/{encode_path_param(namespace)}/list/{encode_path_param(type)}",
method="POST",
params={
"cursor": cursor,
"page": page,
"limit": limit,
"sort": sort,
Expand Down Expand Up @@ -1064,6 +1069,7 @@ async def list(
namespace: str,
type: ListType,
*,
cursor: typing.Optional[str] = None,
page: typing.Optional[int] = None,
limit: typing.Optional[int] = None,
sort: typing.Optional[ListSort] = None,
Expand All @@ -1087,6 +1093,9 @@ async def list(
type : ListType
Resource collection to list: source documents, extracted chunks, or learned memories

cursor : typing.Optional[str]
Opaque cursor from a previous response's `pagination.nextCursor`. When present, `page` is ignored and results continue after the last item of the previous page. Filters, sort, order and limit must match the request that produced the cursor.

page : typing.Optional[int]
One-based page number

Expand Down Expand Up @@ -1117,6 +1126,7 @@ async def list(
f"ns/{encode_path_param(namespace)}/list/{encode_path_param(type)}",
method="POST",
params={
"cursor": cursor,
"page": page,
"limit": limit,
"sort": sort,
Expand Down
Loading
Loading