xtok
A self-hosted API that turns X threads and articles into Kindle-friendly documents and emails them to a Kindle address.
tldr
A small Python service that uses a logged-in browser session to turn X links into clean Kindle documents, removing the gap between saving something and actually reading it.
the problem
Interesting threads and X Articles are easy to save and easy to forget. The useful reading experience is often somewhere else, so the tool needs to capture the page, preserve the important content, and deliver it without requiring a full browser workflow.
what it is
A self-hosted API that turns X threads and articles into Kindle-friendly documents and emails them to a Kindle address.
why it is useful
It removes the friction between finding something worth reading on X and getting it into a calmer, long-form reading environment.
architecture
A small Python server exposes an authenticated `POST /send` endpoint. Playwright loads X with an existing browser session, extracts thread content and images, renders a clean HTML document, and sends it through Gmail SMTP. Kindle then converts the document as a personal document.
how it works
- The user sends an X URL from an iOS Shortcut or an API client.
- The service opens X with stored authentication cookies and determines whether the URL is a post, thread, or Article.
- Playwright extracts text and images, then the service renders a readable HTML document.
- Gmail SMTP sends the document to the Kindle address, where Kindle handles the final conversion and delivery.
implementation notes
- Supports normal posts, threads, and X Articles.
- Uses auth cookies rather than an official X API, so it reads the same content available to the logged-in browser account.
- Includes an iOS Shortcut for sending a link directly from the share sheet.
- Protects the endpoint with an API key and exposes a health check for deployment monitoring.
engineering decisions
- Uses browser automation instead of depending on the official X API for content access.
- Keeps the public endpoint protected with an API key and exposes a health check for deployment monitoring.
- Optimizes for a personal reading workflow rather than trying to become a general-purpose content archive.