{"id":17274317,"url":"https://github.com/xetera/kindle-api","last_synced_at":"2025-07-25T21:02:28.499Z","repository":{"id":65273167,"uuid":"588410230","full_name":"Xetera/kindle-api","owner":"Xetera","description":"📕 Access Kindle's private API in Node.js without a headless browser","archived":false,"fork":false,"pushed_at":"2024-02-24T16:53:11.000Z","size":342,"stargazers_count":182,"open_issues_count":8,"forks_count":16,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-07-23T06:44:20.796Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xetera.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":"2023-01-13T03:32:56.000Z","updated_at":"2025-07-16T20:27:10.000Z","dependencies_parsed_at":"2024-01-15T19:45:08.955Z","dependency_job_id":"b8203de5-e00e-4ead-9569-8bc97a9ca50a","html_url":"https://github.com/Xetera/kindle-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Xetera/kindle-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xetera%2Fkindle-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xetera%2Fkindle-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xetera%2Fkindle-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xetera%2Fkindle-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xetera","download_url":"https://codeload.github.com/Xetera/kindle-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xetera%2Fkindle-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267061734,"owners_count":24029525,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-15T08:53:38.717Z","updated_at":"2025-07-25T21:02:28.335Z","avatar_url":"https://github.com/Xetera.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kindle-Api\n\nA zero dependency, blazing fast library for Amazon Kindle's private API built without headless browsers.\n\n## Installation\n\n```\npnpm add kindle-api\n```\n\n## Setup\n\nOk I kinda lied about the zero dependency part. The library does actually depend on an external [tls-client-api](https://github.com/bogdanfinn/tls-client-api) to proxy requests due to amazon's recent changes to their TLS fingerprinting in July 2023. You'll need to run the server locally to be able to use this library. It's quite easy to set up and have one running in a few minutes and will save you tons of headache if you wanna do other kinds of scraping in the future\n\n### Cookies\n\nAmazon's login system is quite strict and the SMS 2FA makes automating logins difficult. Instead of trying to automate that with puppeteer and slow things down, we use 4 cookies that stay valid for an entire year.\n\n- `ubid-main`\n- `at-main`\n- `x-main`\n- `session-id`\n\nYou can grab these values directly by going on inspect element after loading [read.amazon.com](https://read.amazon.com) and copying the entire thing or just the select ones ![](./assets/cookie-demonstration.png)\n\n### Device Token\n\nWe also need a deviceToken for your kindle. You can grab this from the same network window as before on the `getDeviceToken` request that looks like:\n\nhttps://read.amazon.com/service/web/register/getDeviceToken?serialNumber=(your-device-token)\u0026deviceType=(your-device-token)\n\n![](./assets/kindle-device-token.png)\n\nBoth of those numbers should be the same.\n\n### Usage\n\nUpon creating the `Kindle` object, you'll load the first batch of books.\n\n```js\nimport { Kindle } from \"kindle-api\";\n\nconst kindle = await Kindle.fromConfig({\n  cookies: \"ubid-main=xxx.xxxx ...\",\n  deviceToken: \"(your-device-token)\",\n  tlsServer: {\n    url: \"https://your-tls-server-api.com\",\n    apiKey: \"(your-api-key)\",\n  },\n});\n\nconsole.log(kindle.defaultBooks);\n\n/*\n[\n  KindleBook {\n    title: 'Project Hail Mary: A Novel',\n    authors: [ { firstName: 'Andy', lastName: 'Weir' } ]\n    imageUrl: 'https://m.media-amazon.com/images/I/51YS2zsN+iL._SY400_.jpg',\n    asin: 'B08FHBV4ZX',\n    originType: 'PURCHASE',\n    productUrl: 'https://m.media-amazon.com/images/I/51YS2zsN+iL._SY400_.jpg',\n    mangaOrComicAsin: false,\n    webReaderUrl: 'https://read.amazon.com/?asin=B08FHBV4ZX'\n  },\n  KindleBook {\n    title: 'Engineering Management for the Rest of Us',\n    authors: [ { firstName: 'Sarah', lastName: 'Drasner' } ],\n    imageUrl: 'https://m.media-amazon.com/images/I/61xVsTw0gIL._SY400_.jpg',\n    asin: 'B0BGYVDX35',\n    originType: 'PURCHASE',\n    productUrl: 'https://m.media-amazon.com/images/I/61xVsTw0gIL._SY400_.jpg',\n    mangaOrComicAsin: false,\n    webReaderUrl: 'https://read.amazon.com/?asin=B0BGYVDX35'\n  }\n]\n*/\n```\n\n## Book Details\n\nHere's an example of how you could implement a script that keeps track of your book progress\n\n```ts\nimport { setTimeout } from \"node:timers/promises\";\n\n// assuming we saved our previous run\nconst previous = await getPreviousData();\n\n// you can use `await kindle.books()` if you want to re-fetch your book list\nfor (const book of kindle.defaultBooks) {\n  const details = await book.details();\n\n  const readSinceLastTime =\n    details.progress.syncDate \u003e previous.get(details.asin).lastSync;\n\n  if (readSinceLastTime) {\n    // make another request to fetch full book details\n    // including reading progress\n    const fullDetails = await book.fullDetails(details);\n    console.log(fullDetails.percentageRead); // 45\n  }\n\n  // add a delay after each book lookup to not spam and get banned\n  await setTimeout(5000);\n}\n```\n\n## Missing features\n\n- [ ] Pagination\n- [ ] Reading book content? Can't think of a usecase for this one\n- [ ] Basically anything that isn't just getting book info\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxetera%2Fkindle-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxetera%2Fkindle-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxetera%2Fkindle-api/lists"}