{"_id":"@ayushwalekar/lichess-js","_rev":"2-6883a23a1eb7ab6db859d8f2f37b899f","name":"@ayushwalekar/lichess-js","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@ayushwalekar/lichess-js","version":"0.1.0","keywords":["lichess","chess","api","javascript","typescript","client","sdk"],"author":{"name":"Your Name"},"license":"MIT","_id":"@ayushwalekar/lichess-js@0.1.0","maintainers":[{"name":"ayushwalekar","email":"walekarayush@gmail.com"}],"homepage":"https://github.com/AyushWalekar/lichess-js#readme","bugs":{"url":"https://github.com/AyushWalekar/lichess-js/issues"},"dist":{"shasum":"1434fd43f5e6bfd264f8b7592667a349b1041003","tarball":"https://registry.npmjs.org/@ayushwalekar/lichess-js/-/lichess-js-0.1.0.tgz","fileCount":62,"integrity":"sha512-Hd5biseQ0LqBSd88wQwI4YXbrVxUnNGjaUnbc+YGhgmi3IMJrfGWLOV/LB2GV0B+RBRbh0muT5rwQHvVBOHqKw==","signatures":[{"sig":"MEUCIHrNeOGrPQbZV3msfZMC3K5aQu8uliDWuVJriHuxsidLAiEA+n1yAkq9KkF36VNFD4PZ6ixPQhkX/xITl56JJ35iAcU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":682036},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","module":"dist/index.js","engines":{"node":">=18.0.0"},"gitHead":"42fccb629e438fb2953cb383764f76c7e7991cfc","scripts":{"build":"tsc","clean":"rm -rf dist src/generated","generate":"openapi-ts","prebuild":"npm run generate","prepublishOnly":"npm run build"},"_npmUser":{"name":"ayushwalekar","actor":{"name":"ayushwalekar","type":"user","email":"walekarayush@gmail.com"},"email":"walekarayush@gmail.com"},"repository":{"url":"git+https://github.com/AyushWalekar/lichess-js.git","type":"git"},"_npmVersion":"10.9.2","description":"A modern JavaScript/TypeScript client for the Lichess API, generated from the official OpenAPI specification","directories":{},"_nodeVersion":"22.13.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.0","@types/node":"^24.0.3","@hey-api/openapi-ts":"^0.74.0"},"_npmOperationalInternal":{"tmp":"tmp/lichess-js_0.1.0_1750482838755_0.040824067920363305","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@ayushwalekar/lichess-js","version":"0.2.0","description":"A modern JavaScript/TypeScript client for the Lichess API, generated from the official OpenAPI specification","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","scripts":{"generate":"openapi-ts","build":"tsc","clean":"rm -rf dist src/generated","prebuild":"npm run generate","prepublishOnly":"npm run build"},"keywords":["lichess","chess","api","javascript","typescript","client","sdk"],"author":{"name":"Your Name"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/AyushWalekar/lichess-js.git"},"homepage":"https://github.com/AyushWalekar/lichess-js#readme","bugs":{"url":"https://github.com/AyushWalekar/lichess-js/issues"},"devDependencies":{"@hey-api/openapi-ts":"^0.74.0","@types/node":"^24.0.3","typescript":"^5.3.0"},"engines":{"node":">=18.0.0"},"type":"module","publishConfig":{"access":"public"},"_id":"@ayushwalekar/lichess-js@0.2.0","gitHead":"0490b0fea16757a4085ab547508a326684a96f03","_nodeVersion":"22.13.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-LSyXPdNcRCIRp3TJRhYVyKODctV2Y2g+OqNy7V8jDjLn1t9qqcDlxtAsgTSIre+gKyfjqQjIH3SoUzwyxPnDBw==","shasum":"92a0eb596b0ec556593a1b90d97a29437ee90525","tarball":"https://registry.npmjs.org/@ayushwalekar/lichess-js/-/lichess-js-0.2.0.tgz","fileCount":62,"unpackedSize":682036,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIExyaNiBih0VVJBx2wncCEzZil1O5/qVQZwzdDRMEUFlAiBjGY5Rfw1HjF2CaG1xggP50nkydIgkqgu/dlrHDUE+6A=="}]},"_npmUser":{"name":"ayushwalekar","email":"walekarayush@gmail.com","actor":{"name":"ayushwalekar","email":"walekarayush@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"ayushwalekar","email":"walekarayush@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lichess-js_0.2.0_1750483264535_0.47334876229577816"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-21T05:13:58.653Z","modified":"2025-06-21T05:21:04.890Z","0.1.0":"2025-06-21T05:13:59.003Z","0.2.0":"2025-06-21T05:21:04.715Z"},"bugs":{"url":"https://github.com/AyushWalekar/lichess-js/issues"},"author":{"name":"Your Name"},"license":"MIT","homepage":"https://github.com/AyushWalekar/lichess-js#readme","keywords":["lichess","chess","api","javascript","typescript","client","sdk"],"repository":{"type":"git","url":"git+https://github.com/AyushWalekar/lichess-js.git"},"description":"A modern JavaScript/TypeScript client for the Lichess API, generated from the official OpenAPI specification","maintainers":[{"name":"ayushwalekar","email":"walekarayush@gmail.com"}],"readme":"# @ayushwalekar/lichess-js\n\nA modern JavaScript/TypeScript client for the Lichess API, generated from the official OpenAPI specification.\n\n## Features\n\n- 🎯 **Type-safe**: Full TypeScript support with auto-generated types\n- 🔄 **Up-to-date**: Generated from the latest Lichess OpenAPI specification\n- 🚀 **Modern**: Uses Fetch API with ESM modules\n- 🔑 **Authentication**: Built-in support for Personal Access Tokens\n- 📦 **Tree-shakable**: Only import what you need\n- 🌐 **Universal**: Works in Node.js and modern browsers\n\n## Installation\n\n```bash\nnpm install @ayushwalekar/lichess-js\n# or\npnpm add @ayushwalekar/lichess-js\n# or\nyarn add @ayushwalekar/lichess-js\n```\n\n## Quick Start\n\n1. **Get your API token**: Visit [Lichess Personal Access Tokens](https://lichess.org/account/oauth/token) to generate a token.\n\n2. **Use the client**:\n\n```typescript\nimport { createLichessClient } from \"@ayushwalekar/lichess-js\";\n\n// Create client with your token\nconst lichess = createLichessClient({\n  token: \"your-personal-access-token\",\n});\n\n// Get your account info\nconst account = await lichess.accountMe();\nconsole.log(`Hello, ${account.data?.username}!`);\n\n// Get user status\nconst userStatus = await lichess.apiUsersStatus({\n  query: {\n    ids: \"thibault,maia1,maia5\",\n    withGameIds: true,\n  },\n});\nconsole.log(\"User statuses:\", userStatus.data);\n\n// Get recent games\nconst games = await lichess.apiGamesUser({\n  path: {\n    username: \"thibault\",\n  },\n  query: {\n    max: 10,\n  },\n});\nconsole.log(\"Recent games:\", games.data);\n```\n\n## Configuration\n\n### Basic Configuration\n\n```typescript\nimport { createLichessClient } from \"@ayushwalekar/lichess-js\";\n\nconst lichess = createLichessClient({\n  token: \"your-token\",\n  baseUrl: \"https://lichess.org\", // optional, defaults to https://lichess.org\n});\n```\n\n### Environment Variables\n\nFor security, store your token in environment variables:\n\n```typescript\nconst lichess = createLichessClient({\n  token: process.env.LICHESS_TOKEN!,\n});\n```\n\n## API Coverage\n\nThis client provides access to all Lichess API endpoints including:\n\n- **Account**: Profile, preferences, kid mode\n- **Users**: Public user information, status, activity\n- **Games**: Export games, ongoing games, game analysis\n- **Puzzles**: Puzzle dashboard, activity, themes\n- **Teams**: Team information, members, join/leave\n- **Tournaments**: Arena and Swiss tournaments\n- **Studies**: Chess studies and chapters\n- **Board**: Play games with physical boards\n- **Bot**: Bot account functionality\n- **Broadcasts**: Live game broadcasts\n- **And much more...**\n\n## Examples\n\n### Get User Information\n\n```typescript\n// Get public user profile\nconst user = await lichess.apiUser({\n  path: { username: \"thibault\" },\n});\nconsole.log(user.data);\n\n// Get multiple users' online status\nconst statuses = await lichess.apiUsersStatus({\n  query: {\n    ids: \"thibault,maia1,maia5\",\n    withGameIds: true,\n  },\n});\n```\n\n### Export Games\n\n```typescript\n// Export user's games\nconst games = await lichess.apiGamesUser({\n  path: { username: \"thibault\" },\n  query: {\n    since: Date.now() - 7 * 24 * 60 * 60 * 1000, // Last 7 days\n    max: 20,\n  },\n});\n```\n\n### Puzzle Activity\n\n```typescript\n// Get puzzle dashboard\nconst puzzles = await lichess.apiPuzzleDashboard({\n  path: { days: 30 },\n});\n\n// Get puzzle activity\nconst activity = await lichess.apiPuzzleActivity({\n  query: { max: 50 },\n});\n```\n\n### Team Management\n\n```typescript\n// Get team information\nconst team = await lichess.teamShow({\n  path: { teamId: \"lichess-swiss\" },\n});\n\n// Get team members\nconst members = await lichess.teamIdUsers({\n  path: { teamId: \"lichess-swiss\" },\n});\n```\n\n## Error Handling\n\nThe client returns response objects with both data and error information:\n\n```typescript\ntry {\n  const account = await lichess.accountMe();\n\n  if (account.error) {\n    console.error(\"API Error:\", account.error);\n    return;\n  }\n\n  console.log(\"Account:\", account.data);\n} catch (error) {\n  console.error(\"Network Error:\", error);\n}\n```\n\n## Rate Limiting\n\nLichess APIs are rate-limited. The client will return appropriate HTTP status codes (429) when rate limits are exceeded. Always handle these gracefully:\n\n```typescript\nconst response = await lichess.accountMe();\n\nif (response.response?.status === 429) {\n  console.log(\"Rate limited. Please wait before making more requests.\");\n  // Wait 60 seconds as recommended by Lichess documentation\n  await new Promise((resolve) => setTimeout(resolve, 60000));\n}\n```\n\n## Type Safety\n\nAll API responses are fully typed. You get complete IntelliSense support:\n\n```typescript\nconst account = await lichess.accountMe();\n\n// TypeScript knows the exact shape of the response\nif (account.data) {\n  console.log(account.data.username); // ✅ Type-safe\n  console.log(account.data.profile?.realName); // ✅ Optional chaining\n  // console.log(account.data.invalidField); // ❌ TypeScript error\n}\n```\n\n## Development\n\nThis package is generated from the official Lichess OpenAPI specification using [Hey API](https://heyapi.dev/).\n\n### Building from Source\n\n```bash\n# Clone the repository\ngit clone https://github.com/yourusername/lichess-ts.git\ncd lichess-ts\n\n# Install dependencies\npnpm install\n\n# Generate client from OpenAPI spec\npnpm run generate\n\n# Build the package\npnpm run build\n```\n\n### Project Scripts\n\n- `pnpm run generate` - Generate TypeScript client from OpenAPI spec\n- `pnpm run build` - Build the package for distribution\n- `pnpm run clean` - Clean generated files and build output\n\n### Updating the API\n\nTo update to the latest Lichess API:\n\n1. Download the latest `lichess-openapi.json` from Lichess\n2. Replace the existing file\n3. Run `pnpm run generate && pnpm run build`\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- [Lichess.org](https://lichess.org) for providing the excellent chess platform and API\n- [Hey API](https://heyapi.dev/) for the powerful OpenAPI code generation tools\n- The TypeScript and Node.js communities for the amazing ecosystem\n\n## Related Projects\n\n- [Lichess API Documentation](https://lichess.org/api)\n- [Hey API OpenAPI TypeScript](https://github.com/hey-api/openapi-ts)\n- [Lichess Database](https://database.lichess.org/) - Download games and puzzles\n\n## Support\n\n- [Lichess Discord](https://discord.gg/lichess) - Get help with the Lichess API\n- [GitHub Issues](https://github.com/yourusername/lichess-ts/issues) - Report bugs or request features\n","readmeFilename":"README.md"}