{"id":14987136,"url":"https://github.com/secreto31126/whatsapp-api-js","last_synced_at":"2025-05-15T19:06:26.493Z","repository":{"id":36985981,"uuid":"485584222","full_name":"Secreto31126/whatsapp-api-js","owner":"Secreto31126","description":"A TypeScript server agnostic Whatsapp's Official API framework","archived":false,"fork":false,"pushed_at":"2025-05-15T11:02:25.000Z","size":9010,"stargazers_count":189,"open_issues_count":3,"forks_count":37,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-15T19:05:53.047Z","etag":null,"topics":["api","bot","bot-api","bot-framework","business-api","chatbot","cloud","cloud-api","deno","javascript","nodejs","npm-package","whatsapp","whatsapp-api","whatsapp-bot","whatsapp-business","whatsapp-business-api","whatsapp-cloud","whatsapp-cloud-api"],"latest_commit_sha":null,"homepage":"","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/Secreto31126.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":"Secreto31126","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-04-26T00:53:25.000Z","updated_at":"2025-05-13T15:11:08.000Z","dependencies_parsed_at":"2024-04-22T08:59:42.380Z","dependency_job_id":"dba5dd6c-327d-4514-af39-4fcb9b347866","html_url":"https://github.com/Secreto31126/whatsapp-api-js","commit_stats":{"total_commits":920,"total_committers":10,"mean_commits":92.0,"dds":"0.10108695652173916","last_synced_commit":"58e4d3d6b6dac243235358e3850107fc3dbfbae9"},"previous_names":[],"tags_count":103,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Secreto31126%2Fwhatsapp-api-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Secreto31126%2Fwhatsapp-api-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Secreto31126%2Fwhatsapp-api-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Secreto31126%2Fwhatsapp-api-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Secreto31126","download_url":"https://codeload.github.com/Secreto31126/whatsapp-api-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254404356,"owners_count":22065641,"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":["api","bot","bot-api","bot-framework","business-api","chatbot","cloud","cloud-api","deno","javascript","nodejs","npm-package","whatsapp","whatsapp-api","whatsapp-bot","whatsapp-business","whatsapp-business-api","whatsapp-cloud","whatsapp-cloud-api"],"created_at":"2024-09-24T14:14:09.058Z","updated_at":"2025-05-15T19:06:26.470Z","avatar_url":"https://github.com/Secreto31126.png","language":"TypeScript","funding_links":["https://patreon.com/Secreto31126"],"categories":[],"sub_categories":[],"readme":"# whatsapp-api-js v5\n\n[![npm](https://img.shields.io/npm/v/whatsapp-api-js?color=4ccc1c)](https://www.npmjs.com/package/whatsapp-api-js)\n[![Contributors](https://img.shields.io/github/all-contributors/Secreto31126/whatsapp-api-js)](#contributors)\n\nA TypeScript server agnostic Whatsapp's Official API framework.\n\n## List of contents\n\n- [whatsapp-api-js v5](#whatsapp-api-js-v5)\n    - [List of contents](#list-of-contents)\n    - [Set up](#set-up)\n    - [Examples and Tutorials](#examples-and-tutorials)\n    - [Types](#types)\n    - [Changelog](#changelog)\n    - [Documentation](#documentation)\n    - [Contributors](#contributors)\n    - [Contributions](#contributions)\n    - [Breaking changes](#breaking-changes)\n    - [Beta releases](#beta-releases)\n\n## Set up\n\nBefore all, you will need a Meta Bussiness App with WhatsApp API activated. You\ncan create your first app following\n[this steps](https://developers.facebook.com/docs/whatsapp/cloud-api/get-started).\n\n- Get the API token, either a temporal or a\n  [permanent one](https://developers.facebook.com/docs/whatsapp/business-management-api/get-started).\n- Get your App secret from the dashboard in App Settings \u003e Basic \u003e App Secret.\n- More in-depth information on how to set and retrieve this values is available\n  at\n  [the module documentation](https://whatsappapijs.web.app/types/types.TheBasicConstructorArguments.html)\n\nYou can now install the module using npm:\n\n```sh\nnpm install whatsapp-api-js\n```\n\nWhich will let you write code like this:\n\n```js\nimport { WhatsAppAPI } from \"whatsapp-api-js\";\nimport { Document, Image, Text } from \"whatsapp-api-js/messages\";\n\n// Kind reminder to not hardcode your token and secret\nconst TOKEN = \"YOUR_TOKEN\";\nconst APP_SECRET = \"YOUR_SECRET\";\n\n/** @type WhatsAppAPI\u003cnumber\u003e */\nconst Whatsapp = new WhatsAppAPI({ token: TOKEN, appSecret: APP_SECRET });\n\n// Assuming post is called on a POST request to your server\nasync function post(e) {\n    // Too long? Read https://whatsappapijs.web.app/modules/middleware.html\n    return await Whatsapp.post(\n        JSON.parse(e.data),\n        e.data,\n        e.headers[\"x-hub-signature-256\"]\n    );\n}\n\nWhatsapp.on.message = async ({ phoneID, from, message, name, reply }) =\u003e {\n    console.log(\n        `User ${name} (${from}) sent to bot ${phoneID} ${JSON.stringify(\n            message\n        )}`\n    );\n\n    let response;\n\n    if (message.type === \"text\") {\n        response = await reply(\n            new Text(`*${name}* said:\\n\\n${message.text.body}`),\n            true\n        );\n    }\n\n    if (message.type === \"image\") {\n        response = await reply(\n            new Image(message.image.id, true, `Nice photo, ${name}`)\n        );\n    }\n\n    if (message.type === \"document\") {\n        response = await reply(\n            new Document(message.document.id, true, undefined, \"Our document\")\n        );\n    }\n\n    console.log(\n        response ??\n            \"There are more types of messages, such as contacts, \" +\n                \"locations, templates, interactive, reactions and \" +\n                \"all the other media types.\"\n    );\n\n    Whatsapp.markAsRead(phoneID, message.id);\n\n    return 200;\n};\n\nWhatsapp.on.sent = ({ phoneID, to, message }) =\u003e {\n    console.log(`Bot ${phoneID} sent to user ${to} ${message}`);\n};\n```\n\nTo receive the messages updates, you must set-up the webhook at your Meta app.\nBack in the dashboard, click on WhatsApp \u003e Settings, write down your webhook\nURL, and make sure to subscribe to the messages event. You will also be asked\nfor a Verify Token. This can be any string you want.\n\nThe package also includes a GET handler for the webhook authentication:\n\n```js\nimport { WhatsAppAPI } from \"whatsapp-api-js\";\n\nconst TOKEN = \"YOUR_TOKEN\";\nconst APP_SECRET = \"YOUR_SECRET\";\nconst VERIFY_TOKEN = \"YOUR_VERIFY_TOKEN\";\n\nconst Whatsapp = new WhatsAppAPI({\n    token: TOKEN,\n    appSecret: APP_SECRET,\n    webhookVerifyToken: VERIFY_TOKEN\n});\n\n// Assuming get is called on a GET request to your server\nfunction get(e) {\n    // Too long!? Read https://whatsappapijs.web.app/modules/middleware.html\n    return Whatsapp.get(e.query);\n}\n```\n\nAnd that's it! Now you have a functioning Whatsapp Bot connected to your server.\nFor more information on the setup process for specific runtimes and frameworks,\ncheck out the\n[Environments.md file](https://github.com/Secreto31126/whatsapp-api-js/blob/main/ENVIRONMENTS.md).\n\n## Examples and Tutorials\n\nThere are a few examples that cover how to create each type of message, and how\nto use the basic methods of the library.\n\nCheck them out in the\n[examples folder](https://github.com/Secreto31126/whatsapp-api-js/blob/main/EXAMPLES/).\n\n## Types\n\nThe library is fully typed. Most types are available by importing `/types` or\n`/emitters` files:\n\n```ts\nimport { GetParams, PostData } from \"whatsapp-api-js/types\";\nimport { OnMessage, OnSent, OnStatus } from \"whatsapp-api-js/emitters\";\n```\n\n## Changelog\n\nTo know what changed between updates, check out the\n[releases on Github](https://github.com/Secreto31126/whatsapp-api-js/releases).\n\n## Documentation\n\nThe latest release documentation is available at\n[whatsappapijs.web.app](https://whatsappapijs.web.app/), and previous versions\nare archived at\n[secreto31126.github.io/whatsapp-api-js](https://secreto31126.github.io/whatsapp-api-js/).\n\n## Contributors\n\n[Emoji key ✨](https://allcontributors.org/docs/en/emoji-key)\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/DiegoCarrillogt\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/29462621?v=4?s=100\" width=\"100px;\" alt=\"Diego Carrillo\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDiego Carrillo\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#financial-DiegoCarrillogt\" title=\"Financial\"\u003e💵\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/HysMX\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/50180189?v=4?s=100\" width=\"100px;\" alt=\"Omar\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eOmar\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Secreto31126/whatsapp-api-js/issues?q=author%3AHysMX\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"#financial-HysMX\" title=\"Financial\"\u003e💵\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/RahulLanjewar93\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/63550998?v=4?s=100\" width=\"100px;\" alt=\"Rahul Lanjewar\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eRahul Lanjewar\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Secreto31126/whatsapp-api-js/commits?author=RahulLanjewar93\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/Secreto31126/whatsapp-api-js/commits?author=RahulLanjewar93\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#ideas-RahulLanjewar93\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/felixarjuna\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/79026094?v=4?s=100\" width=\"100px;\" alt=\"Felix Arjuna\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eFelix Arjuna\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Secreto31126/whatsapp-api-js/issues?q=author%3Afelixarjuna\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e \u003ca href=\"#security-felixarjuna\" title=\"Security\"\u003e🛡️\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n## Contributions\n\nIf you have some free time and really want to improve the library or fix dumb\nbugs, feel free to read\n[CONTRIBUTING.md file](https://github.com/Secreto31126/whatsapp-api-js/blob/main/CONTRIBUTING.md).\n\n## Breaking changes\n\nYou can get a full list of breaking changes in the\n[BREAKING.md file](https://github.com/Secreto31126/whatsapp-api-js/blob/main/BREAKING.md).\n\n## Beta releases\n\nInstall the latest beta release with `npm install whatsapp-api-js@beta`. As any\nbeta, it is 110% likely to break. I also use this tag to test npm releases. Use\nit at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecreto31126%2Fwhatsapp-api-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecreto31126%2Fwhatsapp-api-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecreto31126%2Fwhatsapp-api-js/lists"}