{"id":23063410,"url":"https://github.com/rmdes/bluesky-deleter","last_synced_at":"2025-04-28T15:33:20.740Z","repository":{"id":268257279,"uuid":"903786501","full_name":"rmdes/bluesky-deleter","owner":"rmdes","description":"How to Bulk Delete Bluesky Posts With Rate Limit Management","archived":false,"fork":false,"pushed_at":"2024-12-29T15:30:08.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T10:51:11.686Z","etag":null,"topics":["bluesky","bluesky-api","bluesky-tools"],"latest_commit_sha":null,"homepage":"https://blog.rmendes.net/2024/12/15/how-to-bulk.html","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rmdes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-15T15:04:47.000Z","updated_at":"2025-02-17T08:32:29.000Z","dependencies_parsed_at":"2025-02-08T21:40:38.466Z","dependency_job_id":null,"html_url":"https://github.com/rmdes/bluesky-deleter","commit_stats":null,"previous_names":["rmdes/bluesky-deleter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdes%2Fbluesky-deleter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdes%2Fbluesky-deleter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdes%2Fbluesky-deleter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdes%2Fbluesky-deleter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmdes","download_url":"https://codeload.github.com/rmdes/bluesky-deleter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251338981,"owners_count":21573648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluesky","bluesky-api","bluesky-tools"],"created_at":"2024-12-16T04:09:35.438Z","updated_at":"2025-04-28T15:33:20.669Z","avatar_url":"https://github.com/rmdes.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"In some cases, you may find that you need to bulk-delete many posts from your Bluesky account. For example, perhaps you shared many links to a particular domain and now you want to remove them en masse. Doing this manually would be tedious. Fortunately, we can automate the process using a script written in TypeScript.\nblog post about it https://blog.rmendes.net/2024/12/15/how-to-bulk.html\n\nThis script leverages the official `@atproto/api` package to:\n1. Log into your Bluesky account.\n2. Fetch all posts that match certain criteria (e.g., containing a specific domain in their facets, embeds, or entities).\n3. Delete them in batches while respecting and reacting to rate limits.\n\n\n## Key Features\n\n\n- **Domain-based Filtering:**  \n  The script identifies posts containing a specific domain by checking:\n  - Facets with `app.bsky.richtext.facet#link`.\n  - External embeds with `app.bsky.embed.external`.\n  - Legacy entities with `type: link`.\n  \n- **Rate Limit Management (Proactive):**  \n  The Bluesky PDS imposes a rate limit of 5000 deletion points per hour. Deletions cost 1 point each. The script proactively monitors how many deletions it has performed within the current hour. When it approaches the limit, it waits until the hour has elapsed before continuing.\n\n\n- **Rate Limit Management (Fallback):**  \n  If the script ever hits a `429 Rate Limit Exceeded` error, it will parse the `ratelimit-reset` header and wait until the given time before retrying that batch of deletions. This ensures that if the proactive limit check is not enough, the script still handles the server’s instructions gracefully.\n\n\n- **Batch Operations and Delays:**  \n  To avoid rapid-fire requests, the script:\n  - Performs deletions in configurable batch sizes (default: 200 per batch).\n  - Waits a short delay between batches to spread requests out over time.\n\n\n## Prerequisites\n\n\n- **Node.js and npm:**  \n  Ensure you have a recent version of Node.js installed.\n\n\n- **Install Dependencies:**\n  ```bash\n  npm install @atproto/api p-ratelimit\n  ```\n- **Use a CommonJS Approach:**\nIf you simply want to run ts-node in a CommonJS environment (the traditional way):\n\nInstall ts-node and typescript locally (if not already):\n  ```bash\nnpm install --save-dev ts-node typescript\n  ```\nSet \"module\": \"commonjs\" (and \"target\": \"ES2020\" or later) in your tsconfig.json. For example:\n  ```bash\n    {\n      \"compilerOptions\": {\n        \"target\": \"ES2020\",\n        \"module\": \"commonjs\",\n        \"strict\": true,\n        \"esModuleInterop\": true,\n        \"skipLibCheck\": true,\n        \"forceConsistentCasingInFileNames\": true\n      }\n    }\n  ```\n## Credentials\n\n\nReplace your-handle and your-password in the script with your Bluesky account credentials. You should only do this with an account you control and trust running scripts on.\n\n\n## Running the Script\n\n\nSave the script below as bluesky-sweep.ts.\n\n\nRun it using:\n\n\n```bash\nnpx ts-node bluesky-sweep.ts\n```\n## Configuration Parameters\n- TARGET_DOMAIN: Set this to the domain you want to search for in your posts.\n- DELETES_PER_BATCH: Number of posts per deletion batch.\n- MAX_DELETES_PER_HOUR: Maximum deletions allowed per hour (5000 is the current default from Bluesky).\n- SAFE_MARGIN: A buffer to start waiting before hitting the exact limit.\n- DELAY_BETWEEN_BATCHES_MS: Milliseconds to wait between each batch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmdes%2Fbluesky-deleter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmdes%2Fbluesky-deleter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmdes%2Fbluesky-deleter/lists"}