Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix: map TOO_MANY_REQUESTS to 429 in the api

Mohamed Bassem5053050d560a
diff --git a/packages/api/middlewares/trpcAdapter.ts b/packages/api/middlewares/trpcAdapter.ts
index 6bb4a790..ced2539a 100644
--- a/packages/api/middlewares/trpcAdapter.ts
+++ b/packages/api/middlewares/trpcAdapter.ts
@@ -19,6 +19,8 @@ function trpcCodeToHttpCode(code: TRPCError["code"]) {
return 408;
case "PAYLOAD_TOO_LARGE":
return 413;
+ case "TOO_MANY_REQUESTS":
+ return 429;
case "INTERNAL_SERVER_ERROR":
return 500;
default:
diff --git a/packages/open-api/index.ts b/packages/open-api/index.ts
index 2bb8ecc7..0b8e3361 100644
--- a/packages/open-api/index.ts
+++ b/packages/open-api/index.ts
@@ -49,7 +49,8 @@ function getOpenApiDocumentation() {
"Bookmarks can be one of three types:\n" +
"- **link** — A URL bookmark with optional crawled metadata.\n" +
"- **text** — A plain text note.\n" +
- "- **asset** — An uploaded file (image or PDF).",
+ "- **asset** — An uploaded file (image or PDF).\n\n## Rate Limiting\n\nWhen rate limiting is enabled, the API enforces per-IP request limits. " +
+ "If you exceed the allowed number of requests within the time window, the API returns a `429 Too Many Requests` response with a message indicating how many seconds to wait before retrying.",
},
tags: [
{
diff --git a/packages/open-api/karakeep-openapi-spec.json b/packages/open-api/karakeep-openapi-spec.json
index f8864f34..840306b4 100644
--- a/packages/open-api/karakeep-openapi-spec.json
+++ b/packages/open-api/karakeep-openapi-spec.json
@@ -3,7 +3,7 @@
"info": {
"version": "1.0.0",
"title": "Karakeep API",
- "description": "Karakeep is a self-hostable bookmarking and read-it-later service. This API allows you to manage bookmarks, lists, tags, highlights, assets, and backups programmatically.\n\n## Authentication\n\nAll endpoints require a Bearer token passed in the `Authorization` header. You can generate an API key from the Karakeep web UI under **Settings > API Keys**.\n\n## Pagination\n\nList endpoints support cursor-based pagination via `cursor` and `limit` query parameters. The response includes a `nextCursor` field — pass it as the `cursor` parameter to fetch the next page. A `null` value for `nextCursor` indicates there are no more results.\n\n## Bookmark Types\n\nBookmarks can be one of three types:\n- **link** — A URL bookmark with optional crawled metadata.\n- **text** — A plain text note.\n- **asset** — An uploaded file (image or PDF)."
+ "description": "Karakeep is a self-hostable bookmarking and read-it-later service. This API allows you to manage bookmarks, lists, tags, highlights, assets, and backups programmatically.\n\n## Authentication\n\nAll endpoints require a Bearer token passed in the `Authorization` header. You can generate an API key from the Karakeep web UI under **Settings > API Keys**.\n\n## Pagination\n\nList endpoints support cursor-based pagination via `cursor` and `limit` query parameters. The response includes a `nextCursor` field — pass it as the `cursor` parameter to fetch the next page. A `null` value for `nextCursor` indicates there are no more results.\n\n## Bookmark Types\n\nBookmarks can be one of three types:\n- **link** — A URL bookmark with optional crawled metadata.\n- **text** — A plain text note.\n- **asset** — An uploaded file (image or PDF).\n\n## Rate Limiting\n\nWhen rate limiting is enabled, the API enforces per-IP request limits. If you exceed the allowed number of requests within the time window, the API returns a `429 Too Many Requests` response with a message indicating how many seconds to wait before retrying."
},
"tags": [
{