{"id":28171204,"url":"https://github.com/green-api/whatsapp-api-client-js-v2","last_synced_at":"2026-03-03T19:01:11.357Z","repository":{"id":291803243,"uuid":"953799150","full_name":"green-api/whatsapp-api-client-js-v2","owner":"green-api","description":"whatsapp-api-client-js-v2","archived":false,"fork":false,"pushed_at":"2025-10-20T03:54:21.000Z","size":94,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-20T07:34:19.861Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-24T05:09:40.000Z","updated_at":"2025-10-20T03:54:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b96df15-5f4d-4645-8153-d4461a096aef","html_url":"https://github.com/green-api/whatsapp-api-client-js-v2","commit_stats":null,"previous_names":["green-api/whatsapp-api-client-js-v2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/green-api/whatsapp-api-client-js-v2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-client-js-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-client-js-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-client-js-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-client-js-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/green-api","download_url":"https://codeload.github.com/green-api/whatsapp-api-client-js-v2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/green-api%2Fwhatsapp-api-client-js-v2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30056056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-05-15T18:16:19.448Z","updated_at":"2026-03-03T19:01:11.349Z","avatar_url":"https://github.com/green-api.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GREEN-API WhatsApp SDK Library v2\n\nA TypeScript/JavaScript SDK for interacting with the GREEN-API WhatsApp gateway.\n\n## Installation\n\n```bash\nnpm install @green-api/whatsapp-api-client-js-v2\n# or\nyarn add @green-api/whatsapp-api-client-js-v2\n```\n\n#### API\n\nDocumentation for the REST API is located at [link](https://green-api.com/en/docs/api/). The library is a wrapper for\nthe REST API,\nso the documentation at the link above is also applicable to the library itself.\n\n#### Authorization\n\nTo send a message or perform other GREEN-API methods, the WhatsApp account in the phone application must be in the\nauthorized state. To authorize the instance, go to [console](https://console.green-api.com/) and\nscan the QR code using the WhatsApp application.\n\n## Getting Started\n\nTo use the SDK, you need to create an instance of the `GreenApiClient` with your GREEN-API instance credentials:\n\n```typescript\nimport { GreenApiClient } from '@green-api/whatsapp-api-client-js-v2';\n\nconst client = new GreenApiClient({\n    idInstance: 12345,\n    apiTokenInstance: 'your-api-token'\n});\n```\n\nFor Partner API access, use the `GreenApiPartnerClient`:\n\n```typescript\nimport { GreenApiPartnerClient } from '@green-api/whatsapp-api-client-js-v2';\n\nconst partnerClient = new GreenApiPartnerClient({\n    partnerToken: 'your-partner-token',\n    partnerApiUrl: 'https://api.green-api.com' // Optional, defaults to this URL\n});\n```\n\n## Usage Examples\n\n### Sending a Text Message\n\n```typescript\nawait client.sendMessage({\n    chatId: '1234567890@c.us',\n    message: 'Hello from GREEN-API SDK!'\n});\n```\n\n### Sending a File by URL\n\n```typescript\nawait client.sendFileByUrl({\n    chatId: '1234567890@c.us',\n    file: {\n        url: 'https://example.com/file.pdf',\n        fileName: 'document.pdf'\n    },\n    caption: 'Check this file'\n});\n```\n\n### Creating a Poll\n\n```typescript\nawait client.sendPoll({\n    chatId: '1234567890@c.us',\n    message: 'What\\'s your favorite color?',\n    options: [\n        {optionName: 'Red'},\n        {optionName: 'Blue'},\n        {optionName: 'Green'}\n    ],\n    multipleAnswers: false\n});\n```\n\n### Managing Groups\n\n```typescript\n// Create a group\nconst group = await client.createGroup({\n    groupName: 'My Test Group',\n    chatIds: ['1234567890@c.us', '0987654321@c.us']\n});\n\n// Add a participant\nawait client.addGroupParticipant({\n    groupId: group.chatId,\n    participantChatId: '1122334455@c.us'\n});\n```\n\n### Receiving Notifications\n\n```typescript\n// Receive notification with 30 sec timeout\nconst notification = await client.receiveNotification(30);\nif (notification) {\n    console.log('Received notification:', notification.body.typeWebhook);\n\n    // Process the notification\n    if (notification.body.typeWebhook === 'incomingMessageReceived') {\n        // Handle incoming message\n        console.log('Message:', notification.body.messageData);\n    }\n\n    // Delete the notification from queue after processing\n    await client.deleteNotification(notification.receiptId);\n}\n\n// Download file from a message\nconst fileData = await client.downloadFile({\n    chatId: '1234567890@c.us',\n    idMessage: 'MESSAGE_ID_WITH_FILE'\n});\nconsole.log('File URL:', fileData.downloadUrl);\n```\n\n### Working with WhatsApp Statuses (Beta)\n\n```typescript\n// Send text status\nawait client.sendTextStatus({\n    message: \"Hello from GREEN-API SDK!\",\n    backgroundColor: \"#228B22\", // Green background\n    font: \"SERIF\",\n    participants: [\"1234567890@c.us\"] // Optional: limit visibility to specific contacts\n});\n\n// Send media status\nawait client.sendMediaStatus({\n    urlFile: \"https://example.com/image.jpg\",\n    fileName: \"image.jpg\",\n    caption: \"Check out this view!\",\n    participants: [\"1234567890@c.us\"]\n});\n\n// Get status statistics\nconst stats = await client.getStatusStatistic({\n    idMessage: \"BAE5F4886F6F2D05\"\n});\nconsole.log(`Status was viewed by ${stats.length} contacts`);\n\n// Get incoming statuses from contacts\nconst statuses = await client.getIncomingStatuses({minutes: 60}); // Last hour\nstatuses.forEach(status =\u003e {\n    console.log(`Status from ${status.senderName} at ${new Date(status.timestamp * 1000)}`);\n});\n```\n\n### Partner API (Instance Management)\n\n```typescript\n// Get all instances\nconst instances = await partnerClient.getInstances();\nconsole.log(`Total instances: ${instances.length}`);\nconsole.log(`Active instances: ${instances.filter(i =\u003e !i.deleted).length}`);\n\n// Create a new instance\nconst instance = await partnerClient.createInstance({\n    name: \"Marketing Campaign\",\n    incomingWebhook: \"yes\",\n    outgoingWebhook: \"yes\",\n    delaySendMessagesMilliseconds: 3000\n});\nconsole.log(`Created instance with ID: ${instance.idInstance}`);\nconsole.log(`API Token: ${instance.apiTokenInstance}`);\n\n// Delete an instance\nconst result = await partnerClient.deleteInstanceAccount({\n    idInstance: instance.idInstance\n});\nif (result.deleteInstanceAccount) {\n    console.log(\"Instance successfully deleted\");\n}\n```\n\n### Editing and Deleting Messages\n\n```typescript\n// Edit a message\nconst editResult = await client.editMessage({\n    chatId: '1234567890@c.us',\n    idMessage: 'BAE5367237E13A87',\n    message: 'This is the edited message text'\n});\nconsole.log('Edited message ID:', editResult.idMessage);\n\n// Delete a message for everyone\nawait client.deleteMessage({\n    chatId: '1234567890@c.us',\n    idMessage: 'BAE5F4886F6F2D05'\n});\n\n// Delete a message only for sender\nawait client.deleteMessage({\n    chatId: '1234567890@c.us',\n    idMessage: 'BAE5F4886F6F2D05',\n    onlySenderDelete: true\n});\n```\n\n## SDK methods\n\nThe SDK provides the following groups of methods:\n\n1. **Message Sending Methods**\n    - `sendMessage`\n    - `sendFileByUrl`\n    - `sendFileByUpload`\n    - `sendPoll`\n    - `forwardMessages`\n    - `sendLocation`\n    - `sendContact`\n    - `uploadFile`\n\n2. **Account Management Methods**\n    - `reboot`\n    - `logout`\n    - `getStateInstance`\n    - `getQR`\n    - `getSettings`\n    - `setSettings`\n    - `getWaSettings`\n    - `setProfilePicture`\n    - `getAuthorizationCode`\n\n3. **Message Queue Methods**\n    - `showMessagesQueue`\n    - `clearMessagesQueue`\n\n4. **Service Methods**\n    - `readChat`\n    - `checkWhatsapp`\n    - `getAvatar`\n    - `getContacts`\n    - `getContactInfo`\n    - `archiveChat`\n    - `unarchiveChat`\n    - `setDisappearingChat`\n    - `editMessage`\n    - `deleteMessage`\n\n5. **Group Management Methods**\n    - `createGroup`\n    - `updateGroupName`\n    - `getGroupData`\n    - `addGroupParticipant`\n    - `removeGroupParticipant`\n    - `setGroupAdmin`\n    - `removeAdmin`\n    - `setGroupPicture`\n    - `leaveGroup`\n\n6. **Journal Methods**\n    - `getMessage`\n    - `getChatHistory`\n    - `lastIncomingMessages`\n    - `lastOutgoingMessages`\n\n7. **Message Receiving Methods**\n    - `receiveNotification`\n    - `deleteNotification`\n    - `downloadFile`\n\n8. **Status Methods (Beta)**\n    - `sendTextStatus`\n    - `sendVoiceStatus`\n    - `sendMediaStatus`\n    - `deleteStatus`\n    - `getStatusStatistic`\n    - `getIncomingStatuses`\n    - `getOutgoingStatuses`\n\n9. **Partner API Methods**\n    - `getInstances`\n    - `createInstance`\n    - `deleteInstanceAccount`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-api-client-js-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreen-api%2Fwhatsapp-api-client-js-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreen-api%2Fwhatsapp-api-client-js-v2/lists"}