{"library":"magicbell","title":"MagicBell Deprecated API Wrapper","description":"The `magicbell` npm package is a deprecated JavaScript/TypeScript API wrapper designed for interacting with the MagicBell notification service. Originally, it provided client classes like `ProjectClient` and `UserClient` to facilitate sending and managing notifications. As of version 4.5.1, this package is no longer maintained and advises users to migrate to the `magicbell-js` package. The `magicbell-js` package, currently at version 1.6.0, serves as the modern, actively developed JavaScript/TypeScript SDK, offering a unified `Client` for both project and user authentication via tokens, and includes features for real-time notification listening. MagicBell provides a multi-channel push notification service, including in-app, email, mobile push, web push, Slack, and SMS, through a single API, handling preferences and delivery tracking.","language":"javascript","status":"deprecated","last_verified":"Sun Apr 19","install":{"commands":["npm install magicbell"],"cli":null},"imports":["import { Client } from 'magicbell-js/project-client';","import { Client } from 'magicbell-js/user-client';","import { Realtime } from 'magicbell-js/realtime';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Client } from 'magicbell-js/project-client';\nimport { Realtime } from 'magicbell-js/realtime';\n\nconst MAGICBELL_PROJECT_TOKEN = process.env.MAGICBELL_PROJECT_TOKEN ?? ''; // Replace with your MagicBell Project Token\nconst MAGICBELL_USER_JWT = process.env.MAGICBELL_USER_JWT ?? ''; // Replace with a user-specific JWT\n\nasync function sendAndListenNotifications() {\n  if (!MAGICBELL_PROJECT_TOKEN || !MAGICBELL_USER_JWT) {\n    console.error('MagicBell tokens are not set. Please provide them as environment variables.');\n    return;\n  }\n\n  // Initialize the Project Client with your project token\n  const projectClient = new Client({\n    token: MAGICBELL_PROJECT_TOKEN,\n  });\n\n  // Send a test broadcast notification\n  try {\n    const broadcastResult = await projectClient.broadcasts.create({\n      broadcast: {\n        recipients: [{ external_id: 'your-user-external-id', email: 'user@example.com' }],\n        title: 'New Feature Alert!',\n        content: 'Check out our latest updates.',\n      },\n    });\n    console.log('Broadcast sent:', broadcastResult);\n  } catch (error) {\n    console.error('Failed to send broadcast:', error);\n  }\n\n  // Initialize the Realtime client with a user JWT for listening\n  const realtimeClient = new Realtime({\n    token: MAGICBELL_USER_JWT,\n  });\n\n  // Listen for new notifications\n  realtimeClient.onNotification((notification) => {\n    console.log('Received new notification:', notification);\n  });\n\n  console.log('Listening for real-time notifications...');\n\n  // In a real application, you would manage the connection lifecycle (e.g., connect, disconnect)\n  // For this example, we'll keep it simple.\n  // To stop listening, you would typically call realtimeClient.disconnect();\n}\n\nsendAndListenNotifications().catch(console.error);\n","lang":"typescript","description":"This quickstart demonstrates how to use the `magicbell-js` package (the recommended replacement for `magicbell`) to send a broadcast notification and listen for real-time user notifications.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}