{"_id":"@apinator/client","_rev":"7-d31215e14d32d6fa42ae54ae96d96f05","name":"@apinator/client","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@apinator/client","version":"1.0.0","keywords":["apinator","realtime","websocket","pubsub","channels","presence","sdk","client"],"author":{"url":"https://apinator.io","name":"Apinator","email":"dev@apinator.io"},"license":"MIT","_id":"@apinator/client@1.0.0","maintainers":[{"name":"apinator","email":"hello@apinator.io"}],"homepage":"https://github.com/apinator-io/client-js#readme","bugs":{"url":"https://github.com/apinator-io/client-js/issues"},"dist":{"shasum":"97fad448a45efbc8e3207ec63a57f243b5fdc8f0","tarball":"https://registry.npmjs.org/@apinator/client/-/client-1.0.0.tgz","fileCount":9,"integrity":"sha512-qdCI1dJtz5W+UhUjfYpSMIB7zeC225z/LQIBYbShu8YVZu2nZjASqbu/0+MicXgyoO1CK/osHqM6x1oElwbAaA==","signatures":[{"sig":"MEUCIAgND16iNv+7GxeSwhWTDJ3luSQfOX/K4pQSAS0O2kpcAiEAuOIepfEoNqQH4C54yuZWyEG2ojR1mlfsyT+dRCCkt5w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":117858},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"18f008443f5d783a7c290cd2028bf98880ffa8bc","scripts":{"lint":"tsc --noEmit","test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"apinator","email":"hello@apinator.io"},"repository":{"url":"git+https://github.com/apinator-io/client-js.git","type":"git"},"_npmVersion":"10.8.2","description":"JavaScript client SDK for Apinator — real-time WebSocket messaging","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","typescript":"^5.4.0","@vitest/coverage-v8":"^2.1.9"},"_npmOperationalInternal":{"tmp":"tmp/client_1.0.0_1771272575566_0.1342641041168029","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@apinator/client","version":"2.0.0","description":"JavaScript client SDK for Apinator — real-time WebSocket messaging","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup","lint":"tsc --noEmit","test":"vitest run","test:coverage":"vitest run --coverage","test:watch":"vitest","typecheck":"tsc --noEmit"},"license":"MIT","author":{"name":"Apinator","email":"dev@apinator.io","url":"https://apinator.io"},"repository":{"type":"git","url":"git+https://github.com/apinator-io/client-js.git"},"bugs":{"url":"https://github.com/apinator-io/client-js/issues"},"homepage":"https://github.com/apinator-io/client-js#readme","keywords":["apinator","realtime","websocket","pubsub","channels","presence","sdk","client"],"devDependencies":{"@vitest/coverage-v8":"^2.1.9","tsup":"^8.0.0","typescript":"^5.4.0","vitest":"^2.0.0"},"_id":"@apinator/client@2.0.0","gitHead":"6205cbf046722f9a8cac3fcdc9d26da4a0592960","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-C6ytd/g071c5ibj+VifNxX58UJlwY2YGLv8oL3UvVHooT3dcenAlwe+C1Glf2BdG93psGnUeGVj3390Vi8GC0w==","shasum":"eaa78a806215a5a942aa28ffcb1ec6eb5f1d7c7f","tarball":"https://registry.npmjs.org/@apinator/client/-/client-2.0.0.tgz","fileCount":9,"unpackedSize":117858,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCPv+BoyWmKYiO7IhAq2CE+GT5nCN1bXmHhQyyOeZsORgIhAI9XX0yk2b9ujH2u/8QauvCaCLnQ8LNqG5QRvUesv6q+"}]},"_npmUser":{"name":"apinator","email":"hello@apinator.io"},"directories":{},"maintainers":[{"name":"apinator","email":"hello@apinator.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/client_2.0.0_1771278697047_0.06796056456054345"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-16T20:09:35.479Z","modified":"2026-02-16T21:51:37.320Z","1.1.0":"2026-02-16T01:12:09.509Z","1.1.1":"2026-02-16T08:49:31.337Z","1.1.2":"2026-02-16T19:13:39.405Z","1.1.3":"2026-02-16T19:38:40.477Z","1.0.0":"2026-02-16T20:09:35.689Z","2.0.0":"2026-02-16T21:51:37.204Z"},"bugs":{"url":"https://github.com/apinator-io/client-js/issues"},"author":{"name":"Apinator","email":"dev@apinator.io","url":"https://apinator.io"},"license":"MIT","homepage":"https://github.com/apinator-io/client-js#readme","keywords":["apinator","realtime","websocket","pubsub","channels","presence","sdk","client"],"repository":{"type":"git","url":"git+https://github.com/apinator-io/client-js.git"},"description":"JavaScript client SDK for Apinator — real-time WebSocket messaging","maintainers":[{"name":"apinator","email":"hello@apinator.io"}],"readme":"# @apinator/client\n\n[![npm version](https://img.shields.io/npm/v/@apinator/client.svg)](https://www.npmjs.com/package/@apinator/client)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![CI](https://img.shields.io/github/actions/workflow/status/apinator-io/client-js/test.yml?label=CI)](https://github.com/apinator-io/client-js/actions/workflows/test.yml)\n\nJavaScript client SDK for [Apinator](https://apinator.io) — real-time WebSocket messaging for web applications.\n\n## Features\n\n- Public, private, and presence channels\n- Automatic reconnection with exponential backoff\n- Client events on private/presence channels\n- Presence member tracking\n- TypeScript-first with full type definitions\n- Zero dependencies — works in any modern browser\n- Dual ESM + CommonJS builds\n\n## Installation\n\n```bash\nnpm install @apinator/client\n```\n\nOr via CDN:\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/@apinator/client/dist/index.mjs\" type=\"module\"></script>\n```\n\n## Quick Start\n\n```typescript\nimport { Apinator } from '@apinator/client';\n\nconst client = new Apinator({\n  appKey: 'your-app-key',\n  cluster: 'eu',\n});\n\nclient.connect();\n\nconst channel = client.subscribe('my-channel');\n\nchannel.bind('my-event', (data) => {\n  console.log('Received:', data);\n});\n```\n\n## Channel Types\n\n### Public Channels\n\nNo authentication required. Any client can subscribe.\n\n```typescript\nconst channel = client.subscribe('news');\nchannel.bind('update', (data) => { /* ... */ });\n```\n\n### Private Channels\n\nRequire server-side authentication. Prefix with `private-`.\n\n```typescript\nconst client = new Apinator({\n  appKey: 'your-app-key',\n  cluster: 'eu',\n  authEndpoint: '/api/realtime/auth',\n});\n\nconst channel = client.subscribe('private-orders');\nchannel.bind('new-order', (data) => { /* ... */ });\n```\n\n### Presence Channels\n\nLike private channels, but also track who is subscribed. Prefix with `presence-`.\n\n```typescript\nconst presence = client.subscribe('presence-chat') as PresenceChannel;\n\npresence.bind('realtime:subscription_succeeded', () => {\n  console.log('Members:', presence.getMembers());\n  console.log('Me:', presence.me);\n});\n\npresence.bind('realtime:member_added', (member) => {\n  console.log('Joined:', member);\n});\n\npresence.bind('realtime:member_removed', (member) => {\n  console.log('Left:', member);\n});\n```\n\n`channel.me` is derived from the signed `channel_data` returned by your `authEndpoint`.\nIt becomes available only after `realtime:subscription_succeeded`.\n\n## Client Events\n\nTrigger events directly from the client on private or presence channels:\n\n```typescript\nconst privateChannel = client.subscribe('private-chat');\nprivateChannel.trigger('client-typing', { user: 'alice' });\n```\n\n## Connection States\n\nMonitor the connection lifecycle:\n\n```typescript\nclient.bind('state_change', ({ previous, current }) => {\n  console.log(`${previous} -> ${current}`);\n});\n```\n\nStates: `initialized` → `connecting` → `connected` → `disconnected` / `unavailable`\n\n## API Reference\n\nSee [docs/api-reference.md](docs/api-reference.md) for the full API.\n\n## Browser Support\n\nAny browser with WebSocket and `fetch` support:\n\n- Chrome 42+\n- Firefox 39+\n- Safari 10.1+\n- Edge 14+\n- Brave 10+\n\n## Links\n\n- [Installation Guide](docs/installation.md)\n- [Quick Start Tutorial](docs/quickstart.md)\n- [API Reference](docs/api-reference.md)\n- [Architecture Guide](docs/architecture.md)\n- [Contributing](CONTRIBUTING.md)\n- [Changelog](CHANGELOG.md)\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","readmeFilename":"README.md"}