{"library":"sip.js","title":"SIP.js WebRTC Library","description":"SIP.js is a comprehensive JavaScript library designed for building real-time communication applications using SIP (Session Initiation Protocol) over WebSockets, with deep integration for WebRTC. It enables peer-to-peer audio and video sessions, instant messaging, presence, and DTMF signaling. The current stable version is 0.21.2. The project maintains an active release cadence with regular minor and patch updates, often introducing new features and addressing bugs. Key differentiators include its TypeScript-first development, compatibility with standard SIP servers like Asterisk and FreeSWITCH, and support for all major web browsers and Node.js environments. It offers both a simplified `SimpleUser` API for common use cases and a full API framework for more granular control over SIP sessions.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install sip.js"],"cli":null},"imports":["import { Web } from 'sip.js';\nconst simpleUser = new Web.SimpleUser(server, options);","import { UserAgent } from 'sip.js';\nconst userAgent = new UserAgent(options);","import { SessionState } from 'sip.js';\n// ... switch (newState) { case SessionState.Established: ... }"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Web } from \"sip.js\";\n\n// Helper function to get an HTML audio element\nfunction getAudioElement(id: string): HTMLAudioElement {\n  const el = document.getElementById(id);\n  if (!(el instanceof HTMLAudioElement)) {\n    throw new Error(`Element \"${id}\" not found or not an audio element.`);\n  }\n  return el;\n}\n\n// Options for SimpleUser\nconst options: Web.SimpleUserOptions = {\n  aor: \"sip:alice@example.com\", // caller\n  media: {\n    constraints: { audio: true, video: false }, // audio only call\n    remote: { audio: getAudioElement(\"remoteAudio\") }\n  }\n};\n\n// WebSocket server to connect with\nconst server = \"wss://sip.example.com\";\n\n// Construct a SimpleUser instance\nconst simpleUser = new Web.SimpleUser(server, options);\n\n// Connect to server and place call\nsimpleUser.connect()\n  .then(() => simpleUser.call(\"sip:bob@example.com\"))\n  .catch((error: Error) => {\n    console.error(\"Call failed:\", error);\n    // Handle call failure\n  });","lang":"typescript","description":"This quickstart demonstrates how to establish a basic audio-only SIP call using the `SimpleUser` API, connecting to a WebSocket server, and handling call initiation with basic error logging.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}