{"id":18923991,"url":"https://github.com/green-api/whatsapp-api-calls-client-js","last_synced_at":"2026-03-13T23:30:22.145Z","repository":{"id":261555569,"uuid":"863912181","full_name":"green-api/whatsapp-api-calls-client-js","owner":"green-api","description":"This library is for creating an application to call via WhatsApp. ","archived":false,"fork":false,"pushed_at":"2025-02-20T12:42:33.000Z","size":354,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-20T13:39:23.233Z","etag":null,"topics":["javascript","voip","whatsapp","whatsapp-api-javascript","whatsapp-calls","whatsapp-library"],"latest_commit_sha":null,"homepage":"https://green-api.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/green-api.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":"2024-09-27T06:33:17.000Z","updated_at":"2024-12-26T12:15:39.000Z","dependencies_parsed_at":"2025-02-20T13:32:50.718Z","dependency_job_id":"94706adc-032f-4ab6-b21b-50c6823d0114","html_url":"https://github.com/green-api/whatsapp-api-calls-client-js","commit_stats":null,"previous_names":["green-api/whatsapp-api-calls-client-js"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-calls-client-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-calls-client-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-calls-client-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-calls-client-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/green-api","download_url":"https://codeload.github.com/green-api/whatsapp-api-calls-client-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239921877,"owners_count":19718842,"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","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":["javascript","voip","whatsapp","whatsapp-api-javascript","whatsapp-calls","whatsapp-library"],"created_at":"2024-11-08T11:05:10.365Z","updated_at":"2026-03-13T23:30:22.115Z","avatar_url":"https://github.com/green-api.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# whatsapp-api-calls-client Library for JavaScript\n\n[![license](https://img.shields.io/badge/license-CC%20BY--ND%204.0-green)](https://creativecommons.org/licenses/by-nd/4.0/)\n\n## Support Links\n\n[![Support](https://img.shields.io/badge/support@green--api.com-D14836?style=for-the-badge\u0026logo=gmail\u0026logoColor=white)](mailto:support@greenapi.com)\n[![Support](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge\u0026logo=telegram\u0026logoColor=white)](https://t.me/greenapi_support_eng_bot)\n[![Support](https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white)](https://wa.me/77273122366)\n\n## Guides \u0026 News\n\n[![Guides](https://img.shields.io/badge/YouTube-%23FF0000.svg?style=for-the-badge\u0026logo=YouTube\u0026logoColor=white)](https://www.youtube.com/@greenapi-en)\n[![News](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge\u0026logo=telegram\u0026logoColor=white)](https://t.me/green_api)\n[![News](https://img.shields.io/badge/WhatsApp-25D366?style=for-the-badge\u0026logo=whatsapp\u0026logoColor=white)](https://whatsapp.com/channel/0029VaLj6J4LNSa2B5Jx6s3h)\n\n- [Документация на русском языке](./docs/README_ru.md)\n\nThis library helps you easily create a JavaScript/TypeScript application to receive incoming calls and start outgoing calls via WhatsApp using the API service [green-api.com](https://green-api.com/en/). To use this library, you need to obtain your `ID_INSTANCE` and `API_TOKEN_INSTANCE` from [control panel](](https://console.green-api.com)). The library is free for developers.\n\n## API\n\nThe API is based on WebSockets and the WebRTC protocol.\n\nPros of using WebRTC:\n\n* Availability in browsers;\n* Low latency;\n* Congestion control;\n* Mandatory encryption.\n\n## Installing \u0026 Importing\n\nLibrary supports both browser environment without package managers and Node/Webpack apps with package manager that can\nhandle `require` or `import` module expressions.\n\n**Installing for webpack and npm based apps:**\n\n```shell\nnpm i @green-api/whatsapp-api-calls-client-js\n```\n\n**Way to import the library in a project:**\n\nUsing ES6 JavaScript or TypeScript\n```javascript\nimport { GreenApiVoipClient } from '@green-api/whatsapp-api-calls-client-js';\n```\n\n**Import \u0026 installing for vanilla JavaScript modify index.html:**\n```html\n\u003cscript src=\"https://unpkg.com/@green-api/whatsapp-api-client/lib/whatsapp-api-client.min.js\"\u003e\u003c/script\u003e\n```  \n\n## Authentication\n\nTo use the library, you need a GREEN-API account on [green-api.com](https://green-api.com/en) and authentication completed by mobile WhatsApp app. To register the account, you must proceed to the [control panel](https://console.green-api.com/). After registering you get unique pair of `ID_INSTANCE` and `API_TOKEN_INSTANCE` keys.\n\nWhatsApp mobile app authentication may be achieved by [control panel](https://console.green-api.com/). You need to\nscan QR-code generated within the control panel.\n\n## Examples\n\nThe GreenApiVoipClient class emits several important events that you can listen to in order to manage the lifecycle of a call.\n\n### Initialization\n\n```javascript\nimport { GreenApiVoipClient } from '@green-api/whatsapp-api-calls-client-js';\n\n// Initialize the GreenApiVoipClient\nconst greenApiVoipClient = new GreenApiVoipClient();\n\n// Example initialization options, replace with your actual instance details\nconst initOptions = {\n  idInstance: 'your-id-instance',\n  apiTokenInstance: 'your-api-token-instance',\n  apiUrl: 'your-api-url-voip' // usually https://pool.voip.green-api.com, where pool is first 4 symbols at idInstance\n};\n\n// Initialize the client\ngreenApiVoipClient.init(initOptions).then(() =\u003e {\n  console.log('GreenApiVoipClient initialized and connected.');\n}).catch(error =\u003e {\n  console.error('Failed to initialize GreenApiVoipClient:', error);\n});\n```\n\n### Handling Incoming Calls\n\n```javascript\nconst callBtns = document.getElementById('initBtns');\nconst audioElement = document.createElement('audio'); // audio element to play the sound\n\n// Subscribe to the incoming call event and get call info from WhatsApp\ngreenApiVoipClient.addEventListener('incoming-call', (event) =\u003e {\n  console.log(event.detail.info);\n\n  // Render accept and reject call buttons\n  const acceptCallBtn = document.createElement('button');\n  const rejectCallBtn = document.createElement('button');\n  \n  acceptCallBtn.addEventListener('click', async () =\u003e {\n    await greenApiVoipClient.acceptCall();\n  });\n  \n  rejectCallBtn.addEventListener('click', async () =\u003e {\n    await greenApiVoipClient.rejectCall();\n  });\n\n  callBtns.append(acceptCallBtn, rejectCallBtn);\n});\n\ngreenApiVoipClient.addEventListener('remote-stream-ready', (event) =\u003e {\n  // Assign remote media stream value from event so you can hear the voice of the other call participant\n  audioElement.srcObject = event.detail;\n});\n```\n\n### Making Outgoing Calls\n\n```javascript\nconst callBtn = document.getElementById('call');\nconst audioElement = document.getElementById('remote'); // audio element to play the sound\n\ncallBtn.addEventListener('click', async () =\u003e {\n  try {\n    await greenApiVoipClient.startCall('Receiver phone number');\n  } catch (err) {\n    console.error(err);\n  }\n});\n\ngreenApiVoipClient.addEventListener('remote-stream-ready', (event) =\u003e {\n  // Assign remote media stream value from event so you can hear the voice of the other call participant\n  audioElement.srcObject = event.detail;\n});\n```  \n\n## Demo examples on Vanilla JS \u0026 React\n\nYou can find our demo examples:\n* [Vanilla JS](./examples/basic-usage-vanilla-js/)\n* [React JS](./examples/react/)\n\nDownload the required example from the repository at the link. Then  following steps in the project folder:\n\n```shell\nnpm install\n\nnpm run dev\n```\n`npm install` runs only once during the first installation.\n\nAfter that, the client web interface will be available for you at the specified address, for example:\n\n```\nnpm run dev\n\n\u003e vite-project@0.0.0 dev\n\u003e vite\n\nVITE v5.2.11 ready in 969 ms\n\n➜ Local: http://localhost:80/\n➜ Network: use --host to expose\n➜ press h + enter to show help\n```\n\nOpen the link in your preferred browser. For work with the app, use `idInstance` and `apiTokenInstance` from [control panel](https://console.green-api.com/). After authorization, you can receive incoming calls and make outgoing ones.\n\nTo stop the server, press `Ctrl + C` and after press the `Y` button in your terminal.\n\n## Documentation\n\nFor more detailed information, please refer to the [Step by step guide](./docs/step-by-step.md).\n\n## Third-party Libraries\n\n- [socket.io-client](https://www.npmjs.com/package/socket.io-client) - WebSocket library\n- [freeice](https://www.npmjs.com/package/freeice) - Free random STUN or TURN server for your WebRTC application\n\n## License\n\nLicensed under the Creative Commons License. For additional information, see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-api-calls-client-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-api%2Fwhatsapp-api-calls-client-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-api-calls-client-js/lists"}